A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hi All,
Currently I use the inventoryManagement field on productVariant() to check if inventory is managed by Shopify. This field is deprecated and the Explorer suggests to use the tracked field on the InventoryItem(). The tracked field returns TRUE even if the item is tracked by a fulfillment service. When I also check the inventoryManagement on fulfillmentService() it returns TRUE even if the inventory is managed by SHOPIFY.
What's the way to check with GraphQL if a variant's inventory is managed by Shopify or by a third party?
Solved! Go to the solution
This is an accepted solution.
Cutting down on the amount of (first:X) calls can definitely make it less expensive. You actually only need the first inventorylevel (which reduces the cost of the query to 10), rather than all of them since currently an item can only be stocked at either Shopify Locations or a FulfillmentService, not both.
Edit: scaling up to 30 variants costs 213, and 50 is 353, so not terrible.
Ryan | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
Hi Harold,
tracked provides simply whether or not the item is tracking inventory levels. To know whether or not that variant/item is stocked at a fulfillment service (instead of a shopify location) you would traverse: variant.inventoryItem.inventoryLevel.location.fulfillmentService. Example call below:
{ product(id: "gid://shopify/Product/1536578748438") { id variants(first: 10) { edges { node { inventoryManagement # Deprecated inventoryItem { id tracked # Provides whether or not the item is tracking inventory inventoryLevels(first: 10) { edges { node { available id location { fulfillmentService { # null if not stocked at a fulfillment service handle id inventoryManagement serviceName } id name }}}}}}}}}}
Return for an item not stocked at an FS like:
{ "product": { "id": "gid://shopify/Product/1536578748438", "variants": { "edges": [ { "node": { "inventoryManagement": "SHOPIFY", "inventoryItem": { "id": "gid://shopify/InventoryItem/14109354524694", "tracked": true, "inventoryLevels": { "edges": [ { "node": { "available": 1, "id": "gid://shopify/InventoryLevel/37685843?inventory_item_id=14109354524694", "location": { "fulfillmentService": null, "id": "gid://shopify/Location/44073811", "name": "Location1" } } }, { "node": { "available": 70, "id": "gid://shopify/InventoryLevel/13571129400?inventory_item_id=14109354524694", "location": { "fulfillmentService": null, "id": "gid://shopify/Location/13969457208", "name": "Location2" }}}]}}}}]}}}
When it is stocked at a fulfillment service (Shortened to just relevant parts):
"inventoryLevels": { "edges": [ { "node": { "available": 96, "id": "gid://shopify/InventoryLevel/16888299542?inventory_item_id=19839477415958", "location": { "fulfillmentService": { "handle": "ryanfs", "id": "gid://shopify/FulfillmentService/581959702?id=true", "inventoryManagement": false, "serviceName": "RyanFS" }, "id": "gid://shopify/Location/17241047062", "name": "RyanFS" }}}]
Hope that helps!
Ryan
Ryan | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog
Hi Ryan,
Thanks for the reply.
That's also how far I got, but isn't this quite "expensive"? Let's say I want to fetch 10 or 20 different variants and fetch First:10 for the inventoryLevels. And is inventoryLevels( first:10 ) enough for all stores?
Would it be an idea to add a boolean field to the fulfillmentService to show if the inventory is tracked by that fulfillmentService? That would be a lot easier and cheaper if you don't need the inventory and just want to know if an items inventory is tracked by a third party or not. 🙂
Cheers,
Harold
This is an accepted solution.
Cutting down on the amount of (first:X) calls can definitely make it less expensive. You actually only need the first inventorylevel (which reduces the cost of the query to 10), rather than all of them since currently an item can only be stocked at either Shopify Locations or a FulfillmentService, not both.
Edit: scaling up to 30 variants costs 213, and 50 is 353, so not terrible.
Ryan | Shopify
- Was my reply helpful? Click Like to let me know!
- Was your question answered? Mark it as an Accepted Solution
- To learn more visit the Shopify Help Center or the Shopify Blog