To update inventory through my app

krish115
Shopify Partner
26 0 5

I have created an app to update product inventory from the uploaded csv file, I am facing problem in the GraphQL update query, I am using the following mutation: -


data: {
                query: `mutation {
                  productUpdate(input: { id: "${prod}", variants: { inventoryQuantity: ${product.inventory} } }) {
                    product {
                      id
                    }
                  }
                }`
              }

I am facing error: -

Inventory Update Fail Error: InputObject 'ProductVariantInput' doesn't accept argument 'inventoryQuantity'

Reply 1 (1)

LucasOdd4
Shopify Partner
2 0 0
The newer version of the Shopify Graphql API does not have a inventoryQuantity field in the ProductVariantInput object
 
try inventoryQuantities
 
https://shopify.dev/docs/api/admin-graphql/unstable/input-objects/productvariantinput#field-productv...

data: {
query: `
mutation {
productUpdate(input: {
id: "${prod}",
variants: [
{
inventoryQuantities: [
{
availableQuantity: ${product.inventory},
locationId: "YOUR_LOCATION_ID_HERE" // Replace this with your actual location ID
}
]
}
]
}) {
product {
id
variants(first: 3) {
edges {
node {
inventoryQuantities {
availableQuantity
locationId
}
}
}
}
}
userErrors {
field
message
}
}
}
`
}