Skip to main content

Pagination

products, orders and refunds return a page at a time. Each page has two fields:

FieldMeaning
nodesThe records on this page
nextCursorPass this as after to get the next page. null on the last page

Reading every page​

Ask for a page, then keep passing nextCursor back as after until it comes back null.

query Orders($from: DateTime!, $to: DateTime!, $after: String) {
site {
orders(from: $from, to: $to, first: 200, after: $after) {
nodes { id number total }
nextCursor
}
}
}
let after = null;
const orders = [];
do {
const { data } = await query(ORDERS, { from, to, after });
orders.push(...data.site.orders.nodes);
after = data.site.orders.nextCursor;
} while (after);

Page size​

first sets how many records come back. The default is 100 and the most you can ask for is 200.

Rules for cursors​

A cursor is an opaque string, so do not build or change one, and use it only with the same query and the same from and to it came from.

Orders and refunds come back oldest first, which means you can stop and resume at any point.