Storefront API pagination suddenly started throwing an error

Topic summary

Storefront API pagination began failing for collection product queries when requesting the next page with an “after” cursor, returning: “Invalid cursor for current pagination sort.”

Scope and triggers:

  • Occurred specifically when combining filters with the CREATED sort key (asc or desc). Without filters, pagination worked.
  • Reproduced across multiple stores; impacted “load more” functionality.

Details:

  • Initial page returned valid pageInfo (startCursor/endCursor), but using endCursor on the next request caused the error.
  • Example GraphQL queries/results were shared, showing the failing cursor-based pagination.

Workarounds/attempts:

  • One team resolved it locally by adjusting custom logic related to pagination and “new to old” behavior when filters were applied.
  • Others saw no reliable workaround and suspected a server-side issue. A request for an API health status was raised.

Current status:

  • Reports indicate the issue started recently and then began working again without code changes.
  • Shopify Plus support confirmed a fix was deployed “last night,” which appears to resolve the problem.

Resolution: Resolved by a Shopify-side fix; no remaining action items noted.

Summarized with AI on December 22. AI used: gpt-5.

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

2 Likes

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

1 Like

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

1 Like

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.

2 Likes

is it fixed?

1 Like

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

1 Like

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

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.

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

1 Like

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.

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

2 Likes