How to add sku to product variant via graphQL

I’m using the Shopify GraphiQL App to set up my mutations, and I’m using the GraphQL docs as a reference. The docs say that updating the sku using the productVariantUpdate mutation is deprecated and to use inventoryItem.sku instead, however InventoryItemInput does not have sku as an option and I get a type error when I try to use it in this mutation “InputObject ‘InventoryItemInput’ doesn’t accept argument ‘sku’”.

Using the deprecated ‘sku’ value works like this,

mutation MyMutation {
  productVariantUpdate(
    input: {id: "gid://shopify/ProductVariant/49897690000000", price: "20.45", sku: "test5/20-51s"}
  ) {
    productVariant {
      id
      sku
    }
  }
}

But the whole point of updating our application was to get away from deprecated REST API usage, and I can’t seem to find a way to update a sku for a product variant using a GraphQL mutation that isn’t deprecated as well.

I had the same problem. Please try to use API version 2024-07. With the newest version you can pass sku in the inventoryItem*.*

1 Like

Thank you.

is it worked ??

Well, we have the same problem as we use SKUs for product identification in the warehouse. Now with the 2025-01 update can’t find a way to save SKUs for new products. Is there any solution to update/add SKU for a product?

Not even the price is saved when productCreate GraphQL.

I’m also trying to update to 2025-01. Same issue, I have new products without variants that need to have SKUs. It looks like I need to create a variant and to do that I need to create a variantOption. All of our existing items still have SKUs without variants/variantOptions, it seems creating new varitant-less products with a SKU is impossible in 2025-01…

With the last version 2025-01 you need to create first the product

this create a variant option by default get id of this variant.

as a second step to add sku, price you need to update the variant by productVariantsBulkUpdate

https://shopify.dev/docs/api/admin-graphql/latest/mutations/productVariantsBulkUpdate?example=Modify+an+existing+Product+Variant


"variants": [
{
"id": "gid://shopify/ProductVariant/50796440158513",
"price": "500",
"inventoryItem": {
"sku": "1234567890"
}
}
],

1 Like