Replacing the WP REST API
If your application is using the WP REST API, it is possible to use Gato GraphQL instead.
With the Persisted Queries extension you can publish REST-like endpoints, composed using GraphQL.
For each of the REST endpoints in your application, you can create a corresponding persisted query endpoint that retrieves the same data, and use that endpoint instead.
For instance, the following GraphQL query can replace REST endpoint /wp-json/wp/v2/posts/
:
Thanks to the API hierarchy, the persisted query be published under path /graphql-query/wp/v2/posts/
, making it easy to map endpoints.
To replicate REST endpoint /wp-json/wp/v2/posts/{id}/
, which retrieves data for the post with given ID, we can provide the post ID under URL param postId
.
For instance, the following persisted query can be invoked under endpoint /graphql-query/wp/v2/posts/single/?postId={id}
: