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?
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
}}}}}}}}}}
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.
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.