Can't see certain shipped orders in query results

Hi, So there’s about 39 shipped orders we have that didn’t show up in some of the queries I’ve been using. An example is order # CS124070 (its shipment time on the portal shows as ‘11/27/2021 02:20 PM’).

My current way to query (check orders updated during a certain time frame) doesn’t show this order:

query {
  orders(fulfillment_status: "fulfilled" updated_from: "2021-11-25" updated_to: "2021-11-29") {
    request_id
    complexity
    data {
      edges {
        node {
          order_number
          partner_order_id
          shop_name
          fulfillment_status
          order_date
        }
      }
    }
  }
}

When the above didn’t work, I did more research, and found the method here, and used this query:

query {
  shipments(date_from: "2021-11-25", date_to: "2021-11-29") {
    request_id
    complexity
    data {
      edges {
        node {
          order{
            order_number
          }
          shipping_labels {
            tracking_number
            created_date
          }
        }
      }
    }
  }
}

But still that order doesn’t show up - what am I doing wrong? how can I ensure I can get all the shipped orders in the queried time frame?
Thank you

Hello @Raj!
I hope you are doing great!
Regarding your issue, do you know how pagination works?
You do not see that order/shipment because, in both cases, the query has more than 100 results, and by default, we return the first 100 for each node.
In this case, you have 2 options.

  1. You can query more than 100 by doing something like this. The value in the first clause inside data will let the system know you want that amount, but it can be very credit consuming and you might waste more credits than needed if you query for 200, but in the end, you have 150, but it might be helpful for some quick queries now and then:
query {
  shipments(date_from: "2021-11-25", date_to: "2021-11-29") {
    request_id
    complexity
    data (first: 200){
      edges {
        node {
          order{
            order_number
          }
          shipping_labels {
            tracking_number
            created_date
          }
        }
      }
    }
  }
}
  1. If you know how to paginate, you can use a query like this:
query {
  shipments(date_from: "2021-11-25", date_to: "2021-11-29") {
    request_id
    complexity
    data (first: 10 after "the value you get in endCursor"){
      edges {
        node {
          order{
            order_number
          }
          shipping_labels {
            tracking_number
            created_date
          }
        }
      }
      pageInfo{
        endCursor
        hasNextPage
      }
    }
  }
}

In this case, you query the first 10. In the response, you will find the value for endCursor. You can then use that value in the after parameter to query the next 10 after your last query, and you can advance 10 by 10 until you get to the last one. That is basically how pagination works.

  • Bare in mind, the first query of your pagination should have the after parameter empty as you still don’t know a value for it

  • You can do pagination using any number other than 10, I just used it as an example, but you could paginate one at a time or 100 at a time.

Please let me know if this doesn’t help.
Best regards,
TomasFD

Hello @tomasfd ! Yes, I’ve used pagination in one other query, but I’m used to APIs generally adding info about more pages in the returned data by default, so not seeing that it didn’t occur to me that might be the case here - maybe it’s a GraphQL thing, and I don’t have much experience with that yet.
But thank you so much for sorting that out, I should be able to fix my code now - much appreciated!

1 Like