Company
Date Published
Author
Dhaivat Pandya
Word count
1720
Language
English
Hacker News points
None

Summary

Persisted queries in Apollo Client allow clients to send only the ID of a query, rather than the entire query document, to the server. This reduces bandwidth usage and improves security by preventing malicious queries from being executed. The `persistgraphql` tool analyzes GraphQL documents at build time, creates a mapping between queries and IDs, and provides a network interface that can be used to send only the query ID to the server. The server receives the query ID and uses it to look up the corresponding query in the map data structure, sending back the actual query document as needed. By using persisted queries, clients can save bandwidth and improve security without sacrificing performance or developer experience.