Jump into concepts and practice - no test required
or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Recall & Review
beginner
What is the purpose of the Relay specification in GraphQL?
The Relay specification defines a standard way to structure GraphQL schemas and queries to support efficient pagination, caching, and data fetching in client applications.
Click to reveal answer
beginner
What are the two main connection types defined by the Relay specification?
The Relay specification defines Connection and Edge types to represent lists of data with pagination support.
Click to reveal answer
intermediate
Explain the role of the pageInfo field in Relay-compliant GraphQL queries.
The pageInfo field provides information about the current page of results, such as whether there are more pages available before or after the current set.
Click to reveal answer
intermediate
What arguments are commonly used in Relay connections to support pagination?
Relay connections commonly use first, last, before, and after arguments to paginate forward or backward through a list.
Click to reveal answer
intermediate
Why does Relay require nodes in connections to have a globally unique id field?
Relay requires a globally unique id so clients can reliably cache and refetch individual objects across the app.
Click to reveal answer
Which type does the Relay specification use to represent a list of items with pagination?
AConnection
BArray
CObject
DScalar
✗ Incorrect
Relay uses the Connection type to represent paginated lists.
What does the pageInfo field NOT provide in Relay pagination?
AHas next page
BTotal count of items
CStart cursor
DHas previous page
✗ Incorrect
pageInfo does not provide total count; it provides cursors and page availability info.
Which argument is used to fetch the first N items in a Relay connection?
Aafter
Bbefore
Clast
Dfirst
✗ Incorrect
The first argument fetches the first N items.
In Relay, what is the purpose of the Edge type?
ATo represent a single node with a cursor
BTo represent the entire list
CTo store metadata about the query
DTo define the schema
✗ Incorrect
Edge wraps a node and includes a cursor for pagination.
Why must Relay nodes have a globally unique id?
ATo improve query speed
BTo reduce server load
CTo allow clients to cache and refetch objects reliably
DTo encrypt data
✗ Incorrect
Unique IDs help clients identify and cache objects consistently.
Describe the Relay specification's approach to pagination in GraphQL.
Think about how Relay structures lists and controls which items are fetched.
You got /4 concepts.
Explain why globally unique IDs are important in Relay-compliant GraphQL schemas.
Consider how clients keep track of data objects.
You got /4 concepts.
Practice
(1/5)
1. What is the main purpose of the edges field in a Relay-compliant GraphQL connection?
easy
A. To store metadata about the entire list
B. To hold the list of items along with their cursors for pagination
C. To define the total count of items in the list
D. To specify the GraphQL schema version
Solution
Step 1: Understand Relay connection structure
Relay connections use edges to represent each item with its cursor for pagination.
Step 2: Identify the role of edges
The edges field contains nodes (items) and cursors, enabling smooth pagination.
Final Answer:
To hold the list of items along with their cursors for pagination -> Option B
Quick Check:
edges = items + cursors [OK]
Hint: Edges always pair items with cursors for pagination [OK]
Common Mistakes:
Confusing edges with pageInfo
Thinking edges store only items without cursors
Mixing edges with totalCount field
2. Which of the following is the correct syntax to request the first 5 items in a Relay connection named users?
easy
A. { users(first: 5) { edges { node { id } } } }
B. { users(limit: 5) { edges { node { id } } } }
C. { users(count: 5) { edges { node { id } } } }
D. { users(take: 5) { edges { node { id } } } }
Solution
Step 1: Recall Relay pagination argument
Relay uses first to specify how many items to fetch from the start.
Step 2: Check syntax correctness
Only first: 5 is valid; limit, count, and take are not Relay standard arguments.
Final Answer:
{ users(first: 5) { edges { node { id } } } } -> Option A
Quick Check:
Use first for Relay pagination [OK]
Hint: Use 'first' to fetch initial items in Relay queries [OK]
Common Mistakes:
Using non-Relay arguments like limit or count
Omitting edges or node fields
Confusing Relay with REST query parameters
3. Given this GraphQL query on a Relay connection:
D. There are more posts available after the current 2
Solution
Step 1: Understand pageInfo.hasNextPage
This field tells if more items exist beyond the current page.
Step 2: Interpret the returned value
The value true means more posts exist after the fetched two.
Final Answer:
There are more posts available after the current 2 -> Option D
Quick Check:
hasNextPage = true means more data [OK]
Hint: True hasNextPage means more items exist [OK]
Common Mistakes:
Assuming true means no more data
Confusing hasNextPage with hasPreviousPage
Ignoring pageInfo in Relay connections
4. You wrote this Relay connection query:
{ comments(last: 3) { edges { node { text } } } }
But the server returns an error:
"Field 'last' is not supported on this connection"
What is the likely cause?
medium
A. The connection does not support backward pagination with 'last'
B. The 'last' argument must be replaced with 'first'
C. The query is missing the 'before' cursor argument
D. The 'edges' field is misspelled
Solution
Step 1: Understand Relay pagination directions
Relay supports forward pagination with first and backward with last.
Step 2: Identify server limitation
Some connections only support forward pagination; thus, last is unsupported.
Final Answer:
The connection does not support backward pagination with 'last' -> Option A
Quick Check:
Unsupported 'last' means no backward pagination [OK]
Hint: Check if connection supports 'last' for backward pagination [OK]
Common Mistakes:
Replacing 'last' with 'first' without cursor
Assuming 'edges' spelling causes error
Ignoring need for 'before' cursor with 'last'
5. You want to fetch a paginated list of products using Relay spec. You need to get the first 3 products, then fetch the next 3 after the last cursor. Which sequence of queries correctly follows Relay pagination?