skip to Main Content

I have checked the Shopify GraphQL API, and I have tried to update the product inventory on Shopify but when I execute the graphql API it says "

Inventory quantities cannot be updated with variants API

The mutation I am trying to run:

mutation productVariantsBulkUpdate(
  $productId: ID!,
  $variants [ProductVariantsBulkInput!]!
) {
    productVariantsBulkUpdate(
      productId: $productId,
      variants: $variants
    ) {
      product {
        id
      }
      productVariants {
        id
      }
      userErrors {
        field
        message
      }
    }
}

And the variable of this request

{"variants": {"inventoryQuantities": {"availableQuantity": 10,"locationId":"gid://shopify/Location/66027421902" },"id":"gid://shopify/ProductVariant/40747448828110" },"productId": "gid://shopify/Product/6899888488654"}

I have checked with the bulk update inventory but it is not what I need, how do I set (not adjust) the inventory level using the Shopify API?

2

Answers


  1. Unfortunately, it looks like this is intentional and that there is no way to directly set inventory levels using the GraphQL API at this time

    From this Shopify documentation page:

    There is no mutation to set levels directly using the GraphQL Admin
    API. Use the adjustInventoryLevelQuantity mutation to adjust the
    inventory level instead.

    The good news is that this is possible via the REST API, and details are provided on the same page as above, under the "REST" tab.


    I will request this feature from Shopify as it is useful in some cases where adjusting quantity is not appropriate (e.g. writing idempotent functions).

    Login or Signup to reply.
  2. I had the same problem and used productVariantUpdate() instead, you can just put all you variants in a list and loop on them using this mutation

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search