Q25: What are offset-based vs. cursor-based pagination in GraphQL?

Difficulty:IntermediateTopic:API Design
  • Offset-based: Uses limit and offset. Simple to write, but susceptible to missed/duplicate items when records are inserted or deleted during paging.
  • Cursor-based: Uses opaque pointers (cursors) pointing to specific items. Highly consistent, performs better on massive datasets, and is formalized by the Relay Cursor Connections Specification.
Key Takeaways
  • Cursor pagination avoids pagination drift during real-time data mutations.
  • Relay Connection pattern is the industry standard for cursor pagination in GraphQL.
Knowledge Check

Why is cursor pagination preferred over offset pagination for real-time feeds?