Can I update a specific Variant using only a Product ID?

Solved
Highlighted
Pathfinder
83 4 8

I want to update the taxcode variant on a product with a mutation. Is it possible to take a product id and pass it to a mutation and update the taxcode variant? I am currently using the variantid to update the taxcode like this: 

  mutation productVariantUpdate($input: ProductVariantInput!) {
    productVariantUpdate(input: $input) {
      product {
        title
      }
      productVariant {
        id
        taxCode
      }
    }
  }
0 Likes
Highlighted
Pathfinder
83 4 8

This is an accepted solution.

To answer my own question, no you can't update a Variant using only a Product ID. The reason is covered in the Mutation documents which define what is accepted as ProductVariantInput. 

Here is the reference: 

https://shopify.dev/docs/admin-api/graphql/reference/mutation/productvariantupdate?api[version]=2020... 

0 Likes