Focusing on managing products, variants, and collections through the API.
I have implemented pagination as per https://shopify.dev/docs/api/usage/pagination-graphql but am finding an odd situation with backward pagination.
For testing, we're just displaying one product at a time from demo data on a development store. This backward pagination query (with no price filter) returns a product as expected:
query getCollectionById($id: ID!) { collection(id: $id) { products( last: 1, before: "eyJsYXN0X2lkIjo4NTQxNjYzMTMzOTc0LCJsYXN0X3ZhbHVlIjowfQ==", filters: { }) { edges { node { id title priceRange { minVariantPrice { amount } maxVariantPrice { amount } } compareAtPriceRange { minVariantPrice { amount } maxVariantPrice { amount } } } }, pageInfo { hasPreviousPage hasNextPage startCursor endCursor } }, } }
Result:
{ "data": { "collection": { "products": { "edges": [ { "node": { "id": "gid://shopify/Product/8541663166742", "title": "The Multi-managed Snowboard", "priceRange": { "minVariantPrice": { "amount": "629.95" }, "maxVariantPrice": { "amount": "629.95" } }, "compareAtPriceRange": { "minVariantPrice": { "amount": "0.0" }, "maxVariantPrice": { "amount": "0.0" } } } } ], "pageInfo": { "hasPreviousPage": true, "hasNextPage": true, "startCursor": "eyJsYXN0X2lkIjo4NTQxNjYzMTY2NzQyLCJsYXN0X3ZhbHVlIjowfQ==", "endCursor": "eyJsYXN0X2lkIjo4NTQxNjYzMTY2NzQyLCJsYXN0X3ZhbHVlIjowfQ==" } } } } }
The same query with a price filter applied returns no results, even though the price of the product shown above is within bounds of that price filter:
query getCollectionById($id: ID!) { collection(id: $id) { products( last: 1, before: "eyJsYXN0X2lkIjo4NTQxNjYzMTMzOTc0LCJsYXN0X3ZhbHVlIjowfQ==", filters: { price: { min: 0, max: 2000 } }) { edges { node { id title priceRange { minVariantPrice { amount } maxVariantPrice { amount } } compareAtPriceRange { minVariantPrice { amount } maxVariantPrice { amount } } } }, pageInfo { hasPreviousPage hasNextPage startCursor endCursor } }, } }
Returns:
{ "data": { "collection": { "products": { "edges": [], "pageInfo": { "hasPreviousPage": false, "hasNextPage": false, "startCursor": null, "endCursor": null } } } } }
Is this a bug, particularly given that the same does not happen for forward pagination?