API pagination response contract (page info)

10005
0

For list endpoints, the frontend needs predictable pagination metadata, not just an array. I return items plus pageInfo (endCursor, hasNextPage) so building infinite scroll is straightforward and the API stays extensible if you later add totals (which can be expensive). I also make sort order implicit and stable (e.g. newest-first) so clients don’t accidentally depend on unstable ordering. One important rule: cursor tokens are opaque strings—clients should never parse them. This contract works well whether you’re doing REST or GraphQL-style responses, and it keeps pagination logic clean on both sides of the stack.