Automatic Persisted Queries
The absence of Automatic Persisted Queries can cause backend performance problems at scale.
GraphQL clients send queries to Apollo Servers as HTTP requests, including the GraphQL query string. Depending on your GraphQL schema, the size of a valid query string might be arbitrarily large. As query strings become larger, increased latency and network usage can noticeably degrade client performance. A persisted query is a query string cached on the server-side, along with its unique identifier (SHA-256 hash of the query). Clients can send this identifier instead of the full query string, drastically reducing request sizes.
To make a query string persist, your GraphQL server must first receive it from a requesting client. Each unique query string must therefore be sent to the server at least once. Once a client has sent a query string to persist, any other client executing that query can benefit from APQ.
To improve network performance for large query strings, enable APQ if your GraphQL server supports it.
Enable Automatic Persisted queries. For a complete guide on how to do so, see Apollo's Automatic Persisted Queries documentation.
For a complete guide on the matter, see dgraph's Persisted Queries documentation.
Enable Automatic persisted Queries For a complete guide on how to do so, see gqlgen's Automatic Persisted Queries documentation.
Add graphql-persisted_queries to your Gemfile
gem 'graphql-persisted_queries' and add the plugin to your schema class:
class GraphqlSchema < GraphQL::Schema
:extensions argument as part of a context to all calls of
usually it happens in
GraphqlChannel and tests:
Ignore this check
- Escape Severity: LOW
- OWASP: API8:2023
- PCI DSS: 6.5.8
- WASC: WASC-10
- CVSS_VECTOR: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:N/A:L/E:F/RL:O/RC:C
- CVSS_SCORE: 4.9