Paginated `orders` query sometimes returns duplicate results

We are building API integrations for customers who use ShipHero. One of our workflows uses the ordersquery to list orders with a given tag. Sometimes a tag can have a few hundred orders associated with it, so we have been using pagination with first/endCursor/after.

Sometimes, after grabbing all of the pages, our final result has a number of duplicated orders. The total number of results always seems to match the correct number of orders, but the ShipHero API is returning duplicates instead of the unique orders.

For example – if we are looking for orders tagged with tag-A and there are 333, then we will receive 333 orders after exhausting the paginated results, but some of the results will be duplicates and we do not get data for all 333 orders.

I assume that the issue is that the sorting of these rows is changing behind the scenes – however, there does not seem to be a way for us to specify a sort order to try to keep things stable. Is there a way to reliably get all order results from pagination, or is there always a risk that reading all of the pages will not actually return all of the results? Is there actually a way to reliably get all of the orders for a given tag?

For completeness, here is a basic example of the query we are using:

query {
  orders(tag: “tag-A”, updated_from: “2025-08-27”) {
    data(first: 100) {
      pageInfo {
        hasNextPage
        endCursor
      }
      edges {
        node {
          id
        }
      }
    }
  }
}

Our workaround has been to send the request with large limits (like 1000) but this causes issues with rate limits when the customer has other apps running.

Any suggestions for how we can solve this issue would be greatly appreciated. Our customers are not happy when we miss orders, and we are not sure how best to address this issue.

Hoping for some more info here. Has anyone figured out a workaround for this issue?

I’ve run into similar issues with the warehouse_products, picks_per_day, and packs_per_day queries. Sometimes they would have the duplicates issue you mentioned, and other times they’d just be missing some results. For me, I’ve found that specifying a sort usually does help. Which order fields have you tried sorting by that didn’t work? If you’re just trying to get everything, I would think any field that wouldn’t be changing on you behind the scenes would work best. Or maybe something that would be just about unique per order, like the order_number, order_date, or created_at fields.

@jeremyw I had completely missed that there was a “sort” parameter on the OrderConnection. I will try sorting by the order number and expect that will fix this issue.

Thank you so much for taking the time to respond to my post. You’ve saved me and our customers a lot of headache :slight_smile:

1 Like