In rest api, the product variant returns the above attribute, in our app, we only update the inventory if inventory_management=shopify and fulfilment_service=manual
So in graphql, I have a productVariant id, how to query the above information?
So for inventory_management=shopify, you can use the inventoryItem.tracked field that’s on productVariant, and for fulfillmentService you’d include inventoryLevels in your query, so it would look something like:
query GetProductVariantDetails {
productVariant(id: "gid://shopify/ProductVariant/43729076") {
inventoryItem {
tracked # Indicates if inventory is managed by Shopify
}
inventoryLevels(first: 1) {
edges {
node {
location {
fulfillmentService {
type # Indicates the fulfillment service type (e.g., MANUAL, THIRD_PARTY)
}
}
}
}
}
}
}
[{“message”:“Field ‘inventoryLevels’ doesn’t exist on type ‘ProductVariant’”,“locations”:[{“line”:1,“column”:109}],“path”:[“query getProductVariant”,“productVariant”,“inventoryLevels”],“extensions”:{“code”:“undefinedField”,“typeName”:“ProductVariant”,“fieldName”:“inventoryLevels”}}]
But this is the return: (for this product it is managed by shopify and I have not created any fulfillment service, I assume by default it is manual, so it should return something)