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.
Make all Users Public
The following snippets allow for Users with no published content to be shown in public (non-authenticated) WPGraphQL query results.
Showing Post Type labels in public queries
WPGraphQL respects WordPress core access control rights. This means that data that is only available to authenticated users in the WordPress admin is only available to authenticated users making GraphQL requests.
Making Menus and Menu Items public
By default, Menus and Menu Items that are not assigned to a Menu Location are considered private, meaning they are not exposed in non-authenticated WPGraphQL Queries.
If you want to expose Menus and Menu Items that are not assigned to menu locations to public GraphQL Queries, you can use the following snippet: