I'm missing edges in my orders query! Why?

So. You're working on a GraphQL query, involving orders, and you're seeing a response that looks like this:

{
  "data": {
    "orders": {
      "pageInfo": {
        "hasNextPage": true
      },
      "edges": []
    }
  }
}

Maddeningly, hasNextPage is true, but the set of "edges" is empty! Not only do you have no orders, but you have evidence of another page of orders existing, and no way to reach it without a cursor.

In every case we've seen, this happens when working on a store that has "Read all orders" disabled. Because you're only authorized to view the last 60 days of orders, Shopify's taking the orders that would otherwise appear in your set of edges, and has simply hidden them. The orders are there, but you can't see them. And you can't reach the next page of results, because you have no cursors.

To move forward, you have two options:

  1. If you're working on a bespoke task for a specific store, simply enable "Read all orders". (Read more about that here.)
  2. Or, for a more general solution, query for orders in an order that forces the newest ones (the ones you're most likely to be able to see) to come first. For example, you might use sortKey: CREATED_AT, reverse: true, as parameters for your orders connection.

If you've got more questions about this, use the support button in the corner. :)

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.