Have your say in Community Polls: What was/is your greatest motivation to start your own business?
Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Set variant title with GraphQL

Solved

Set variant title with GraphQL

CuriousShopper
Visitor
1 0 0

How can one set a variant title with GraphQL? In the docs it says that it is deprecated and the field is not writable, but its value is instead generated from the options. In the web interface, however, the title is writable.

We have to set the titles for thousands of variants. Having to do that through the web interface seems silly. Is there a better way to do this?

Accepted Solution (1)

Liam
Community Manager
3108 344 889

This is an accepted solution.

Hi CuriousShopper,

 

This productVariantUpdate mutation will set the variant title: 

mutation {
  productVariantUpdate(input: {
    id: "gid://shopify/ProductVariant/12345678",
    options: ["New Title"]
  }) {
    productVariant {
      id
      title
    }
    userErrors {
      field
      message
    }
  }
}

 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

View solution in original post

Reply 1 (1)

Liam
Community Manager
3108 344 889

This is an accepted solution.

Hi CuriousShopper,

 

This productVariantUpdate mutation will set the variant title: 

mutation {
  productVariantUpdate(input: {
    id: "gid://shopify/ProductVariant/12345678",
    options: ["New Title"]
  }) {
    productVariant {
      id
      title
    }
    userErrors {
      field
      message
    }
  }
}

 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog