Stellate Product Updates logo
Back to Homepage Subscribe to Updates

Product Updates

See the latest new features, improvements, and product updates

Labels

  • All Posts
  • Fix
  • Announcement
  • Improvement
  • graph api
  • feature

Jump to Month

  • March 2023
  • January 2023
  • September 2022
  • August 2022
  • May 2022
  • April 2022
  • March 2022
  • February 2022
  • January 2022
  • December 2021
  • November 2021
  • October 2021
  • September 2021
  • June 2021
  • May 2021
  • April 2021
  • March 2021
  • February 2021
Announcement
a year ago

Automatic Persisted Queries (APQ)

We recently shipped support for automatic persisted queries (or APQ for short), which can help drastically reduce the size of your GraphQL payloads sent from your clients to GraphCDN 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 -H "Content-Type: application/json" \
  -d '{"query": "{__typename}", "extensions": {"persistedQuery": {"version":1, "sha256Hash": "ecf4edb46db40b5132295c0291d62fb65d6759a9eedfa4d5d612dd5ec54a6b38"}}}' \
  https://spacex-api.graphcdn.app

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 -H "Content-Type: application/json" \
  -d '{"extensions": {"persistedQuery":{"version":1,"sha256Hash": "ecf4edb46db40b5132295c0291d62fb65d6759a9eedfa4d5d612dd5ec54a6b38"}}}' \
  https://spacex-api.graphcdn.app

This example uses a quite 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). And as with all our changes, we're always looking for your feedback. So let us know if you think we can improve support for APQs via support@graphcdn.io. 

Avatar of authorMarko Locher