Consider a GraphQL server that uses persisted queries identified by SHA-256 hashes. If a client sends a request with a hash that does not match any stored query, what will the server respond with?
Think about what happens when the server cannot find a query matching the client's hash.
Persisted queries rely on the server having the query stored under the given hash. If the hash is unknown, the server cannot execute the query and returns an error.
Which of the following is the main benefit of using persisted queries in GraphQL?
Think about network efficiency and bandwidth savings.
Persisted queries reduce request size by sending only a small hash instead of the full query text, improving performance especially on slow networks.
Given a GraphQL server setup, which snippet correctly registers a persisted query with hash abc123 and query { user { id name } }?
Consider common JavaScript Map methods for storing key-value pairs.
The set method is used to add a key-value pair to a Map object, where the key is the hash and the value is the query string.
Which statement best explains how persisted queries help with caching on the server or CDN?
Think about how identical keys help caches recognize repeated requests.
Using a fixed hash as a key means caches can easily identify repeated queries and serve cached responses, improving performance.
A client sends a GraphQL request with only a persisted query hash that the server does not recognize, and no query text. What error will the server produce?
Consider the server's response when it cannot find the query for the given hash.
The server returns a specific PersistedQueryNotFound error when the hash is unknown and no query text is provided to fallback on.