⬡ GraphQL
Intermediate
What are the pagination strategies in GraphQL?
Answer
GraphQL supports two main pagination strategies. Offset-based (page/limit) pagination uses offset: 20, limit: 10 — simple to implement but problematic with live data (insertions cause items to shift, resulting in duplicates or skips). Cursor-based pagination uses an opaque cursor pointing to a specific item: first: 10, after: "cursor123". The Relay Connection spec formalizes this with edges, node, and pageInfo containing hasNextPage, hasPreviousPage, startCursor, and endCursor. Cursor-based is more stable for paginating frequently changing datasets like social media feeds or real-time lists.
Previous
What is the difference between schema-first and code-first GraphQL approaches?
Next
How is authentication handled in GraphQL?
More GraphQL Questions
View all →- Intermediate What is the N+1 problem in GraphQL and how does DataLoader solve it?
- Intermediate What are persisted queries in GraphQL?
- Intermediate What is the difference between schema-first and code-first GraphQL approaches?
- Intermediate How is authentication handled in GraphQL?
- Intermediate How do you implement field-level authorization in GraphQL?