In our pursuit of delivering best in class performance for GraphQL APIs deployed at the edge, we just added support for Automatic Persisted Queries.
Instead of sending the query document repeatedly:
{
"query": "query { __typename }"
}
you can persist it for later use by hashing the contents:
{
"query": "query { __typename }",
"extensions": {
"persistedQuery": {
"version": 1,
"sha256Hash": "4ef8d269e7944ef2cd6554ecb3d73164546945cf935806933448905abec554e5"
}
}
}
The next time you want to execute the same query, you can omit the query field and pass the hash instead:
{
"extensions": {
"persistedQuery": {
"version": 1,
"sha256Hash": "4ef8d269e7944ef2cd6554ecb3d73164546945cf935806933448905abec554e5"
}
}
}
To benefit the most from our Edge Caching feature, you can also send HTTP GET requests instead of POST requests to cache responses using the Grafbase Global Edge Network:
# With the query document
curl --get 'https://api.grafbase.com/graphql' \
--data-urlencode 'query=query { __typename }' \
--data-urlencode 'extensions={"persistedQuery":{"version":1,"sha256Hash":"4ef8d269e7944ef2cd6554ecb3d73164546945cf935806933448905abec554e5"}}'
# Without the query document
curl --get 'https://api.grafbase.com/graphql' \
--data-urlencode 'extensions={"persistedQuery":{"version":1,"sha256Hash":"4ef8d269e7944ef2cd6554ecb3d73164546945cf935806933448905abec554e5"}}'