Create custom schemas, with custom access rules for different users, each available under its own endpoint.
A GraphQL server normally exposes a single endpoint for retrieving and posting data.
In addition to supporting the single endpoint, the GraphQL API also makes it possible to create custom endpoints, providing different schema configurations to deal with the needs from different targets, such as:
- Some specific client or user
- A group of users with more access to features (such as PRO users)
- One of the several applications, like mobile app or website
- 3rd-party APIs
- Any other
The custom endpoint is a Custom Post Type, and its permalink is the endpoint. An endpoint with title "My endpoint"
and slug my-endpoint
will be accessible under /graphql/my-endpoint/
.
Each custom endpoint has its own set of clients to interact with:
✅ A GraphiQL client, available under the endpoint + ?view=graphiql
(eg: /graphql/my-endpoint/?view=graphiql
).
Module GraphiQL for Custom Endpoints
must be enabled.
✅ An Interactive schema client, available under the endpoint + ?view=schema
(eg: /graphql/my-endpoint/?view=schema
).
Module Interactive Schema for Custom Endpoints
must be enabled.
Clicking on the Custom Endpoints link in the menu, it displays the list of all the created custom endpoints:
A custom endpoint is a custom post type (CPT). To create a new custom endpoint, click on button "Add New GraphQL endpoint", which will open the WordPress editor:
When the custom endpoint is ready, publish it, and its permalink becomes its endpoint URL. Links to the endpoint (and source and clients) are shown on the "Custom Endpoint Overview" sidebar panel:
Appending ?view=source
to the permalink, it will show the endpoint's configuration (as long as the user is logged-in and the user role has access to it):
By default, the custom endpoint has path /graphql/
, and this value is configurable through the Settings:
Defining what elements the schema contains, and what access will users have to it, is defined in the schema configuration.
So we must create a create a schema configuration, and then select it from the dropdown:
On the sidebar panel "Endpoint categories" we can add categories to help manage the Custom Endpoint:
For instance, we can create categories to manage endpoints by client, application, or any other required piece of information:
On the list of Custom Endpoints, we can visualize their categories and, clicking on any category link, or using the filter at the top, will only display all entries for that category:
These inputs in the body of the editor are shipped with the plugin (more inputs can be added by extensions):
Input | Description |
---|---|
Title | Custom endpoint's title |
Schema configuration | From the dropdown, select the schema configuration that applies to the custom endpoint, or one of these options:
|
Options | Select if the custom endpoint is enabled. It's useful to disable a custom endpoint it's a parent query in an API hierarchy |
GraphiQL | Enable/disable attaching a GraphiQL client to the endpoint, accessible under ?view=graphiql |
Interactive Schema | Enable/disable attaching an Interactive schema client to the endpoint, accessible under ?view=schema |
API Hierarchy | Use the same query as the parent custom endpoint. This section is enabled when the custom endpoint has a parent query (selected on the Document settings) |
These are the inputs in the Document settings:
Input | Description |
---|---|
Permalink | The endpoint under which the custom endpoint will be available |
Categories | Can categorize the custom endpoint. Eg: mobile , app , etc |
Excerpt | Provide a description for the custom endpoint. This input is available when module "Excerpt as Description" is enabled |
Page attributes | Select a parent custom endpoint. This input is available when module "API Hierarchy" is enabled |