0

I am working on a headless WordPress + Next.js app

In my GraphiQL ide when i query the current viewer (me !) I keep getting null as a result

I am using the latest WP version + latest wpgraphqQL + latest WPGraphQL CORS plugin

May be this is caused by the fact that for the moment my WordPress installation is in local but i tried to add wpgraphQL on another website in production and to reproduce this and I still get this null for my current Viewer

Don't know if this issue is linked to wpgraphQL or me

Thanks for any help

Here is my query

query MyQuery {
 viewer {
 name
 username
 }
}

1 Answer 1

0

Viewer queries will return null when the authenticated user is not logged in.

For example:

  • If your WP Admin user is not logged in, you will receive null.
  • When your WP Admin user is logged in, you will receive the values for the viewer specified by your query.

If you are running queries within the WP Admin area and within the WP GraphiQL IDE, there is a small icon to the right of the "Run Query" (play) button with a profile icon.

Clicking this button will run your queries as authenticated (green dot) or not within the WP GraphiQL IDE.

You can find more details in the WP GraphQL docs here: https://www.wpgraphql.com/docs/wp-graphiql#toggle-between-public-and-authenticated-requests

answered Jan 15, 2024 at 13:16
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.