A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hi i need to update the price and inventory of the variants once a day and i saw a thread saying i can use productvariantupdate with bulk mutation. I created the bulk mutation below.
mutation {
bulkOperationRunMutation(mutation: "mutation call($input: ProductVariantInput!) {productVariantUpdate(input: $input) {
productVariant { id price inventoryQuantity } userErrors { field message }
}
}", stagedUploadPath: "tmp/58782580893/bulk/0de283d9-3181-4bd8-9a46-******863adb/shopify_uploads") {
bulkOperation {
createdAt
completedAt
errorCode
id
status
}
userErrors {
field
message
}
}
}
I uploaded these variable to the server
{"input":{"id": "gid://shopify/ProductVariant/40678598934685", "price": 55.9, "inventoryQuantity": 23.0}}
{"input":{"id": "gid://shopify/ProductVariant/40678600245405", "price": 69.9, "inventoryQuantity": 15.0}}
When i run the mutation i get the error that inventoryQuantity field does not exist
{"data":{"bulkOperationRunMutation":{"bulkOperation":null,"userErrors":[{"field":null,"message":"Invalid Bulk Mutation Field - Variable $input of type ProductVariantInput! was provided invalid value for inventoryQuantity (Field is not defined on ProductVariantInput)"}]}},"extensions":{"cost":{"requestedQueryCost":10,"actualQueryCost":10,"throttleStatus":{"maximumAvailable":1000.0,"currentlyAvailable":990,"restoreRate":50.0}}}}
I want/very much prefer to update the price and inventory in a single mutation. Any help is appreciated thank you.
Solved! Go to the solution
This is an accepted solution.
Hey @JJasperr
Yes, that's right - productVariantUpdate is available to be run as part of a bulkOperationRunMutation. InventoryQuantity does not exist on the productVariantInput, although InventoryQuantities does.
However unfortunately, Inventory Quantities is a create only field(docs) and so it wouldn't work with productVariantUpdate as part of the bulk mutation.
To update the inventory quantities, after creation, it is looking like you would need to use inventoryBulkAdjustQuantityAtLocation mutation - there are some docs here. Hope that helps!
This is an accepted solution.
Hey @JJasperr
Yes, that's right - productVariantUpdate is available to be run as part of a bulkOperationRunMutation. InventoryQuantity does not exist on the productVariantInput, although InventoryQuantities does.
However unfortunately, Inventory Quantities is a create only field(docs) and so it wouldn't work with productVariantUpdate as part of the bulk mutation.
To update the inventory quantities, after creation, it is looking like you would need to use inventoryBulkAdjustQuantityAtLocation mutation - there are some docs here. Hope that helps!