Tutorial: Registering a Custom Post Type as a GraphQL Interface

WPGraphQL v1.12.0 introduces new options for customizing how Post Types and Taxonomies are exposed to the WPGraphQL Schema. The goal of this post is to show how to use some of these options in action. You can read this post for an overview of all the options, or check out the release.. To do that, …

Adding End 2 End Tests to WordPress plugins using wp-env and wp-scripts

I recently published a video walking through how End to End tests are set up for WPGraphQL, but I thought it would be good to publish a more direct step-to-step tutorial to help WordPress plugin developers set up End 2 End tests for their own WordPress plugins. Setting up End to End tests for WordPress …

Query any page by its path using WPGraphQL

One of the most common ways WordPress is used, is by users visiting a URL of a WordPress site and reading the content on the page. WordPress has internal mechanisms that take the url from the request, determine what type of entity the user is requesting (a page, a blog post, a taxonomy term archive, …

Building a Bookstore using WordPress, WPGraphQL and Atlas Content Modeler

In this post, we’ll look at how we can create a simple Book Store using WordPress, WPGraphQL and Atlas Content Modeler, a new plugin from WP Engine that allows Custom Post Types, Custom Taxonomies and Custom Fields to be created in the WordPress dashboard and allows the data to be accessed from WPGraphQL. By the …

Getting started with WPGraphQL and Gridsome

This is a guest post by @nicolaisimonsen Gridsome is a Vue.js framework for building static generated sites/apps. It’s performant, powerful, yet simple and really faaaaast. Gridsome can pull in data from all sorts of data-sources like CMSs, APIs, Markdown etc. It has a lot of features. Go check ’em out. Since GraphQL is so efficient …

Setting up a new developer environment to contribute to WPGraphQL..

I just announced that I am now employed by WP Engine to work on WPGraphQL. With new employment comes a new Macbook, which I need to setup as a dev machine to continue working on WPGraphQL. It’s always a tedious process to get a new computer setup to be an effective developer, so I thought …

Allowing WPGraphQL to show unpublished authors in User Queries

Objective The goal of this article is to make a non-authenticated GraphQL query for a User with no published content and to get the User returned in the response. Like the following: NOTE: To test these queries you will want to use a GraphQL client that is not Authenticated, such as GraphQL Playground or Altair. …

Query posts based on Advanced Custom Field values by Registering a Custom “where” Argument

If you manage custom fields in WordPress using Advanced Custom Fields, and you want to use WPGraphQL to get a list of posts filtering by the ACF field value, you’ll need to implement a few things in your themes functions.php. Summary: Register the new “where” argument: First you need to create a add_action on graphql_register_types …

Forward and Backward Pagination with WPGraphQL

WPGraphQL makes use of cursor-based pagination, inspired by the Relay specification for GraphQL Connections. If you’re not familiar with cursor-based pagination it can be confusing to understand and implement in your applications. In this post, we’ll compare cursor-based pagination to page-based pagination, and will look at how to implement forward and backward pagination in a …

Registering GraphQL Fields with Arguments

One of the most common ways to customize the WPGraphQL Schema is to register new fields. When registering fields, argument(s) can also be defined for the field. Field arguments in GraphQL allow input to be passed to the field, and when the field is resolved, the input of the field argument can be used to …