/

Install and Activate

How to install and activate the WPGraphQL plugin


New to WordPress?If you're new to WordPress we recommend getting started by downloading and using Local

WPGraphQL WordPress Plugin

WPGraphQL is a free, open-source WordPress plugin that turns your WordPress site into a GraphQL API server.

Breaking Change Notice

Until WPGraphQL hits a v1.0.0, breaking changes to the Schema and underlying code should be expected.

This doesn't mean that the plugin is not ready for use in production (it's used in production on some big sites today), it just means that if you choose to use WPGraphQL, you should pay attention to releases in case breaking changes are introduced.

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.

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.

Install DirectoryTo minimize risk of unintended behavior, it’s best for your plugin directory to be "wp-graphql" and not something else, like "wp-graphql-master" or "wp-graphql-develop"

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.
Feel free to use any of the tools mentioned, explore and discover others that aren’t mentioned, or even build your own!

Just note that guides and documentation on this site will reference WPGraphiQL and GraphiQL.app and will also make use of inline instances of the GraphiQL React component to show examples.

Edit on GitHub

Install and Activate

  • WPGraphQL WordPress Plugin
  • Breaking Change Notice
  • Recommended Version
  • Github - Download / Clone Plugin
  • Composer
  • Activate the Plugin
  • Verify the Endpoint Works
  • GraphQL Tools and IDEs

Edit on GitHub

Discuss on Spectrum