Gatsby & WordPress - 2.3. - WPGraphQL

by Jack Pritchard

Hey! Just so you know, this article is over 2 years old. Some of the information in it might be outdated, so take it with a grain of salt. I'm not saying it's not worth a read, but don't take everything in it as gospel. If you're curious about something, it never hurts to double-check with a more up-to-date source!

WPGraphQL

#

After installing the WPGraphQL plugin from Github, and installing it, we will now have access to a new endpoint in our WordPress environment. The endpoint is the name of your site with `/graphql'at the end of the URL.

When you first access this endpoint you'll be met with a confusing error which says that you need to provide at least a query or queryId.

This is because GraphQL is a very explicit querying language and required you to be specific with what data you want to be returned before it returns any payloads.

To get an understanding of the schema we do have available to us, we'll be using the WPGraphiQL plugin within our WordPress admin dashboard.

With the plugin, we'll query the posts available on our website and return the ID, date, slug, and title of each post using GraphQL and getting a JSON payload response.