explaingit

wp-graphql/wp-graphql

3,778PHPAudience · developerComplexity · 3/5Setup · moderate

TLDR

A free WordPress plugin that adds a GraphQL API to your site, letting you build modern headless frontends with Next.js, Svelte, or Astro while keeping the familiar WordPress admin for content editors.

Mindmap

mindmap
  root((WPGraphQL))
    What it does
      Adds GraphQL API to WordPress
      Enables headless CMS setup
      Schema for all WordPress content
    Tech stack
      PHP plugin
      GraphiQL explorer
      REST alternative
    Use cases
      Next.js frontend
      Svelte or Astro site
      Custom field queries
    Extensions
      WPGraphQL for ACF
      Smart Cache plugin
    Audience
      Frontend developers
      WordPress developers
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

Things people build with this

USE CASE 1

Build a headless WordPress site using Next.js or Astro for the frontend while WordPress manages content in the background.

USE CASE 2

Query specific WordPress posts, pages, and custom fields in a single API request without over-fetching data.

USE CASE 3

Add network-level caching to WordPress content queries using the Smart Cache plugin extension.

USE CASE 4

Register custom fields and connections to the GraphQL schema using standard PHP functions.

Tech stack

PHPWordPressGraphQL

Getting it running

Difficulty · moderate Time to first run · 30min

Requires an existing WordPress installation, install the plugin from WordPress.org and the GraphQL API is immediately available.

In plain English

WPGraphQL is a free WordPress plugin that adds a GraphQL API to any WordPress site. GraphQL is a way of querying data where you describe exactly which fields you want and receive only those fields in a single response, rather than getting a fixed set of data from multiple separate requests. Installing this plugin exposes all of your WordPress content through that kind of API. This opens the door to building what is commonly called a headless WordPress setup: WordPress runs in the background managing content (posts, pages, users, menus, taxonomies, custom post types), while the front-end of the website is built with a separate framework of your choice. Next.js, Svelte, and Astro are mentioned as examples. The WordPress admin stays familiar for editors, but the public-facing site is built independently and fetches its data from WPGraphQL. The schema covers the full range of core WordPress data. Extension plugins expand it further: WPGraphQL for ACF adds support for Advanced Custom Fields, and WPGraphQL Smart Cache adds network-level caching and automatic cache invalidation so repeated queries do not hit the database each time. Developers can also register their own fields and connections to the schema using built-in WordPress-style PHP functions. The repository is organized as a monorepo containing the core plugin, the IDE extension, the Smart Cache plugin, and the ACF integration, along with the source for the wpgraphql.com documentation site. For anyone just installing the plugin, none of that structure matters: you install it from WordPress.org, activate it, and the API is immediately available. A built-in GraphiQL browser interface lets you explore and test queries directly from the WordPress admin panel. Documentation, a Discord community, and a live demo environment are all linked from the project website.

Copy-paste prompts

Prompt 1
I have a WordPress site with WPGraphQL installed. Write a Next.js page that fetches the latest 5 blog posts using GraphQL and displays their titles and excerpts.
Prompt 2
Show me how to write a WPGraphQL query that retrieves a post's title, featured image URL, and all its tags in one request.
Prompt 3
I'm using WPGraphQL with ACF (Advanced Custom Fields). Write a GraphQL query to fetch all posts with their custom field values.
Prompt 4
Help me register a custom field called 'reading_time' to the WPGraphQL Post type using PHP.
Prompt 5
Write a GraphQL query for WPGraphQL that fetches a navigation menu and its items to render in a headless frontend.
Open on GitHub → Explain another repo

← wp-graphql on gitmyhub — every repo by this author, as a profile.

Verify against the repo before relying on details.