Pagination

As the number of links grow, listing all of them becomes less feasible. It stands to reason you should introduce the ability to only request a number of links and paginate through the result.

Like filtering, pagination can be achieved in any way that makes sense for the underlying storage.

In this tutorial, you’ll implement a simple pagination approach called limit-offset pagination (similar to what you may know from SQL). This approach does not work with Relay on the frontend, since Relay requires cursor-based pagination via the concept of connections. You can read more about pagination in the GraphQL docs. Connections, and the rest of the Relay specification, can be found in the Relay docs.

Predictably, you start off from the schema.

Note that the parameter type for both must be Number because graphql-java-tools will sometimes try to stuff an Integer and sometimes a BigInteger into it, depending on the context.

Wasn’t that easy? Jump back to GraphiQL and paginate away!

Jump back to GraphiQL and paginate away 1
Jump back to GraphiQL and paginate away 2

You can still, of course, get all links:

Jump back to GraphiQL and paginate away 3

Unlock the next chapter
Is pagination supported by GraphQL?
Yes, out of the box, via dedicated query arguments
The implementer can provide their own pagination scheme
Yes, but only if the Connection specification (part of the Relay spec) is supported
No