Q33: What are Automatic Persisted Queries (APQ)?

Difficulty:AdvancedTopic:Optimization

APQ optimizes network transfer and caching:

  1. Client sends a cryptographic hash (SHA-256) of the query instead of the full string.
  2. If the server recognizes the hash in its lookup cache, it executes the operation immediately.
  3. If unknown, the server responds with PersistedQueryNotFound, prompting the client to send the full query text once to register the hash.
Key Takeaways
  • APQ drastically reduces HTTP payload sizes by substituting query strings with cryptographic hashes.
  • It allows caching GraphQL queries via GET requests using hashed identifiers.
Knowledge Check

What is transmitted on the first attempt in an Automatic Persisted Query protocol?