A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
Hi There,
I've spent days trying to figure out an issue I'm having with the shopify api for nodeJS.
How can I use pagination when using the node client "Customer.search()" from here https://shopify.dev/api/admin-rest/2022-04/resources/customer#get-customers.
Here is what I'm using at the moment:
const customerDetails = await Customer.search({
session,
query: req.query.search ? req.query.search : null,
limit: 50,
// Nothing seems to work here to paginate, nor is there any documentation surrounding this feature on this specific client
});
The limit is only 250 customers and I need to be able to paginate through a few thousand.
Best,
Kane
Did you ever figure this out? I'm trying to get pagination to work as well. Not much from the docs...
Hello,
I'm having issues with this pagination too, I've made a nodejs and express app that can request products on an endpoint and wanted to perform the paginated request for the second page, but I can't manage the way client-side can tell my backend to request the next page
I've tried to make a GET request on the link given by the API from the headers but I've a CORS error
Does someone know anything ? The documentation is too general about pagination and there is no example
Take a look this doc https://shopify.dev/docs/api/usage/pagination-rest.
Below is an working example to fetch all inventory levels by location ids. But I think other pagination should be similar. Hope it still helps after one year. LOL
async getAllInventoryLevelsByLocationIds(locationIds: string[]):Promise<InventoryLevel[]> {
const session = this.getSession();
let result:InventoryLevel[] = [];
// Get the first page
let response = await this.shopify.rest.InventoryLevel.all({
session,
location_ids: locationIds.join(','),
limit: 250
});
result = result.concat(response.data);
// Get the following pages. Can NOT pass in location_ids to get next pages
let nextPageInfo = response.pageInfo?.nextPage?.query?.page_info;
while(nextPageInfo) {
response = await this.shopify.rest.InventoryLevel.all({
session,
limit: 250,
page_info: nextPageInfo,
});
result = result.concat(response.data);
nextPageInfo = response.pageInfo?.nextPage?.query?.page_info;
}
return result;
}