Skip to content

Conversation

@linucks
Copy link
Contributor

@linucks linucks commented Jan 31, 2024

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

@justlevine
Copy link
Collaborator

justlevine commented Jan 31, 2024

Thanks so much for this PR @linucks - this has been on my personal wishlist for a long time 🙌

cc: @josephfusco #3019

@justlevine justlevine added type: enhancement Improvements to existing functionality status: in review Awaiting review before merging or closing needs: reviewer response This needs the attention of a codeowner or maintainer graphiql ide Issues or pull requests related to the GraphiQL IDE labels Jan 31, 2024
jasonbahl
jasonbahl previously approved these changes Feb 2, 2024
Copy link
Collaborator

@jasonbahl jasonbahl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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

@jasonbahl
Copy link
Collaborator

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; }
	] );

} );

@qlty-cloud-legacy
Copy link

Code Climate has analyzed commit 6245643 and detected 0 issues on this pull request.

View more on Code Climate.

@jasonbahl
Copy link
Collaborator

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.

@jasonbahl jasonbahl merged commit f480fd2 into wp-graphql:develop Feb 2, 2024
@coveralls
Copy link

Coverage Status

coverage: 84.756%. remained the same
when pulling 6245643 on linucks:graphiql-broken-schema
into 49e2d5a on wp-graphql:develop.

This was referenced Feb 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

graphiql ide Issues or pull requests related to the GraphiQL IDE needs: reviewer response This needs the attention of a codeowner or maintainer status: in review Awaiting review before merging or closing type: enhancement Improvements to existing functionality

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants