How to get inventory based on lot number using graphql

Hello,

This is my query for import products from shiphero:
query = “”"
query {
products {
request_id
complexity
data(first:100) {
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
edges {
node {
id
legacy_id
account_id
name
sku
barcode
country_of_manufacture
dimensions {
height
width
length
weight
}
product_note
active
warehouse_products {
warehouse_id
on_hand
}
images {
src
}
tags
kit_components {
sku
quantity
}
}
cursor
}
}
}
}
“”"
From this I can get the actual on hand Quantity (Total in all the lots).

However,
When I call this query for change in inventory:
query = “”"
query {
inventory_changes(date_from: “%s” date_to: “%s”) {
request_id
complexity
data(first:10){
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
edges {
node {
user_id
account_id
warehouse_id
sku
previous_on_hand
change_in_on_hand
reason
cycle_counted
lot_id
lot_name
lot_expiration
location_id
created_at
location {
id
legacy_id
account_id
warehouse_id
name
zone
pickable
sellable
is_cart
temperature
last_counted
created_at
}
}
}
}
}
}
“”" % (date_from, date_to)

I do not get the correct on hand quantity by lots.

What to do to get the correct on hand quantity by lots?

Hi there!

Thanks for your submission. Could you share some more details on what your trying to achieve?

In order to find quantity of a sku by lots you should be able to make a call using warehouse_products like:

{
warehouse_products {
request_id
complexity
data(first: 1) {
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
edges {
node {
id
legacy_id
account_id
sku
locations {
edges {
node{
expiration_lot {
name
id
}
quantity
}
}
}
}
}
}
}
}

Note that because lot information is highly nested you would need to reduce the number of results to less than 100. If you need a larger dataset pagination would be the key.