Paginate Query Results
There are multiple ways to obtain pagination behavior, let’s take a look at a couple of them.Cursor based pagination
Cursors are used to traverse across entities of an entity set. They work by returning a pointer (“cursor”) to a specific entity which can then be used to fetch the next batch. The batch will start with the entity after the one the cursor points to. For cursor-based pagination, OpenReader follows the Relay Cursor Connections spec. Currently, only forward pagination is supported. If your use case requires bidirectional pagination please let us know at our Telegram channel. In SQD GraphQL server, cursor based pagination is implemented with{entityName}sConnection queries available for every entity in the input schema. These queries require an explicitly supplied orderBy argument, and the field that is used for ordering must also be requested by the query itself. Check out this section for a valid query template.
Example: this query fetches a list of videos where isExplicit is true and gets their count.
Operator first
The first operator is used to fetch a specified number of entities from the beginning of the output.
Example: Fetch the first 5 videos:
PageInfo object
PageInfo is a “virtual” entity that can be requested from any {entityName}sConnection query (see below). It returns the relevant cursors and some page information:
Operator after
Example: Fetch the first 10 channels, ordered by createdAt. Then, in a second query, fetch the next 10 channels:
Important Note on orderBy
The field chosen to orderBy needs to be present in the query itself. For example, any after query must follow this template:
Examples
An interactive example of using cursor-based pagination can be found in this repo.Paginating with {entityName}s queries
Arguments limit and offset
In a list of entities returned by a query, the limit argument specifies how many should be retained, while the offset argument specifies how many should be skipped first. Default values are 50 for limit and 0 for offset.

