Have your say in Community Polls: What was/is your greatest motivation to start your own business?

How to add sku to product variant via graphQL

Solved

How to add sku to product variant via graphQL

Iwebaholic
Shopify Partner
2 0 0

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. 

 

 

Accepted Solution (1)

dmntlr
Visitor
1 1 1

This is an accepted solution.

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

 

View solution in original post

Replies 2 (2)

dmntlr
Visitor
1 1 1

This is an accepted solution.

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

 

Iwebaholic
Shopify Partner
2 0 0

Thank you.