-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
Describe the bug
I'm using a Spring Boot project configured with spring-boot-starter-graphql version 3.5.3, This setup brings in spring-graphql version 1.4.0 and the core graphql-java library version 24.0.
I've found a bug where the introspection query returns a response with invalid JSON. Specifically, the description fields for the built-in __Schema.directives and __Schema.subscriptionType fields are incorrectly formatted. They begin with a single quote (') instead of a double quote ("). This violates the JSON specification and causes parsing errors in many web-based GraphQL clients, such as Hoppscotch.
If this is not a bug and is an intended feature, I apologize. I may have misunderstood its purpose.
If you don't mind, I would be very grateful if you could explain why this is necessary in the code.
Thank you for your time.
To Reproduce
Steps to reproduce the bug:
- Set up a Spring Boot GraphQL service using the specified dependencies (spring-graphql 1.4.0 and graphql-java 24.0).
- Send a standard introspection query to the service endpoint.
** Introspection query **
The query written below is an introspection query that the Hoppscotch client sends to the GraphQL API server.
query IntrospectionQuery {
__schema {
queryType { name kind }
mutationType { name kind }
subscriptionType { name kind }
types {
...FullType
}
directives {
name
description
locations
args {
...InputValue
}
}
}
}
fragment FullType on __Type {
kind
name
description
fields(includeDeprecated: true) {
name
description
args {
...InputValue
}
type {
...TypeRef
}
isDeprecated
deprecationReason
}
inputFields {
...InputValue
}
interfaces {
...TypeRef
}
enumValues(includeDeprecated: true) {
name
description
isDeprecated
deprecationReason
}
possibleTypes {
...TypeRef
}
}
fragment InputValue on __InputValue {
name
description
type { ...TypeRef }
defaultValue
}
fragment TypeRef on __Type {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
ofType {
kind
name
}
}
}
}
}
}
}
}
}
}
Expected behavior
The GraphQL response string should be valid JSON and successfully parsed by standard JSON parsers, such as JSON.parse().
Actual behavior
The JSON response contains a specific string (in the description fields) that is not properly formatted. The string begins with a single quote ('), which makes the entire response an invalid JSON string. This causes a parsing error when a client attempts to use a JSON parser like JSON.parse().
The problematic code is located on lines 681 and 685 of the following URL:
| .description("'A list of all directives supported by this server.") |
| .description("'If this server support subscription, the type that subscription operations will be rooted at.") |