Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 422
Non Avatar asked Jul 06 '20 22:07

Non


1 Answers

After a few moments of playing with the playground ... you can use a workaround - reverse and first

{
  orders(first: 10, reverse:true) {
    edges {
      node {
        id
        createdAt
      }
    }
  }
}
like image 124
xadm Avatar answered Oct 13 '22 00:10

xadm