0
0
GraphQLquery~20 mins

Persisted queries in GraphQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Persisted Queries Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2:00remaining
What is the result of executing a persisted query with a missing hash?

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?

AThe server ignores the hash and executes the query text sent by the client.
BThe server executes a default fallback query instead.
CThe server returns an error indicating the query was not found.
DThe server caches the new query under the given hash automatically.
Attempts:
2 left
💡 Hint

Think about what happens when the server cannot find a query matching the client's hash.

🧠 Conceptual
intermediate
2:00remaining
Why use persisted queries in GraphQL?

Which of the following is the main benefit of using persisted queries in GraphQL?

ATo reduce the size of requests by sending only query hashes instead of full query text.
BTo allow clients to send multiple queries in a single request.
CTo enable real-time subscriptions over WebSocket connections.
DTo automatically generate schema documentation.
Attempts:
2 left
💡 Hint

Think about network efficiency and bandwidth savings.

📝 Syntax
advanced
2:00remaining
Which option correctly shows how to register a persisted query in a GraphQL server?

Given a GraphQL server setup, which snippet correctly registers a persisted query with hash abc123 and query { user { id name } }?

ApersistedQueries.set('abc123', '{ user { id name } }');
BpersistedQueries.add('{ user { id name } }', 'abc123');
CpersistedQueries['abc123'] = '{ user { id name } }';
DpersistedQueries.register('{ user { id name } }', 'abc123');
Attempts:
2 left
💡 Hint

Consider common JavaScript Map methods for storing key-value pairs.

optimization
advanced
2:00remaining
How do persisted queries improve caching efficiency?

Which statement best explains how persisted queries help with caching on the server or CDN?

APersisted queries disable caching to ensure fresh data every time.
BPersisted queries compress the query text to reduce cache size.
CPersisted queries require clients to send full query text, improving cache hits.
DPersisted queries use fixed hashes, allowing caches to store and identify queries by hash instead of varying query text.
Attempts:
2 left
💡 Hint

Think about how identical keys help caches recognize repeated requests.

🔧 Debug
expert
2:00remaining
What error occurs if a client sends a persisted query hash but no query text and the hash is unknown?

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?

ATimeoutError because the server waits for query text indefinitely.
BPersistedQueryNotFound error indicating the hash is unknown.
CAuthenticationError because the client is unauthorized.
DSyntaxError due to missing query text.
Attempts:
2 left
💡 Hint

Consider the server's response when it cannot find the query for the given hash.