Why do my GraphQL Link shows query error in WordPress

Viewed 3556

I installed WPGraphQL plugin on my wordpress dashboard but And I tried accessing it via mysite/graphql

I got this error

{"errors":[{"message":"GraphQL Request must include at least one of those two parameters: \"query\" or \"queryId\"","extensions":{"category":"request"}}],"extensions":{"debug":[]}}

What could be the cause?

3 Answers

You have to pass an query parameter e-g: http://localhost:8000/graphql?query={user(id:1){email}} and you want graphql-playground then install play-ground package then just access play-ground by this link: http://localhost:8000/graphql-playground

As others have stated, you need a query.

When the extension is activated, it serves as any API. It'll give you the data that you request, not direct you to some website. You can access the GraphiQL IDE to get a visual representation of the queries you can make.

I think something like this is what you may be after:

curl -v -X POST -H 'X-WP-NONCE: 6fd57fe0ac' --cookie 'wordpress_logged_in_37d007a56d816107ce5b52c10342db37=wordpress|1647471410|i2dnczBB8vm2pblmRJWQ0NtuQ1lA7elWpB1TiRhXeMi|9c3dc66b56babcafa294156dc91f65cc6b2c2feb5e784a0380eb6c44141fb5c6' -F 'query={posts{edges{node{id}}}}' 'http://localhost:8080/graphql'

Related