Queries

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 mutation to still be executable by public users, even if the rest of the API is restricted.

This snippet allows you to “allow” the login mutation when all other root operations are restricted.

View Recipe

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 node.

View Recipe

Filter to add restricted field on Model

Labels on Post Types are not publicly exposed by WordPress. They are attributes for use in the Admin, and are treated with respect to proper access to the admin.

View Recipe