Reliable way of querying sales orders

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?

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
                  }
                }
              }
            }
          }
        }
      }
    }

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.

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