GraphQL cursor pagination is a method for paginating GraphQL APIs.
Here, we send a GraphQL query requesting a list of items. This query includes parameters such as the number of items to fetch and any filtering or sorting criteria required. In response, requested items are received, together with cursor information (each item in the response is associated with a cursor, which is typically a unique identifier for that item).
The GraphQL cursor pagination method was developed for the Shopify GraphQL API however, the same principles apply for other GraphQL systems.
Option | Summary |
---|---|
The GraphQL cursor pagination method works in conjunction with a query on the endpoint body, which determines required settings. For example:
If you need to change the existing query for an endpoint, you should edit the connector and access body options for the required endpoint.
Pagination continues until hasNextPage
is returned as false
.
EndCursor path
Always defined in the following form:
data.
{type}
.pageInfo.endCursor
Here, the {type}
element should be replaced with the type that's defined by the schema - for example:
data.products.pageInfo.endCursor
HasNextPage path
Always defined in the following form:
data.
{type}
.pageInfo.hasNextPage
Here, the {type}
element should be replaced with the type that's defined by the schema - for example:
data.products.pageInfo.hasNextPage