Automatic Persisted Queries (APQ)

Stellate supports automatic persisted queries (or APQs for short), which can help drastically reduce the size of your GraphQL payloads sent from clients to Stellate edge locations.

Here is an example request using the { __typename } query. The initial request would look like the following curl command.

curl -g -X POST https://spacex-api.stellate.sh \
  -H "Content-Type: application/json" \
  -d '{
    "query": "{__typename}",
    "extensions": {
      "persistedQuery": {
        "version": 1,
        "sha256Hash": "ecf4edb46db40b5132295c0291d62fb65d6759a9eedfa4d5d612dd5ec54a6b38"
      }
    }
  }'

Subsequent requests for the same query would only need to use the hash of the operation, dropping the query key completely.

curl -g -X POST https://spacex-api.stellate.sh \
  -H "Content-Type: application/json" \
  -d '{
    "extensions": {
      "persistedQuery": {
        "version": 1,
        "sha256Hash": "ecf4edb46db40b5132295c0291d62fb65d6759a9eedfa4d5d612dd5ec54a6b38"
      }
    }
  }'

This example uses a very small query, which doesn't show the full impact APQs can have. However, keep in mind that the query can be of arbitrary length, whereas the sha256 hash will always have a constant length.

You can read more about Automatic Persisted Queries on the Apollo Documentation at https://www.apollographql.com/docs/apollo-server/performance/apq/ (among other pages).