Requires write_products
access scope. Also: The user must have a permission to edit products and manage product variants.
Updates an option on a product, such as size, color, or material. Each option includes a name, position, and a list of values. The combination of a product option and value creates a product variant.
Use the productOptionUpdate
mutation for the following use cases:
The productOptionUpdate
mutation enforces strict data integrity for product options and variants. All option positions must be sequential, and every option should be used by at least one variant.
After you update a product option, you can further manage a product's configuration using related mutations:
productOptionsCreate
productOptionsDelete
productOptionsReorder
productVariantsBulkCreate
productVariantsBulkUpdate
productSet
Learn more about the product model and adding product data.
New option values to create.
IDs of the existing option values to delete.
Existing option values to update.
The ID of the Product the Option belongs to.
The strategy defines which behavior the mutation should observe regarding variants, such as creating variants or deleting them in response to option values to add or to delete. If not provided or set to null, the strategy LEAVE_AS_IS
will be used.
The product with which the option being updated is associated.
The list of errors that occurred from executing the mutation.
mutation updateOption( $productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!] $variantStrategy: ProductOptionUpdateVariantStrategy ) { productOptionUpdate( productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy ) { userErrors { field message code } product { id options { id name values position optionValues { id name hasVariants } } variants(first: 5) { nodes { id title selectedOptions { name, value } } } } } }
curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-07/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation updateOption( $productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!] $variantStrategy: ProductOptionUpdateVariantStrategy ) { productOptionUpdate( productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy ) { userErrors { field message code } product { id options { id name values position optionValues { id name hasVariants } } variants(first: 5) { nodes { id title selectedOptions { name, value } } } } } }", "variables": { "productId": "gid://shopify/Product/1072481071", "option": { "id": "gid://shopify/ProductOption/1064576536", "position": 1, "name": "Tint" } } }'
const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation updateOption( $productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!] $variantStrategy: ProductOptionUpdateVariantStrategy ) { productOptionUpdate( productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy ) { userErrors { field message code } product { id options { id name values position optionValues { id name hasVariants } } variants(first: 5) { nodes { id title selectedOptions { name, value } } } } } }`, { variables: { "productId": "gid://shopify/Product/1072481071", "option": { "id": "gid://shopify/ProductOption/1064576536", "position": 1, "name": "Tint" } }, }, ); const data = await response.json();
const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation updateOption( $productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!] $variantStrategy: ProductOptionUpdateVariantStrategy ) { productOptionUpdate( productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy ) { userErrors { field message code } product { id options { id name values position optionValues { id name hasVariants } } variants(first: 5) { nodes { id title selectedOptions { name, value } } } } } }`, "variables": { "productId": "gid://shopify/Product/1072481071", "option": { "id": "gid://shopify/ProductOption/1064576536", "position": 1, "name": "Tint" } }, }, });
session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY mutation updateOption( $productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!] $variantStrategy: ProductOptionUpdateVariantStrategy ) { productOptionUpdate( productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy ) { userErrors { field message code } product { id options { id name values position optionValues { id name hasVariants } } variants(first: 5) { nodes { id title selectedOptions { name, value } } } } } } QUERY variables = { "productId": "gid://shopify/Product/1072481071", "option": { "id": "gid://shopify/ProductOption/1064576536", "position": 1, "name": "Tint" } } response = client.query(query: query, variables: variables)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4