1

I am trying to bulk update the price on multiple product variants at once. I'm just copying the "interactive" example from Shopify's page

All I did was copy and paste the code and put in my own id's. And of course it does not work.

It looks like this:

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

With Variables like this:

{
  "variants": [
    {
      id:  "gid://shopify/ProductVariant/39369514385591",
      price: "50.00"
    }
  ],
  "productId": "gid://shopify/Product/6591908577463"
}

I'm getting this error: Variables are invalid JSON: Unexpected token i in JSON at position 30.

1 Answer 1

2

It's OK for me. (with some quick tweaks)

I tweaked the request a little since the cursor is not present in the product/variant object, don't know why Shopify has not updated the example in their docs.

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

So try to fix the query and remove the cursor object and check if you are using the proper end-point since the bulk operation is available in the unstable version only if I'm not mistaken.

See the image below showing that the response is OK for me.

enter image description here

1
  • yep you were right on all the fronts! Plus only the unstable version of the API supports this.
    – ToddT
    Commented Mar 21, 2021 at 21:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.