Skip to content
Advertisement

Graphql error: “using last without before is not supported”

I am using Gatsby + GraphQL + Shopify. I am having an issue retrieving my orders by the last 10.

My query looks like this:

query {
   customer(customerAccessToken: "${customerAccessToken}") {
      orders(last: 10) {...}
   }
}

And it returns this:

“message”: “using last without before is not supported”

I noticed this issue happening to some other devs: https://community.shopify.com/c/Shopify-Discussion/How-to-get-customer-s-orders-and-sort-by-date-in-descending/m-p/629133/highlight/false#M151241

If you check the docs it says nothing about using before with last: https://shopify.dev/docs/admin-api/graphql/reference/object/order?api[version]=2020-07

There is a playground at the bottom where you can test queries.

Anybody else has seen this issue before?

Advertisement

Answer

After a few moments of playing with the playground … you can use a workaroundreverse and first

{
  orders(first: 10, reverse:true) {
    edges {
      node {
        id
        createdAt
      }
    }
  }
}
User contributions licensed under: CC BY-SA
3 People found this is helpful
Advertisement