You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are using the following @shopify/[email protected] version. We are not able to fetch all productVariants from Shopify while using the pagination as mentioned in the dev-docs.
Expected behavior
What do you think should happen?
The endCursor should be different for each iteration. The hasNextPage should return false at some point while getting the productVariant pages using the graphql query.
Actual behavior
What actually happens?
The endCursor is returning same value for each iteration. The hasNextPage always returns true while getting the productVariant pages using the graphql query.
Steps to reproduce the problem
Query for getting the productVariants: query GetInventoryLevel($first: Int, $query: String, $quantities_name: [String!]!, $after: String, $location_id: ID!){ productVariants(first: $first, query: $query, after: $after, reverse: false) { edges{ cursor node{ id title displayName inventoryItem{ inventoryLevel(locationId: $location_id){ id quantities(names: $quantities_name){ name quantity } item{ id tracked } location{ id } } id locationsCount{ count } } } } pageInfo { hasPreviousPage hasNextPage startCursor endCursor } } }
In case of using while loop or recursive function to fetch all the productVariants using the above functions it runs infinitely because the endCursor value does not changes.
The following is the result of pageInfo object after the first graphql query call and the cursor values remains the same:
{
"hasPreviousPage": false,
"hasNextPage": true,
"startCursor": "eyJsYXN0X2lkIjo0OTQ5NjU0MzQ2MTY1NiwibGFzdF92YWx1ZSI6NDk0OTY1NDM0NjE2NTZ9",
"endCursor": "eyJsYXN0X2lkIjo0OTY3MzQyMzYxODMyOCwibGFzdF92YWx1ZSI6NDk2NzM0MjM2MTgzMjh9"
}
The text was updated successfully, but these errors were encountered:
Issue summary
Before opening this issue, I have:
@shopify/[email protected]
package and version:{ logger: { level: LogSeverity.Debug } }
in my configuration, when applicableWe are using the following @shopify/[email protected] version. We are not able to fetch all productVariants from Shopify while using the pagination as mentioned in the dev-docs.
Expected behavior
What do you think should happen?
The endCursor should be different for each iteration. The hasNextPage should return false at some point while getting the productVariant pages using the graphql query.
Actual behavior
What actually happens?
The endCursor is returning same value for each iteration. The hasNextPage always returns true while getting the productVariant pages using the graphql query.
Steps to reproduce the problem
Query for getting the productVariants:
query GetInventoryLevel($first: Int, $query: String, $quantities_name: [String!]!, $after: String, $location_id: ID!){ productVariants(first: $first, query: $query, after: $after, reverse: false) { edges{ cursor node{ id title displayName inventoryItem{ inventoryLevel(locationId: $location_id){ id quantities(names: $quantities_name){ name quantity } item{ id tracked } location{ id } } id locationsCount{ count } } } } pageInfo { hasPreviousPage hasNextPage startCursor endCursor } } }
Getting the result:
export const getVariantInventoryLevels = async (admin: any, variables: any) => { console.log( "==============GET VARIANT INVENTORY LEVELS==============", variables, ); const response = await admin.graphql(GET_VARIANT_INVENTORY_LEVELS, variables); const responseJson = await response.json(); return responseJson?.data; };
Calling the graphql API:
let response = await getVariantInventoryLevels(admin, { variables: { first: 2, query:
sku:${sku} location_id:${selectedLocation?.value?.split("/")?.pop()}, quantities_name: ["available"], after: null, location_id: selectedLocation?.value, } });
Debug logs
The text was updated successfully, but these errors were encountered: