Update Stock of variants in bulk through graphql api

def update_product_variant_query(key)
<<~QUERY
mutation {
bulkOperationRunMutation(
mutation: “mutation call($input: ProductVariantInput!) {productVariantUpdate(input: $input) {
productVariant {
id
price
sku
}
userErrors {
field
message
}
}
}”,
stagedUploadPath: “#{key}”) {
bulkOperation {
id
url
status
}
userErrors {
message
field
}
}
}
QUERY
end
I am updating price of variants through this graphl ql api. But when I tried to update stock(inventoryQuantity) of variants through this same api query I am recieving error. So please tell me how can update quantity of stock (inventoryQuantity) in bulk through graphql api

1 Like

You can’t write inventory directly to variants, because we don’t know which locations the inventory should be allocated to. Managing inventory isn’t really on the variant, the inventoryQuantity is a convenience field that’s a rolled-up version of the existing quantities at the stocked locations.

Instead, use the inventoryBulkAdjustQuantityAtLocation mutation to change the inventory quantity of a specific inventory item.

1 Like