Pagination
Stitch provides comprehensive pagination capabilities via GraphQL. Most items, such as bank accounts, transactions and debit orders, can be paginated.
The default page size for collections is 500, but should you want to fetch a specific subset of records, pagination can help you with this.
The information returned for a query result is computed as a Connection
, which is an object that contains Edges
and Nodes
.
- Connection: Contains metadata about the paginated field. This is mostly used in cursor-based pagination because it gives us extra info we use to perform the next query.
- Edges: Edges hold information about the parent and the child it contains. An edge connects two nodes, representing some kind of relationship between them. Each edge holds metadata about each object in the returned paginated result.
- Nodes: Individual objects held in the edges.
Cursor-Based Pagination
Each collection response can return a PageInfo
object that assists in cursor-based pagination. A cursor
is a unique identifier for an item within a list and is usually base64 encoded. The cursor represents a connection between
our data objects.
Variable | Type | Purpose |
---|---|---|
hasPreviousPage | boolean | Indicates if there are results in the connection before the current page |
hasNextPage | boolean | Indicates if there are results in the connection after the current page |
startCursor | string | Points to the cursor of the first node in the nodes list |
endCursor | string | Points to the cursor of the last node in the nodes list |
Forward Pagination
Forward pagination is achieved with the following connection variables:
Variable | Required | Type | Purpose |
---|---|---|---|
first | yes | integer | Number of results to return per page |
after | no | string | Cursor to retrieve nodes after, should ideally be the endCursor of the previous page |
The below example will fetch the first 10 payment request initiations, and also give a cursor object to indicate where the next page will begin.
So long as the value of hasNextPage
is true, then you can continue requesting more records from the API, with the next
page starting at the cursor value returned for endCursor
.
Backward Pagination
Backward pagination is achieved with the following connection variables:
Variable | Required | Type | Purpose |
---|---|---|---|
last | yes | integer | Number of results to return per page |
before | no | string | Cursor to retrieve nodes before, should ideally be the startCursor of the previous page |
The below example will fetch the last 100 payment initiations, and also give a cursor object to indicate where
the previous page will begin. The records will be ordered in reverse chronological order by the date
field,
meaning the latest node will be first in the list of edges.
So long as the value of hasPreviousPage
is true, then you can continue requesting more records from the API, with the next
page starting at the cursor value returned for startCursor
.
More Information
For further details on how to implement pagination for client requests, please refer to the GraphQl guide.