When creating a Shopify GraphQL query with the potential for multiple records to be returned, pagination should be part of the export step.
Where to Add Pagination
- Click into the export step/lookup.
- Scroll down to the section “Does this API use paging?”
- The sample provided is for an orders query, but the word “orders” would be replaced with whatever record is being queried.
- Select Paging Method = Next page token (cursor)
- Path to next page token field in HTTP response body = data.orders.pageInfo.endCursor
- Path to paging complete field in HTTP response body = data.orders.pageInfo.hasNextPage
- Paging complete values = false
Once Paging is Added, How to Add this to the query
Your query should resemble the below. The "after" statement will call the next page token if the current page does not return all records. The field “first” defines the number of records returned in the GraphQL call.
Example Query:
{
orders(
first: 5,
after: {{#if export.http.paging.token}}"{{export.http.paging.token}}"{{else}}null{{/if}},
query: "updated_at:>'{{{lastExportDateTime}}}'") {
nodes {
name
id
}
pageInfo {
endCursor
hasNextPage
hasPreviousPage
startCursor
}
}
}
How do I Test This?
Before adding paging, you can change your query to first: 1. Ensure you should be pulling more than one for the query you are trying to make as well. Without paging, the call should always only return one record.
Once paging is added, the call should return all records that meet the query criteria (or the number you select in the preview value).
Why is paging not working for my Shopify Connector export with a GraphQL query?
For Shopify connector GraphQL queries, you should instead use the below "after" statement.
after: `{{#if export.http.paging.token}}\"{{export.http.paging.token}}\"{{else}}null{{/if}}`