Thanks. This is crazy, but I think it actually does update it. Just cannot see the new value the store UI (it is empty and greyed out). I believe this because I have code to NOT update if nothing has changed (I do a query first), and if I run the same update twice, the second update won’t happen, as it won’t even be attempted, because there was no change.
Also, as a further test, I changed my mutation to give back more information:
mutation = """
mutation inventorySetOnHandQuantities($input: InventorySetOnHandQuantitiesInput!) {
inventorySetOnHandQuantities(input: $input) {
userErrors {
field
message
}
inventoryAdjustmentGroup {
changes {
delta
quantityAfterChange
item {
id
sku
tracked
variant {
inventoryQuantity
}
}
}
}
}
}
"""
variables = {
"input": {
"setQuantities": [
{
"inventoryItemId": inventory_item_id,
"locationId": f"gid://shopify/Location/{location_id}",
"quantity": new_qty
}
],
"reason": "correction"
}
}
mutation_result = shopify.GraphQL().execute(mutation, variables=variables)
and I got this:
Changing available quantity from 50 to 5, item id gid://shopify/InventoryItem/<SKUID>, sku <SKU>, tracked False
=== Parsed mutation_data ===
{
"data": {
"inventorySetOnHandQuantities": {
"userErrors": [],
"inventoryAdjustmentGroup": {
"changes": [
{
"delta": -45,
"quantityAfterChange": null,
"item": {
"id": "gid://shopify/InventoryItem/<SKUID>",
"sku": "<SKU>",
"tracked": false,
"variant": {
"inventoryQuantity": 5
}
}
},
{
"delta": -45,
"quantityAfterChange": null,
"item": {
"id": "gid://shopify/InventoryItem/<SKUID>",
"sku": "<SKU>",
"tracked": false,
"variant": {
"inventoryQuantity": 5
}
}
}
]
}
}
},
"extensions": {
// No idea what this is, so snipped it
}
}
}
=== End mutation_data ===
So that is weird. Yes, this is the update I expected to happen (from 50 down to 5). Since I see nothing in UI, I would never have noticed it without either querying before I did the update, or checking the response after the update. For tracked items, I can see the change in the UI via “Adjustment History”, but no such option for non-tracked items.
So long as the store is not harmed, maybe it is OK. Just quite weird.
Is this one of those rare cases where the RESTful route is actually safer?