Pagination
Many queries in the Cloudshelf API return a list of items, and these lists can be paginated.
Pagination is an important feature in any modern API as it allows the API to respond quickly with only a small subset of the data held instead of huge amounts.
When requests data, you can specify how many items you want to receive, and which page of the results you want to receive, this is handled by cursors.
When you receive data this will be in the form of a PaginatedPayload
object.
Requesting Data
#
All pagination fields in the GraphQL API are optional. If you do not specify a value, our default values will be used.
Where pagination is possible the following fields will always be present:
after
- The cursor of the item you want to offset from for forward paginationbefore
- The cursor of the item you want to offset from for backward paginationfirst
- The maximum number of items you want to receive in forwards paginationlast
- The maximum number of items you want to receive in backwards paginationsortBy
- A field to sort the results by in either ascending or descending order
Receiving Data
#
When you receive data from a paginated query, it will be in the form of a PaginatedPayload
object.
This object will contain the following fields:
edges
- An array ofEdge
objects.pageInfo
- APageInfo
objecttotalCount
- The total number of items available in the API
Edge Object
#
The Edge
object contains the following fields:
node
- The entity that was requestedcursor
- The cursor of the entity
PageInfo Object
#
The PageInfo
object contains the following fields:
hasNextPage
- Whether there is another page of results after this onehasPreviousPage
- Whether there is another page of results before this onestartCursor
- The cursor of the first item in the current pageendCursor
- The cursor of the last item in the current page
Global Ids
Upsert Pattern