Install and Activate
How to install and activate the WPGraphQL plugin
WPGraphQL WordPress Plugin
WPGraphQL is a free, open-source WordPress plugin that turns your WordPress site into a GraphQL API server.
Breaking Change Notice
Don’t hesitate to start using the plugin, but just be sure to follow along with releases and keep up to date with conversations in Slack join here
WPGraphQL is already in use in production on several sites, including work.qz.com, hopelabs.org and more.
Recommended Version
For the most stable and performant experience, it’s recommended that you use the most recent version of the plugin. You can see the latest releases here.
Of course, as new features are in development, feel free to check out the latest develop branch or check out any other feature or release.
Github - Download / Clone Plugin
WPGraphQL is available on Github: https://github.com/wp-graphql/wp-graphql
You can download the plugin or clone the plugin from Github.
Add the downloaded/cloned plugin to your WordPress plugin directory. On a typical WordPress install,
this is located at /wp-content/plugins
.
Composer
WPGraphQL is also available as a composer package on Packagist.
composer require wp-graphql/wp-graphql
Activate the Plugin
Once the plugin is in the WordPress plugins directory, it can be activated by clicking “Activate” on
the plugin screen, or via WP CLI wp plugin activate wp-graphql
Verify the Endpoint Works
The most common use of WPGraphQL is as an API endpoint that can be accessed via HTTP requests (although it can be used without remote HTTP requests as well)
In order for the /graphql
endpoint to work, you must have pretty permalinks enabled and any permalink structure other than the default WordPress permalink structure. In addition, if your site url and wordpress address url don't match, the graphql endpoint will be available at the wordpress address url. These settings can be checked at /wp-admin/options-general.php
For instance:
- Site Address -
http://localhost
- Wordpress Address -
http://localhost/wordpress
- graphql endpoint -
http://localhost/wordpress/graphql
Once the plugin is active, your site should have a example.com/graphql
endpoint and you the
expected response is a JSON payload like so:
{
"errors": [
{
"message": "GraphQL Request must include at least one of those two parameters: \"query\" or \"queryId\"",
"category": "request"
}
]
}
GraphQL Tools and IDEs
One benefit of GraphQL is that it enables powerful developer tooling.
Throughout the documentation, we will use an embedded GraphiQL IDE to showcase how to use GraphQL against a live WPGraphQL API.
There are many GraphQL IDE tools in the wild, such as:
- Firecamp - The fastest GraphQL IDE for the team ever.
- GraphiQL - A React Component that serves as an in-browser IDE for exploring GraphQL.
- WPGraphiQL – GraphQL IDE right in your WordPress dashboard
- GraphQL Playground – GraphQL IDE that supports multi-column schema docs, tabs, query history, configuration of HTTP headers and GraphQL Subscriptions.
- GraphiQL.app – A light, Electron-based wrapper around GraphiQL
- GraphQL Network – A chrome dev-tools extension for debugging GraphQL network requests.
- GraphQL IDE – An extensive IDE for exploring GraphQL API’s
- Altair GraphQL Client – A beautiful feature-rich GraphQL Client for all platforms
- Insomnia – An full-featured API client with first-party GraphQL query editor
- Postman - Create and execute any REST, SOAP, and GraphQL queries from the within Postman API client.