How should you paginate a GraphQL list field?
Assesses fundamental understanding of GraphQL conventions, runtime behavior, and memory/performance considerations.
Hiring managers look for precision, avoidance of ambiguous jargon, and ability to explain trade-offs under real production conditions.
Two options:
- Offset/limit:
orders(offset: 40, limit: 20). Easy to implement but unstable when items are inserted or removed and slow at large offsets. - Cursor-based connections following the Relay spec:
orders(first: 20, after: "cursor")returningedges,node,cursorandpageInfowithhasNextPageandendCursor.
type OrderConnection {
edges: [OrderEdge!]!
pageInfo: PageInfo!
}
Cursors encode a stable, indexed sort key so pages do not skip or repeat items under concurrent writes. Always cap first and last to protect the server, make the connection a reusable pattern across fields, and document the sort order. Cursor pagination is more code but is the standard for feeds and anything that changes frequently.
Candidate Response Strategy & Interview Tips
- Start with a concise one-sentence summary: Deliver a direct, confident answer first before expanding into nuances.
- Demonstrate real-world trade-offs: Discuss where this approach excels and when you would avoid it in production systems.
- Discuss complexity & edge cases: Proactively explain time/space complexity or boundary conditions (null values, scale limits).
- Prepare for interviewer follow-ups: Technical hiring panels frequently probe deeper into concurrency, backward compatibility, or alternative libraries.