0
0
GraphQLquery~20 mins

Relay specification compliance in GraphQL - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Relay Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
query_result
intermediate
2: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
    }
  }
}
A{ "data": { "node": { "id": "VXNlcjox", "name": "Alice" } } }
B{ "data": { "node": { "id": "1", "name": "Alice" } } }
C{ "data": { "node": null } }
D{ "errors": [{ "message": "Field 'node' does not exist" }] }
Attempts:
2 left
💡 Hint
Remember that Relay encodes the global ID as a base64 string combining type and ID.
🧠 Conceptual
intermediate
1: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?
AQueries must use fragments for all fields.
BEvery node must have a globally unique <code>id</code> field.
CAll connections must implement <code>edges</code> and <code>pageInfo</code> fields.
DMutations must return a <code>clientMutationId</code>.
Attempts:
2 left
💡 Hint
Think about how Relay handles lists and pagination.
📝 Syntax
advanced
2: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
}
Afragment NodeFragment on Node { id __type }
Bfragment NodeFragment on Node { id name }
Cfragment NodeFragment on Node { __id __typename }
Dfragment NodeFragment on Node { id __typename }
Attempts:
2 left
💡 Hint
Relay nodes always have an id and __typename.
optimization
advanced
2:30remaining
How to optimize Relay pagination queries to reduce overfetching?
Which approach best optimizes Relay pagination queries to avoid fetching unnecessary data?
AAlways fetch all edges without limits to avoid multiple queries.
BUse <code>first</code> or <code>last</code> arguments with a small number and request only needed fields in <code>edges.node</code>.
CInclude all possible fields in the <code>node</code> selection to prevent future queries.
DAvoid using <code>pageInfo</code> to reduce query size.
Attempts:
2 left
💡 Hint
Think about limiting data and selecting only what you need.
🔧 Debug
expert
3: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?
AThe <code>id</code> field is not a global ID encoded as base64.
BThe mutation response is missing <code>clientMutationId</code>.
CThe <code>user</code> field should be named <code>node</code>.
DThe response is missing the <code>edges</code> field.
Attempts:
2 left
💡 Hint
Relay expects global IDs in mutation responses.