Focusing on managing products, variants, and collections through the API.
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?
Solved! Go to the solution
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
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