1. 12
    Create and Test a GraphQL Endpoint for WordPress with wp-graphql
    1m 2s

Create and Test a GraphQL Endpoint for WordPress with wp-graphql

Share this video with your friends

Send Tweet
Published 3 years ago
Updated 3 years ago

GraphQL is a popular solution for many web applications because of the flexibility it offers the client by giving you exactly the data you need.

And there's a WordPress Plugin for it! We'll find and install the plugin in the Plugin Directory.

You'll notice that the custom post types and the fields from ACF aren't exposed by GraphQL. These will need to be added manually.

Instructor: [0:00] Let's add a GraphQL endpoint to WordPress. We do that by adding a new plugin and using the GraphQL plugin, so WPGraphQL. We install it and we activate it. We can see a couple of things. We've got GraphQL down here with some settings where we can set the endpoint. By default, it's GraphQL. We're able to find it there.

[0:22] There are other things that we're able to do, like allow this IDE which is a GraphiQL IDE to appear in the Admin bar, and various other settings we can do. Let's test it. We're getting an error, which means that there is an endpoint there.

[0:38] Let's construct our query in our GraphiQL editor with posts, nodes. Just get their titles for now. It's working here. To send it over JSON, it all needs to be on a single line.

[0:53] Now, we have the titles of all of our posts, so we do the same for pages. They all have titles as well. If we do the same for [inaudible] . Aha, currently not available.