Page Siblings Connection

Below is a connection that adds the ability to query page siblings (i.e. pages that share the same parent)

Fix pagination conflict with the “Advanced Taxonomy Terms Order” plugin

When using the Advanced Taxonomy Terms Order plugin along with WPGraphQL, you might experience some issues with paginated queries. This snippet should help correct the conflict: What this snippet does: First, this hooks into pre_get_terms which fires when WP_Term_Query is executing to get Terms out of the database. This checks to see if the request …

Deprecating a field in the Schema

Sometimes it can be helpful to deprecate a field in the Schema without removing it altogether. This snippet shows how to deprecate the `Post.excerpt` field. You can use this technique to deprecate other fields. After using this snippet, we can verify in the WPGraphQL Schema Docs that the field is indeed deprecated:

Allow login mutation to be public when the endpoint is fully restricted

If you’ve configured your WPGraphQL settings to “Limit the execution of GraphQL operations to authenticated requests”, this will block all root operations unless the user making the request is already authenticated. If you’re using a GraphQL mutation to authenticate, such as the one provided by WPGraphQL JWT Authentication, you might want to allow the login …

Query the Homepage

In WordPress, the homepage can be a Page or an archive of posts of the Post post_type (which is represented by WPGraphQL as a “ContentType” node). This query allows you to query the homepage, and specify what data you want in response if the homepage is a page, or if the homepage is a ContentType …

Make all Users Public

The following snippets allow for Users with no published content to be shown in public (non-authenticated) WPGraphQL query results. For a more detailed write-up, read the blog post: Allowing WPGraphQL to show unpublished authors in User Queries

Register a basic Mutation

This snippet shows how to register a basic GraphQL Mutation with a single input field, a single output field, and the input is simply returned as the value for the output.