-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge commit 'ae8398b4d46e4eeab35ecee5b4a60c87da597ede' into release/…
…v0.1.1 # Conflicts: # readme.txt
- Loading branch information
Showing
9 changed files
with
97 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,130 +1,3 @@ | ||
# Welcome | ||
|
||
Install the plugin in your WP environment. It is dependent on wp-grapqhl also being installed. | ||
|
||
Save a graphql query string for future use by an easy usable sha 256 hash or an alias name. | ||
|
||
## Saving Queries | ||
|
||
When submiting a query from your client, in the POST request provide a `queryId={value}` parameter with the submitted data. This `queryId` becomes the alias name of the saved query. It can then be used in future requests to invoke the query. | ||
|
||
Example POST data: | ||
|
||
``` | ||
{ | ||
"query": "{ | ||
posts { | ||
nodes { | ||
title | ||
} | ||
} | ||
}" | ||
"queryId": "query-get-posts-title" | ||
} | ||
``` | ||
|
||
After that successful POST request, you can use the GET request to invoke the query by queryId. | ||
|
||
docker run -v $PWD:/app composer install --optimize-autoloader | ||
|
||
``` | ||
https://domain.example/graphql?queryId=query-get-posts-title | ||
``` | ||
|
||
## What about graphql variables? | ||
|
||
Queries that require variables to execute the graphql query, will need the variables specified with each POST or GET request. The variables are not saved with the query string in the system. | ||
|
||
Here is an example of invoking a saved query and providing variables. | ||
|
||
If this is the saved query in the system, | ||
|
||
POST | ||
|
||
``` | ||
{ | ||
"query": "query ($count:Int) { | ||
posts(first:$count) { | ||
nodes { | ||
title | ||
} | ||
} | ||
}" | ||
"queryId": "query-get-posts-title" | ||
} | ||
``` | ||
|
||
The GET request would look like this to provide variables for the request, | ||
|
||
``` | ||
https://domain.example/graphql?queryId=query-get-posts-title&variables={"count":2} | ||
``` | ||
|
||
## What about queries with multiple operation names? | ||
|
||
Graphql query strings can contain multiple operations per string and an operation name is provided in the request to specify which query to invoke. The same is true for saved queries. | ||
|
||
Below is an example of a query string containing multiple operations that can be saved with queryId "multiple-query-get-posts". | ||
|
||
POST | ||
|
||
``` | ||
{ | ||
"query": " | ||
query GetPosts { | ||
posts { | ||
nodes{ | ||
id | ||
title | ||
} | ||
} | ||
} | ||
query GetPostsSlug { | ||
posts { | ||
nodes{ | ||
id | ||
title | ||
slug | ||
} | ||
} | ||
} | ||
", | ||
"queryId": "multiple-query-get-posts" | ||
} | ||
``` | ||
|
||
The GET request for the saved query specifying operation name looks like this, | ||
|
||
https://domain.example/graphql?queryId=multiple-query-get-posts&operationName=GetPostsSlug | ||
|
||
And if your query is multiple operations as well as variables, combine all of it together in your saved query and use the correct name/value parameters on the GET query requests. | ||
|
||
## Not Found Error | ||
|
||
If the queryId is not found in the system an error message will be returned in the response payload. A HTTP code of 200 is returned. | ||
|
||
``` | ||
{ | ||
"errors": [ | ||
{ | ||
"message": "Query Not Found get-post-with-slug", | ||
"extensions": { | ||
"category": "request" | ||
} | ||
} | ||
], | ||
} | ||
``` | ||
|
||
## Enable caching results | ||
|
||
Log into wp-admin for the WP service. | ||
|
||
Select the GraphQL Settings tab. | ||
|
||
![Settings tab](./docs/images/wp-graphql-settings.png). | ||
- | ||
Check the box to enable results caching. | ||
|
||
![The checkbox to enable the results cache](./docs/images/wp-graphql-smart-cache-settings-cache.png). | ||
# WP GraphQL Smart Cache - BETA USERS | ||
|
||
If you've been contacted to beta test this plugin, you can access the docs here: https://docs.google.com/document/d/16n2LxJB5POBkkWF6OIC9et1BogLMiRf6qZwL7ofBT5k/edit?usp=sharing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.