All our GraphQL queries that can return multiple results (e.g. products
) support pagination semantics. In all queries, the maximum number of expected results is required, with an optional object to start the count from.
We'll use the products
query as an example, as it is representative of how all queries are formatted:
products(first: Int!after: StringorderBy: ProductOrderBy): ProductConnection
These parameters are common to all "plural" queries:
Parameter | Description |
first | the maximum number of results to return (required) |
after | should be an identifier and, when provided, the results will start with the next node following the one identified by this id. Normally, this will be used in conjunction with the |
orderBy | defines the ordering of the results |
Plural queries always return a "connection" object. These objects always have the same general format with two fields:
Parameter | Description |
pageInfo | contains pagination information |
edges | contains the actual result nodes |
The edges
object is a collection of nodes. The node is the object returned by the query, i.e. a product
or a plan
.
The PageInfo
object contains pagination information for a result.
type PageInfo {startCursor: StringendCursor: StringhasNextPage: Boolean!hasPreviousPage: Boolean!}
Parameter | Description |
hasNextPage | indicates whether there are still results available after this page |
hasPreviousPage | indicates whether there are results available before this page |
startCursor | contains the identifier of the first node in this result |
endCursor | contains the identifier of the last node in this result |
When querying results, you can go through the several pages of results by mixing the PageInfo
results with the query parameters.
To get the next page in the results, repeat the query using the previous result's pageInfo->endCursor
as the after
parameter in the query.
To get the previous page in the results, repeat the query using the previous result's pageInfo->startCursor
as the after
parameter in the query and set orderBy
to DESC
.