Hi all
We build custom warehouses solution and custom app.
I need to find the most optimal way to query stock in the app.
Our online shop works within context of selected store, which is Shopify Location.
This store has warehouses associated to it (other locations).
This is not the built-in Shopify association feature, its our custom.
Our front end can send parameters to the app API:
- location gid
- variant gid OR sku.
Now I have 2 possibilities to drill down to inventory item:
- using
productVariantquery by ID and asking for inventoryItem - using
inventoryItemsquery with filterquery:"sku:<sku>"
Which one is will be faster?
Next, I need to ask for inventory levels at specific warehouses.
I can ask each warehouse individually, by creating named field for each, example:
inventoryItem {
_w1:inventoryLevel (locationId: "gid://shopify/Location/88008130813") {
quantities(names:"available") {
quantity
}
}
_w2:inventoryLevel (locationId: "gid://shopify/Location/65087111421") {
quantities(names:"available") {
quantity
}
}
}
OR I somehow can use query, but due to Shopify-ish style of documentation I can’t figure if it is even possible. I’m sinking in endless errors, example of my code:
inventoryLevels(first: 1,
query: "location:id:'gid://shopify/Location/88008130813'") {
It will not accept “location.id”, “location:id” or anything like that as a filter. How to filter by location via “query” remains a mystery, but there is a chance this is doable.
Is there a possibility to use query and which pathway is better for performance?
Many thanks to everyone for your support