Given a GraphQL query requesting the first 3 items after a cursor, what will be the returned edges' node IDs?
query {
items(first: 3, after: "cursor2") {
edges {
node {
id
}
}
}
}The after cursor means start after the item with that cursor.
The query asks for 3 items after cursor2, so it returns items with IDs 3, 4, and 5.
Choose the correct description of cursor-based pagination in GraphQL.
Think about how the cursor helps to continue fetching data.
Cursor-based pagination uses a unique cursor to mark the current position and fetches items after or before that cursor, unlike page number pagination.
Which option contains a syntax error in the pagination arguments?
query {
items(first: 5, after: "cursor123") {
edges {
node {
id
}
}
}
}Check how string values are passed in GraphQL arguments.
Cursor values must be strings and require quotes. Missing quotes cause a syntax error.
Which option best improves performance when paginating large datasets with cursors?
Think about how databases find rows quickly.
Indexing the column used as the cursor allows the database to quickly locate the starting point for pagination, improving performance.
A GraphQL query with cursor-based pagination returns some items twice when fetching pages. What is the likely cause?
query {
items(first: 2, after: "cursor5") {
edges {
node {
id
}
}
}
}
# The cursor is generated from the item's 'createdAt' timestamp.
# Some items have identical 'createdAt' values.Consider what happens if multiple items have the same cursor value.
If the cursor is not unique, items with the same cursor value can appear in multiple pages, causing duplicates.