Spring GraphQL 1.4.1 - GraphiQL Schema Load error
I just upgraded to Spring GraphQL 1.4.1 and GraphQL Java 24.1 to upgrade to GraphiQL 5.0.0 and fix the issue with GraphiQL not loading. The GraphiQL URL now loads however It still fails to load the schema and shows the following error.
{ "errors": [ { "message": "Failed to execute 'json' on 'Response': Unexpected end of JSON input", "stack": "SyntaxError: Unexpected end of JSON input\n at https://esm.sh/@graphiql/[email protected]/X-ZWdyYXBocWw/es2022/toolkit.bundle.mjs:7:2407\n at Generator.next (<anonymous>)\n at n (https://esm.sh/@graphiql/[email protected]/X-ZWdyYXBocWw/es2022/toolkit.bundle.mjs:2:554)\n at https://esm.sh/@graphiql/[email protected]/X-ZWdyYXBocWw/es2022/toolkit.bundle.mjs:2:629" } ] }
Is there anything else required for GraphiQL 5.0.0 to work with the new Spring GraphQL 1.4.1? Thanks
I have tested this in several browsers, successfully, including Firefox and Safari. Nothing else is required to run GraphiQL as far as I know. Maybe an extension or company network rule affecting the CDN being used?
Ive narrowed it down to the introspection query that Spring GraphQL makes under the hood. Im not super familiar with the internals, but the libraries are loading, and if I go to /graphql/schema the full schema shows, however the introspection query below fails, which worked prior ro the upgrade.
Two things to note:
- I am creating the GraphQLSchema and GraphQlSource dynamically from configuration
- I am currently locked into these Spring versions for required company libs. Does the upgrade to 1.4.1 also require a Spring upgrade? I'm not sure what effects overriding to newer versions will have on other libs
- Spring 6.1.16,
- Spring Security 6.3.6
- Spring Boot 3.3.8
{"query":"
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
}
}
}
}
}
}
}
}
}
}
","operationName":"IntrospectionQuery"}
That introspection Query is sent by your browser by GraphiQL (you can check that in your networking tab), not spring-graphql. And on the server side, graphql-java replies with the defined schema. At this stage, I'm not sure where the problem is:
- maybe the graphiql explorer fails with this schema?
- maybe the schema is somehow invalid now?
- maybe the new spring+graphql libraries combination fails with your schema somehow
As a first step, you could roll back to 1.4.0 and copy paste this file in your src/main/resources/graphiql folder. If this fails, this points to 1) and you should probably open an issue in graphiql and share your generated schema there.
If this attempt works, this means that the problem could be 2) or 3) and I'm going to need a minimal sample application to dig into this.
Thanks!
I appreciate the quick reply, good to know on the introspection query. ill try the index.html override and see if that resolves the issue for now.
Im assuming the schema is good since the graphql/schema endpoint displays the raw schema as I expect it and since my IT tests all pass, but ill try to narrow down the scope of the issue
@bclozel rolling back to my older version of graphql-java 22.3 and spring-graphql 1.3.4 with the HTML override works with the new URLs, however upgrading to either 1.4.1 for spring or 24.1 for graphql-java both fail. with spring I get the same error I posted here, but with graphql-java 24.1 there seems to be an issue with some of the micrometer beans at startup.
So im not exactly sure what the issue is and havent had the time to isolate the actual culprit, but something doesnt play nice but at least im unblocked for now
Ok thanks for the update. I'll leave this issue opened for now, in case you can provide a minimal sample so that I can have a look.
If you would like us to look at this issue, please provide the requested information. If the information is not provided within the next 7 days this issue will be closed.
Closing due to lack of requested feedback. If you would like us to look at this issue, please provide the requested information and we will re-open the issue.