Pagination
The API supports pagination as long as the necessary fields are provided on each
request. Every list query accepts a page argument of type
PaginationInput and returns a PageInfo object alongside items.
Request
Each API endpoint that supports pagination will include a standard page object
where the page number and result set size (limit) can be passed:
input PaginationInput {
limit: Int! # number of items per page
page: Int # 0-based page number; page 0 returns the first page
}
page: { page: 0, limit: 10 }
In the provided example, records 1 to 10 would be returned as part of the response. Incrementing the page variable to 1 in the provided example would return records 11 to 20.
Response
Each API endpoint that supports pagination will include a standard pageInfo
object as part of the response. This object returns information on the total
result set size which can be helpful in determining how many API calls need to
be made to get the total result set. Provide the following pageInfo object as
part of the GraphQL request for the necessary fields to be returned in the
response:
pageInfo {
size
page
totalCount
hasNextPage
}
| Returned Object | Type | Description |
|---|---|---|
size | int | The size of the returned resultSet |
page | int | The page number of the returned resultSet based on the limit passed in the request |
totalCount | int | The total number of results in the requested resultSet regardless of pagination |
hasNextPage | bool | Denotes whether another page of results exist based off the page/limit passed as part of the request |
Example
Request pages until hasNextPage is false:
query Companies($page: Int!) {
listCompanies(page: {limit: 50, page: $page}) {
items {
id
name
}
pageInfo {
page
size
totalCount
hasNextPage
}
}
}
{
"data": {
"listCompanies": {
"items": [{"id": "co_123", "name": "Acme Foods"}],
"pageInfo": {"page": 0, "size": 50, "totalCount": 132, "hasNextPage": true}
}
}
}