# GraphQL cursor pagination method

## Overview

GraphQL cursor pagination is a method for paginating GraphQL APIs. In this context, a 'cursor' is a pointer that represents a specific position in the data set. Instead of saying *"return page 3"*, you say *"return 10 items after this cursor"*.

{% hint style="info" %}
You can find more information about how this pagination method works in [Shopify's API documentation](https://shopify.dev/docs/api/usage/pagination-graphql).&#x20;
{% endhint %}

{% hint style="info" %}
The GraphQL cursor pagination method was developed for the [Shopify GraphQL API](https://shopify.dev/docs/api/usage/pagination-graphql); however, the same principles apply to other GraphQL systems.
{% endhint %}

## GraphQL cursor options

<table><thead><tr><th width="284">Option</th><th>Summary</th></tr></thead><tbody><tr><td>EndCursor path</td><td><p>The expected location of the pointer (i.e. the <em>cursor</em>) for the last item returned in the current page of results. When the next page is requested, the <code>EndCursor</code> is passed as the <code>after</code> argument, telling Shopify to start fetching from this point.  </p><p></p><p>The <code>EndCursor path</code> is always defined in the following form:<br><br><code>data.</code><mark style="color:red;"><code>{type}</code></mark><code>.pageInfo.endCursor</code><br><br>Here, the <code>{type}</code> element should be replaced with the type  that's defined by the schema - for example: </p><p></p><p><code>data.products.pageInfo.endCursor</code></p></td></tr><tr><td>HasNextPage path</td><td><p>The expected location of the <code>HasNextpage</code> indicator. This is a boolean flag, indicating whether more pages exist after the current batch. If  <code>HasNextPage</code> is <code>false</code>, then you’ve reached the end of the list, and no further requests are made.</p><p></p><p>The <code>HasNextPage</code>  path is always defined in the following form:</p><p></p><p><code>data.</code><mark style="color:red;"><code>{type}</code></mark><code>.pageInfo.hasNextPage</code><br><br>Here, the <code>{type}</code> element should be replaced with the type  that's defined by the schema - for example: </p><p></p><p><code>data.products.pageInfo.hasNextPage</code></p><p></p></td></tr></tbody></table>

## GraphQL cursor pagination - endpoint body requirements

The GraphQL cursor pagination method works in conjunction with a query on the endpoint body, which determines required settings. For example:

{% code overflow="wrap" %}

```graphql
{"query":"{products(first: 250, {{pagination_cursor}}) {edges { node { id title } } pageInfo { hasNextPage startCursor endCursor }}}","variables":{}}
```

{% endcode %}

If you need to change the existing query for an endpoint, you should [edit the connector ](https://doc.wearepatchworks.com/product-documentation/connectors-and-instances/working-with-connectors/updating-a-connector)and access [body options](https://doc.wearepatchworks.com/product-documentation/developer-hub/connector-builder/building-your-own-connector/4-endpoints/endpoint-options/body) for the required endpoint. &#x20;

## When does pagination stop?

Pagination continues until `hasNextPage`  is returned as `false`.
