⬡ 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.