Skip to content
This repository has been archived by the owner on Nov 15, 2020. It is now read-only.

No Schema Available? SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data #30

Open
mckhames opened this issue Oct 26, 2020 · 2 comments

Comments

@mckhames
Copy link

I've installed the wp-graphql and wp-graphiql API, but I can't seem to make any queries within the graphiql interface. I receive the error "SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data" when I make any queries or interactions. When I click "Explorer" I see "No Schema Available" - Any assistance would be greatly appreciated!

@jasonbahl
Copy link
Contributor

@mckhames what version of WPGraphQL are you on? As of v0.13.0 GraphiQL is now built-in to WPGraphQL and this plugin is no longer needed.

In any case, this usually means there's a PHP error that's preventing WordPress from being able to complete the GraphQL request.

I would recommend checking your php error logs on your server to see if you can find anything there.

Another thing you can try is opening Chrome DevTools when you're on the GraphiQL page and inspecting the "network" tab. The "response" tab will often show issues.

For example, I put the following code in a plugin:

add_action( 'init_graphql_request', function() {
	var_dump( 'test' );
	die();
} );

This code prevents WPGraphQL from properly executing, and thus GraphiQL won't get JSON in response and won't know what to show the user.

If I open the "Network" tab of Chrome Dev Tools, execute a GraphQL Query, then check the "Response" for that request, I can see the response that's preventing GraphiQL from getting a proper JSON response.

wp-graphql-debugging-network-tab

@mckhames
Copy link
Author

mckhames commented Nov 10, 2020

Thank you so much for this very detailed and helpful debugging guide. Looking at the response I receive, the payload is my entire front page, it seems. I can't quite understand why 0_0.

P.S. I did realize that I do not need GraphiQL and removed it, and have since updated to the latest GraphQL (thank y'all for integrating them!)

wp_graphql error

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants