A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
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
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.
Shayne | Developer Advocate @ 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 Shopify.dev or the Shopify Web Design and Development Blog