Re: Storefront API pagination suddenly started throwing an error

Storefront API pagination suddenly started throwing an error

Jordaninkmonkey
Shopify Partner
7 0 7

***Edit***

The problem seems to have solved itself. I assume it was a temporary issue with the graphql server

****

 

When requesting a collection and it's products from the storefront API, The first query is successful and will return the correct results, but when I request the second page (first N products after end cursor), this error is returned: "message": "Invalid cursor for current pagination sort."

Here is an example of an initial query and result:

 

 

 

 

query CollectionByHandle($handle: String!) {
  collectionByHandle(handle: $handle) {
    handle
    id
    products(first: 3, filters: {productType: "Vinyl Decal"}) {
      pageInfo {
        endCursor
        hasNextPage
        hasPreviousPage
        startCursor
      }
      edges {
        node {
          id
          handle
          availableForSale
          title
        }
      }
    }
  }
}

 

 

 

 

 

and the initial result:

 

 

 

 

{
  "data": {
    "collectionByHandle": {
      "handle": "outdoors",
      "id": "gid://shopify/Collection/471395467548",
      "products": {
        "pageInfo": {
          "endCursor": "eyJsYXN0X3ZhbHVlIjoiMiIsImxhc3RfaWQiOjkzOTUxNDk0MzkyNjB9",
          "hasNextPage": true,
          "hasPreviousPage": false,
          "startCursor": "eyJsYXN0X3ZhbHVlIjoiMCIsImxhc3RfaWQiOjkzMzQ3NTkyMjc2NzZ9"
        },
        "edges": [
          {
            "node": {
              "id": "gid://shopify/Product/9334759227676",
              "handle": "trippy-magic-skull-decal",
              "availableForSale": true,
              "title": "Trippy Magic Skull - Decal - Customizable"
            }
          },
          {
            "node": {
              "id": "gid://shopify/Product/9395147145500",
              "handle": "bird-flowers-decal",
              "availableForSale": true,
              "title": "Bird & Flowers - Decal"
            }
          },
          {
            "node": {
              "id": "gid://shopify/Product/9395149439260",
              "handle": "graphite-flower-decal",
              "availableForSale": true,
              "title": "Graphite Flower - Decal"
            }
          }
        ]
      }
    }
  }
}

 

 

 

 

 

But, if I then request the next page:

 

 

 

 

query CollectionByHandle($handle: String!) {
  collectionByHandle(handle: $handle) {
    handle
    id
    products(
      first: 3
      filters: {productType: "Vinyl Decal"}
      after: "eyJsYXN0X3ZhbHVlIjoiMiIsImxhc3RfaWQiOjkzOTUxNDk0MzkyNjB9"
    ) {
      pageInfo {
        endCursor
        hasNextPage
        hasPreviousPage
        startCursor
      }
      edges {
        node {
          id
          handle
          availableForSale
          title
        }
      }
    }
  }
}

 

 

 

 

 This I receive this error:

 

 

 

 

{
  "data": {
    "collectionByHandle": null
  },
  "errors": [
    {
      "message": "Invalid cursor for current pagination sort.",
      "locations": [
        {
          "line": 5,
          "column": 5
        }
      ],
      "path": [
        "collectionByHandle",
        "products"
      ]
    }
  ]
}

 

 

 

 

It was all behaving as expected when I last used it 2 days ago, and as of this morning, this error has started to appear. I may be missing something, and if I have left out any info I can try to provide it. Any insight would be appreciated, thanks

 

 

Replies 10 (10)

Pp13
Shopify Partner
1 0 1

I'm having the same issue on collection query, and it seems like the issue only happened to CREATED product sort key

Jordaninkmonkey
Shopify Partner
7 0 7

Yeah, I edited my post too soon. I queried by product type, which worked, and I mistook it for a collection query which is still returning an error with the CREATED sort key

rustic-tables
Visitor
2 0 2

Did anything come of this? We are having the issues with the 'load more' button not pulling more products. It works fine if the filters are not used, is this the same issue you are having, or is it different? We believe the issue is related to the shopify storefront API and we are getting the error message, "Invalid cursor for current pagination sort." when using filters in a product query.

Zolbooo17
Visitor
1 0 1

is it fixed?

Jordaninkmonkey
Shopify Partner
7 0 7

Yes, that is the same issue I'm experiencing. I haven't found a fix for it.

rustic-tables
Visitor
2 0 2

We did get it fixed on our end - we had some custom logic in there to have the second page on down load by new to old when filters were applied. 

mcanaleta
Shopify Partner
4 0 0

Same issue in our store. Only happen when applying at the same time sort by CREATED (asc or desc) and any filter.

blucksy
Shopify Partner
2 0 2

The issue is happening for one of my stores as well, preventing basic functionality.  @Shopify do you have an API health status monitor?

Jordaninkmonkey
Shopify Partner
7 0 7

It seems to be working as expected now for us. Nothing changed on our end otherwise, so I guess it's fixed for the time being.

stage32
Tourist
3 0 4

I contacted Shopify Plus support. They pushed out a fix for this last night which appears to have resolved the issue