How to use updated_at in Orders-line_items

Hi Folks, @sh-agent

I have a requirement to pull recently updated line_items data from Orders API, I see that we have field-updated_at in line_items data set, however I’m not able to use that in the query.

Please suggest, how can I use updated_at to get last updated based on 5Mins ,10Mins etc. time frames?

Note : order_number value is a dummy value.

Below is the query I’m using.
query {
orders(order_number: “#333”){
request_id
complexity
data(first: 10) {
edges {
node {
id
legacy_id
order_number
shop_name
fulfillment_status
order_date
line_items {
edges {
node{
id
sku
quantity
price
product_name
fulfillment_status
updated_at
}
cursor
}
pageInfo {
hasNextPage
}
}
}
cursor
}
}
}
}

Hey @nareshbiyyam,

Thanks for reaching out and Welcome to our Developer Community!

I don’t believe you’ll be able to filter by line items updated when using the orders query. You can filter by order updated however. If you wanted to get the orders updated within the past 10 minutes, the query would look something like this:

query {
  orders(updated_from: "2023-04-21 19:20", updated_to: "2023-04-21 19:30") {
    request_id
    complexity
    data(first: 10) {
      edges {
        node {
          id
          legacy_id
          order_number
          shop_name
          fulfillment_status
          order_date
          line_items {
            edges {
              node {
                id
                sku
                quantity
                price
                product_name
                fulfillment_status
                updated_at
              }
              cursor
            }
            pageInfo {
              hasNextPage
            }
          }
        }
        cursor
      }
    }
  }
}

Do note that the Public API operates in UTC.

Please let me know if you have any questions or concerns.

Best,
RayanP

Hi @sh-agent

Thanks for your quick response.

Yes, that’s true. If I wants to get the last updated order data, then we can use (updated_from: “2023-04-21 19:20”, updated_to: “2023-04-21 19:30” ).

However, If I want to track the last updated Line-Items? Can I use the same condition??

Does that mean - In case of Line-items update also this parameter ( updated_from ) will get’s updated in the system for Orders?

Thank you.

Hi @sh-agent
Hope you are doing well!

I’m reaching out to you regarding the same issue mentioned you earlier. As you already know we’re trying to consume the Orders - Line items and trying to find a way to bring the delta information which changed over time.

We have implemented this approach for reading Orders data(Only header) and for this Updated_at field is used for sort and also we used endcursor from the pagination to read the next updated data in Orders dataset. This worked perfectly.

However, same kind of logic we’re trying to implement for Line-Items in Orders dataset. For some reason it’s not working. Please check the below sample GraphQL query we’re using.

query {
orders(order_number: “Demo_Order”) {
data(sort: “updated_at”) {
edges {
node {
id
order_number
order_date
updated_at
line_items(first: 10, sort: “updated_at”) {
edges {
node {
backorder_quantity
created_at
updated_at
id
order_id
}
}
}
}
}
pageInfo {
startCursor
endCursor
hasNextPage
hasPreviousPage
}
}
}
}

Here, Line items updated date is in future compared to the header data and, Order requirement is to get only Line-items data based on updated_at field and endcursor.

Could you provide the solution or approach for bringing this data.
Similar issue we have seen for Purchase Orders and Returns.

Your suggestion would help us to make the better API for orders and also this is very crucial for us. Since we’re stuck at this point.

early response would be appreciated

Thank you.

Hey @nareshbiyyam,

Thanks for bringing this up.
Going to work with the team on this one and get back to you.

Please let me know if you have any questions or concerns.

Best,
RayanP

Hi @sh-agent

Thank you for your prompt response.

Please keep me updated on the progress and any updates that arise during your collaboration.
This issue has become a bottleneck for our project, so looking for the solution as soon as possible.

If you have any questions or concerns, please don’t hesitate to reach out. I’m here to provide any assistance or clarification needed.

Thank you.