# Reliable way of querying sales orders

**URL:** <https://community.shiphero.com/t/reliable-way-of-querying-sales-orders/113>\
**Category:** GraphQL API\
**Created:** [September 6, 2019, 12:14pm UTC](https://community.shiphero.com/t/reliable-way-of-querying-sales-orders/113 "2019-09-06T12:14:59Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oleg](https://avatars.discourse-cdn.com/v4/letter/o/ebca7d/32.png) [@Oleg](https://community.shiphero.com/u/Oleg)\
**Post date:** [September 6, 2019, 12:14pm UTC](https://community.shiphero.com/t/reliable-way-of-querying-sales-orders/113/1 "2019-09-06T12:14:59Z")

</div>

Hello,

What’s the reliable way of pulling all sales orders since the last day? Is it even feasible with the GraphQL API when I don’t know how many line items order has.

If the doc you suggest to limit the number of line items to reduce consumed credits but then how can I guarantee that I’ve pulled everything?

---

<div class="post-metadata">

**Author:** ![tomasw](https://sea2.discourse-cdn.com/flex020/user_avatar/community.shiphero.com/tomasw/32/248_2.png) [@tomasw](https://community.shiphero.com/u/tomasw)\
**Post date:** [September 6, 2019, 12:55pm UTC](https://community.shiphero.com/t/reliable-way-of-querying-sales-orders/113/2 "2019-09-06T12:55:25Z")

</div>

Hello Oleg!,  
You could include `hasNextPage` on your Query under `pageInfo` field on the line items.  
This will allow you verify if more queries are needed to get the rest of the data.  
If you get a `hasNextPage: true`, this means you still have more line items on that order.

**For example:**

```
query {
  orders {
    request_id
    complexity
    data (first:10) {
          edges {
            node {
              id
              order_number
              line_items(first:10) {
                pageInfo{
                   hasNextPage
                   hasPreviousPage
                   startCursor
                   endCursor
                 }        
                edges {
                  node {
                    id
                    sku
                    quantity
                    product_name
                  }
                }
              }
            }
          }
        }
      }
    }
```

---

<div class="post-metadata">

**Author:** ![Oleg](https://avatars.discourse-cdn.com/v4/letter/o/ebca7d/32.png) [@Oleg](https://community.shiphero.com/u/Oleg)\
**Post date:** [September 6, 2019, 4:54pm UTC](https://community.shiphero.com/t/reliable-way-of-querying-sales-orders/113/3 "2019-09-06T16:54:58Z")

</div>

Thanks Tomas! Good to know.

Do you recommend setting the limit to 1 to minimize credits? If I query with line\_items(first:10) I’ll reach the limit after 1000 orders.

---

<div class="post-metadata">

**Author:** ![tomasw](https://sea2.discourse-cdn.com/flex020/user_avatar/community.shiphero.com/tomasw/32/248_2.png) [@tomasw](https://community.shiphero.com/u/tomasw)\
**Post date:** [September 6, 2019, 8:26pm UTC](https://community.shiphero.com/t/reliable-way-of-querying-sales-orders/113/4 "2019-09-06T20:26:42Z")

</div>

That’s an excellent observation! yes, definitely using `limit: 1` and adding `hasNextPage` is the best approach
