fix(graphiql): Allow GraphiQL to run even if a valid schema cannot be returned.#3031
Conversation
|
Thanks so much for this PR @linucks - this has been on my personal wishlist for a long time 🙌 cc: @josephfusco #3019 |
jasonbahl
left a comment
There was a problem hiding this comment.
@linucks I tested this change and I like it!
We'll be sure to provide a smoother experience like this when the Schema fails to load in the new version of the WPGraphQL IDE we're building here: https://github.com/wp-graphql/wpgraphql-ide I'd love to take this a step fu
|
fwiw, a failed schema can currently be tested with the following: <?php
add_action( 'graphql_register_types', function() {
register_graphql_mutation( 'testMutation', [
'inputFields' => [ 'test' => [ 'type' => 'String' ] ],
'outputFields' => [ 'test' => [ 'type' => 'NonExistantType' ] ], // <-- this will cause the schema to fail to load
'mutateAndGetPayload' => function( $input, $context, $info ) { return true; }
] );
} ); |
|
Code Climate has analyzed commit 6245643 and detected 0 issues on this pull request. View more on Code Climate. |
|
I pushed up a commit that includes the built assets. Of course we ideally shouldn't be versioning the built assets of graphiql, but here we are in 2024 versioning them 🤷🏻♂️ As @josephfusco and I work on the new WPGraphQL IDE over here: https://github.com/wp-graphql/wpgraphql-ide we plan to have better automation/workflows. |
What does this implement/fix? Explain your changes.
Currently GraphiQL won't load and just displays a spinner if there is an error generating a schema. An error is logged to the console, but it gives almost no indication of what the error was.
Even if a valid schema cannot be loaded, GraphiQL can still be used to make queries, and in the case of a broken schema, GraphiQL could then be used to determine which queries were failing and see why the schema was broken.
This fix allows GraphiQL to load, and displays the error message created in generating the schema in the console, so that a developer can see what caused the error.
Does this close any currently open issues?
Any relevant logs, error output, GraphiQL screenshots, etc?
Any other comments?
…
Where has this been tested?
Operating System: Wordpress Docker image sha256:14425bb2eae98ef05853f78e2c8bc3d91cff3b465f2933c6f105ac697facb3ea
WordPress Version: 6.4.2