Challenge - 5 Problems
Relay Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ query_result
intermediate2:00remaining
What is the output of this Relay-compliant GraphQL query?
Given a GraphQL schema with a
Node interface and a User type implementing it, what will be the output of this query fetching a user by ID with Relay's node field?GraphQL
query {
node(id: "VXNlcjox") {
id
... on User {
name
}
}
}Attempts:
2 left
💡 Hint
Remember that Relay encodes the global ID as a base64 string combining type and ID.
✗ Incorrect
Relay uses a global ID encoded as base64 combining the type and the internal ID. Here, "VXNlcjox" decodes to "User:1", so the node field returns the user with id "VXNlcjox" and name "Alice".
🧠 Conceptual
intermediate1:30remaining
Which Relay specification rule ensures consistent pagination?
Which of the following Relay specification rules is responsible for consistent pagination behavior across different GraphQL connections?
Attempts:
2 left
💡 Hint
Think about how Relay handles lists and pagination.
✗ Incorrect
Relay requires connections to have
edges (list of items with cursors) and pageInfo (pagination info) fields to standardize pagination.📝 Syntax
advanced2:00remaining
Which GraphQL fragment correctly implements Relay's Node interface?
Select the fragment that correctly queries a Relay Node with its global ID and typename.
GraphQL
fragment NodeFragment on Node {
id
__typename
}Attempts:
2 left
💡 Hint
Relay nodes always have an
id and __typename.✗ Incorrect
The Relay Node interface requires the
id field and __typename to identify the type. Option D correctly includes both.❓ optimization
advanced2:30remaining
How to optimize Relay pagination queries to reduce overfetching?
Which approach best optimizes Relay pagination queries to avoid fetching unnecessary data?
Attempts:
2 left
💡 Hint
Think about limiting data and selecting only what you need.
✗ Incorrect
Using
first or last limits the number of items fetched, and selecting only necessary fields reduces data size, optimizing performance.🔧 Debug
expert3:00remaining
Why does this Relay mutation response cause a client error?
A Relay mutation returns this response:
{
"data": {
"updateUser": {
"user": {
"id": "1",
"name": "Bob"
}
}
}
}
Why does Relay client report an error?
Attempts:
2 left
💡 Hint
Relay expects global IDs in mutation responses.
✗ Incorrect
Relay requires all
id fields to be globally unique base64-encoded strings. Here, "1" is not encoded, causing client errors.