Version: 2024-10
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"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 } } } } } }\",\n \"variables\": {\n \"productId\": \"gid://shopify/Product/1072481063\",\n \"option\": {\n \"id\": \"gid://shopify/ProductOption/1064576526\"\n },\n \"optionValuesToAdd\": [\n {\n \"name\": \"Yellow\"\n },\n {\n \"name\": \"Red\"\n }\n ],\n \"optionValuesToUpdate\": [\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054672275\",\n \"name\": \"Purple\"\n }\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!], $variantStrategy: ProductOptionUpdateVariantStrategy) {\n productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy) {\n userErrors {\n field\n message\n code\n }\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n variants(first: 5) {\n nodes {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"productId\": \"gid://shopify/Product/1072481063\",\n \"option\": {\n \"id\": \"gid://shopify/ProductOption/1064576526\"\n },\n \"optionValuesToAdd\": [\n {\n \"name\": \"Yellow\"\n },\n {\n \"name\": \"Red\"\n }\n ],\n \"optionValuesToUpdate\": [\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054672275\",\n \"name\": \"Purple\"\n }\n ]\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!], $variantStrategy: ProductOptionUpdateVariantStrategy) {\n productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy) {\n userErrors {\n field\n message\n code\n }\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n variants(first: 5) {\n nodes {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"productId\": \"gid://shopify/Product/1072481063\",\n \"option\": {\n \"id\": \"gid://shopify/ProductOption/1064576526\"\n },\n \"optionValuesToAdd\": [{\"name\"=>\"Yellow\"}, {\"name\"=>\"Red\"}],\n \"optionValuesToUpdate\": [{\"id\"=>\"gid://shopify/ProductOptionValue/1054672275\", \"name\"=>\"Purple\"}]\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!], $variantStrategy: ProductOptionUpdateVariantStrategy) {\n productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy) {\n userErrors {\n field\n message\n code\n }\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n variants(first: 5) {\n nodes {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"productId\" => \"gid://shopify/Product/1072481063\",\n \"option\" => [\n \"id\" => \"gid://shopify/ProductOption/1064576526\",\n ],\n \"optionValuesToAdd\" => [{\"name\"=>\"Yellow\"}, {\"name\"=>\"Red\"}],\n \"optionValuesToUpdate\" => [{\"id\"=>\"gid://shopify/ProductOptionValue/1054672275\", \"name\"=>\"Purple\"}],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!], $variantStrategy: ProductOptionUpdateVariantStrategy) {\n productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy) {\n userErrors {\n field\n message\n code\n }\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n variants(first: 5) {\n nodes {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"productId\": \"gid://shopify/Product/1072481063\",\n \"option\": {\n \"id\": \"gid://shopify/ProductOption/1064576526\"\n },\n \"optionValuesToAdd\": [\n {\n \"name\": \"Yellow\"\n },\n {\n \"name\": \"Red\"\n }\n ],\n \"optionValuesToUpdate\": [\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054672275\",\n \"name\": \"Purple\"\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!], $variantStrategy: ProductOptionUpdateVariantStrategy) {\n productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy) {\n userErrors {\n field\n message\n code\n }\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n variants(first: 5) {\n nodes {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n}"
input: { "productId": "gid://shopify/Product/1072481063", "option": { "id": "gid://shopify/ProductOption/1064576526" }, "optionValuesToAdd": [ { "name": "Yellow" }, { "name": "Red" } ], "optionValuesToUpdate": [ { "id": "gid://shopify/ProductOptionValue/1054672275", "name": "Purple" } ] }
response: { "data": { "productOptionUpdate": { "userErrors": [], "product": { "id": "gid://shopify/Product/1072481063", "options": [ { "id": "gid://shopify/ProductOption/1064576526", "name": "Color", "values": [ "Purple" ], "position": 1, "optionValues": [ { "name": "Purple", "hasVariants": true }, { "name": "Yellow", "hasVariants": false }, { "name": "Red", "hasVariants": false } ] } ], "variants": { "nodes": [ { "id": "gid://shopify/ProductVariant/1070325103", "title": "Purple", "selectedOptions": [ { "name": "Color", "value": "Purple" } ] } ] } } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"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 } } } } } }\",\n \"variables\": {\n \"productId\": \"gid://shopify/Product/1072481069\",\n \"option\": {\n \"id\": \"gid://shopify/ProductOption/1064576533\"\n },\n \"optionValuesToAdd\": [\n {\n \"name\": \"Small\"\n }\n ],\n \"optionValuesToUpdate\": [\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054672293\",\n \"name\": \"Medium\"\n }\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!], $variantStrategy: ProductOptionUpdateVariantStrategy) {\n productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy) {\n userErrors {\n field\n message\n code\n }\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n variants(first: 5) {\n nodes {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"productId\": \"gid://shopify/Product/1072481069\",\n \"option\": {\n \"id\": \"gid://shopify/ProductOption/1064576533\"\n },\n \"optionValuesToAdd\": [\n {\n \"name\": \"Small\"\n }\n ],\n \"optionValuesToUpdate\": [\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054672293\",\n \"name\": \"Medium\"\n }\n ]\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!], $variantStrategy: ProductOptionUpdateVariantStrategy) {\n productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy) {\n userErrors {\n field\n message\n code\n }\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n variants(first: 5) {\n nodes {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"productId\": \"gid://shopify/Product/1072481069\",\n \"option\": {\n \"id\": \"gid://shopify/ProductOption/1064576533\"\n },\n \"optionValuesToAdd\": [{\"name\"=>\"Small\"}],\n \"optionValuesToUpdate\": [{\"id\"=>\"gid://shopify/ProductOptionValue/1054672293\", \"name\"=>\"Medium\"}]\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!], $variantStrategy: ProductOptionUpdateVariantStrategy) {\n productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy) {\n userErrors {\n field\n message\n code\n }\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n variants(first: 5) {\n nodes {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"productId\" => \"gid://shopify/Product/1072481069\",\n \"option\" => [\n \"id\" => \"gid://shopify/ProductOption/1064576533\",\n ],\n \"optionValuesToAdd\" => [{\"name\"=>\"Small\"}],\n \"optionValuesToUpdate\" => [{\"id\"=>\"gid://shopify/ProductOptionValue/1054672293\", \"name\"=>\"Medium\"}],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!], $variantStrategy: ProductOptionUpdateVariantStrategy) {\n productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy) {\n userErrors {\n field\n message\n code\n }\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n variants(first: 5) {\n nodes {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"productId\": \"gid://shopify/Product/1072481069\",\n \"option\": {\n \"id\": \"gid://shopify/ProductOption/1064576533\"\n },\n \"optionValuesToAdd\": [\n {\n \"name\": \"Small\"\n }\n ],\n \"optionValuesToUpdate\": [\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054672293\",\n \"name\": \"Medium\"\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!], $variantStrategy: ProductOptionUpdateVariantStrategy) {\n productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy) {\n userErrors {\n field\n message\n code\n }\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n variants(first: 5) {\n nodes {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n}"
input: { "productId": "gid://shopify/Product/1072481069", "option": { "id": "gid://shopify/ProductOption/1064576533" }, "optionValuesToAdd": [ { "name": "Small" } ], "optionValuesToUpdate": [ { "id": "gid://shopify/ProductOptionValue/1054672293", "name": "Medium" } ] }
response: { "data": { "productOptionUpdate": { "userErrors": [], "product": { "id": "gid://shopify/Product/1072481069", "options": [ { "id": "gid://shopify/ProductOption/1064576532", "name": "Color", "values": [ "Blue", "Green" ], "position": 1, "optionValues": [ { "name": "Blue", "hasVariants": true }, { "name": "Green", "hasVariants": true } ] }, { "id": "gid://shopify/ProductOption/1064576533", "name": "Size", "values": [ "Medium" ], "position": 2, "optionValues": [ { "name": "Medium", "hasVariants": true }, { "name": "Small", "hasVariants": false } ] } ], "variants": { "nodes": [ { "id": "gid://shopify/ProductVariant/1070325113", "title": "Blue / Medium", "selectedOptions": [ { "name": "Color", "value": "Blue" }, { "name": "Size", "value": "Medium" } ] }, { "id": "gid://shopify/ProductVariant/1070325114", "title": "Green / Medium", "selectedOptions": [ { "name": "Color", "value": "Green" }, { "name": "Size", "value": "Medium" } ] } ] } } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"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 } } } } } }\",\n \"variables\": {\n \"productId\": \"gid://shopify/Product/1072481067\",\n \"option\": {\n \"id\": \"gid://shopify/ProductOption/1064576530\"\n },\n \"optionValuesToAdd\": [\n {\n \"name\": \"Red\"\n },\n {\n \"name\": \"Blue\"\n }\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!], $variantStrategy: ProductOptionUpdateVariantStrategy) {\n productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy) {\n userErrors {\n field\n message\n code\n }\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n variants(first: 5) {\n nodes {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"productId\": \"gid://shopify/Product/1072481067\",\n \"option\": {\n \"id\": \"gid://shopify/ProductOption/1064576530\"\n },\n \"optionValuesToAdd\": [\n {\n \"name\": \"Red\"\n },\n {\n \"name\": \"Blue\"\n }\n ]\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!], $variantStrategy: ProductOptionUpdateVariantStrategy) {\n productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy) {\n userErrors {\n field\n message\n code\n }\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n variants(first: 5) {\n nodes {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"productId\": \"gid://shopify/Product/1072481067\",\n \"option\": {\n \"id\": \"gid://shopify/ProductOption/1064576530\"\n },\n \"optionValuesToAdd\": [{\"name\"=>\"Red\"}, {\"name\"=>\"Blue\"}]\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!], $variantStrategy: ProductOptionUpdateVariantStrategy) {\n productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy) {\n userErrors {\n field\n message\n code\n }\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n variants(first: 5) {\n nodes {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"productId\" => \"gid://shopify/Product/1072481067\",\n \"option\" => [\n \"id\" => \"gid://shopify/ProductOption/1064576530\",\n ],\n \"optionValuesToAdd\" => [{\"name\"=>\"Red\"}, {\"name\"=>\"Blue\"}],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!], $variantStrategy: ProductOptionUpdateVariantStrategy) {\n productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy) {\n userErrors {\n field\n message\n code\n }\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n variants(first: 5) {\n nodes {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"productId\": \"gid://shopify/Product/1072481067\",\n \"option\": {\n \"id\": \"gid://shopify/ProductOption/1064576530\"\n },\n \"optionValuesToAdd\": [\n {\n \"name\": \"Red\"\n },\n {\n \"name\": \"Blue\"\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!], $variantStrategy: ProductOptionUpdateVariantStrategy) {\n productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy) {\n userErrors {\n field\n message\n code\n }\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n variants(first: 5) {\n nodes {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n}"
input: { "productId": "gid://shopify/Product/1072481067", "option": { "id": "gid://shopify/ProductOption/1064576530" }, "optionValuesToAdd": [ { "name": "Red" }, { "name": "Blue" } ] }
response: { "data": { "productOptionUpdate": { "userErrors": [ { "field": [ "optionValuesToAdd", "1", "name" ], "message": "Option value already exists.", "code": "OPTION_VALUE_ALREADY_EXISTS" } ], "product": { "id": "gid://shopify/Product/1072481067", "options": [ { "id": "gid://shopify/ProductOption/1064576530", "name": "Color", "values": [ "Blue" ], "position": 1, "optionValues": [ { "id": "gid://shopify/ProductOptionValue/1054672288", "name": "Blue", "hasVariants": true } ] } ], "variants": { "nodes": [ { "id": "gid://shopify/ProductVariant/1070325110", "title": "Blue", "selectedOptions": [ { "name": "Color", "value": "Blue" } ] } ] } } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"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 } } } } } }\",\n \"variables\": {\n \"productId\": \"gid://shopify/Product/1072481071\",\n \"option\": {\n \"id\": \"gid://shopify/ProductOption/1064576536\",\n \"position\": 1,\n \"name\": \"Tint\"\n }\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!], $variantStrategy: ProductOptionUpdateVariantStrategy) {\n productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy) {\n userErrors {\n field\n message\n code\n }\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n variants(first: 5) {\n nodes {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"productId\": \"gid://shopify/Product/1072481071\",\n \"option\": {\n \"id\": \"gid://shopify/ProductOption/1064576536\",\n \"position\": 1,\n \"name\": \"Tint\"\n }\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!], $variantStrategy: ProductOptionUpdateVariantStrategy) {\n productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy) {\n userErrors {\n field\n message\n code\n }\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n variants(first: 5) {\n nodes {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"productId\": \"gid://shopify/Product/1072481071\",\n \"option\": {\n \"id\": \"gid://shopify/ProductOption/1064576536\",\n \"position\": 1,\n \"name\": \"Tint\"\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!], $variantStrategy: ProductOptionUpdateVariantStrategy) {\n productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy) {\n userErrors {\n field\n message\n code\n }\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n variants(first: 5) {\n nodes {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"productId\" => \"gid://shopify/Product/1072481071\",\n \"option\" => [\n \"id\" => \"gid://shopify/ProductOption/1064576536\",\n \"position\" => 1,\n \"name\" => \"Tint\",\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!], $variantStrategy: ProductOptionUpdateVariantStrategy) {\n productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy) {\n userErrors {\n field\n message\n code\n }\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n variants(first: 5) {\n nodes {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"productId\": \"gid://shopify/Product/1072481071\",\n \"option\": {\n \"id\": \"gid://shopify/ProductOption/1064576536\",\n \"position\": 1,\n \"name\": \"Tint\"\n }\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!], $variantStrategy: ProductOptionUpdateVariantStrategy) {\n productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete, variantStrategy: $variantStrategy) {\n userErrors {\n field\n message\n code\n }\n product {\n id\n options {\n id\n name\n values\n position\n optionValues {\n id\n name\n hasVariants\n }\n }\n variants(first: 5) {\n nodes {\n id\n title\n selectedOptions {\n name\n value\n }\n }\n }\n }\n }\n}"
input: { "productId": "gid://shopify/Product/1072481071", "option": { "id": "gid://shopify/ProductOption/1064576536", "position": 1, "name": "Tint" } }
response: { "data": { "productOptionUpdate": { "userErrors": [], "product": { "id": "gid://shopify/Product/1072481071", "options": [ { "id": "gid://shopify/ProductOption/1064576536", "name": "Tint", "values": [ "Blue", "Red" ], "position": 1, "optionValues": [ { "name": "Blue", "hasVariants": true }, { "name": "Red", "hasVariants": true } ] }, { "id": "gid://shopify/ProductOption/1064576535", "name": "Size", "values": [ "Small", "Medium" ], "position": 2, "optionValues": [ { "name": "Small", "hasVariants": true }, { "name": "Medium", "hasVariants": true } ] } ], "variants": { "nodes": [ { "id": "gid://shopify/ProductVariant/1070325117", "title": "Blue / Small", "selectedOptions": [ { "name": "Tint", "value": "Blue" }, { "name": "Size", "value": "Small" } ] }, { "id": "gid://shopify/ProductVariant/1070325118", "title": "Red / Medium", "selectedOptions": [ { "name": "Tint", "value": "Red" }, { "name": "Size", "value": "Medium" } ] } ] } } } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!]) { productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete) { userErrors { field message code } product { options { name linkedMetafield { namespace key } optionValues { name linkedMetafieldValue } } } } }\",\n \"variables\": {\n \"productId\": \"gid://shopify/Product/1072481065\",\n \"option\": {\n \"id\": \"gid://shopify/ProductOption/1064576528\"\n },\n \"optionValuesToAdd\": [\n {\n \"linkedMetafieldValue\": \"gid://shopify/Metaobject/971662473\"\n }\n ],\n \"optionValuesToUpdate\": [\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054672281\",\n \"linkedMetafieldValue\": \"gid://shopify/Metaobject/971662474\"\n }\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!]) {\n productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete) {\n userErrors {\n field\n message\n code\n }\n product {\n options {\n name\n linkedMetafield {\n namespace\n key\n }\n optionValues {\n name\n linkedMetafieldValue\n }\n }\n }\n }\n }`,\n \"variables\": {\n \"productId\": \"gid://shopify/Product/1072481065\",\n \"option\": {\n \"id\": \"gid://shopify/ProductOption/1064576528\"\n },\n \"optionValuesToAdd\": [\n {\n \"linkedMetafieldValue\": \"gid://shopify/Metaobject/971662473\"\n }\n ],\n \"optionValuesToUpdate\": [\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054672281\",\n \"linkedMetafieldValue\": \"gid://shopify/Metaobject/971662474\"\n }\n ]\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!]) {\n productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete) {\n userErrors {\n field\n message\n code\n }\n product {\n options {\n name\n linkedMetafield {\n namespace\n key\n }\n optionValues {\n name\n linkedMetafieldValue\n }\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"productId\": \"gid://shopify/Product/1072481065\",\n \"option\": {\n \"id\": \"gid://shopify/ProductOption/1064576528\"\n },\n \"optionValuesToAdd\": [{\"linkedMetafieldValue\"=>\"gid://shopify/Metaobject/971662473\"}],\n \"optionValuesToUpdate\": [{\"id\"=>\"gid://shopify/ProductOptionValue/1054672281\", \"linkedMetafieldValue\"=>\"gid://shopify/Metaobject/971662474\"}]\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!]) {\n productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete) {\n userErrors {\n field\n message\n code\n }\n product {\n options {\n name\n linkedMetafield {\n namespace\n key\n }\n optionValues {\n name\n linkedMetafieldValue\n }\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"productId\" => \"gid://shopify/Product/1072481065\",\n \"option\" => [\n \"id\" => \"gid://shopify/ProductOption/1064576528\",\n ],\n \"optionValuesToAdd\" => [{\"linkedMetafieldValue\"=>\"gid://shopify/Metaobject/971662473\"}],\n \"optionValuesToUpdate\" => [{\"id\"=>\"gid://shopify/ProductOptionValue/1054672281\", \"linkedMetafieldValue\"=>\"gid://shopify/Metaobject/971662474\"}],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!]) {\n productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete) {\n userErrors {\n field\n message\n code\n }\n product {\n options {\n name\n linkedMetafield {\n namespace\n key\n }\n optionValues {\n name\n linkedMetafieldValue\n }\n }\n }\n }\n }`,\n {\n variables: {\n \"productId\": \"gid://shopify/Product/1072481065\",\n \"option\": {\n \"id\": \"gid://shopify/ProductOption/1064576528\"\n },\n \"optionValuesToAdd\": [\n {\n \"linkedMetafieldValue\": \"gid://shopify/Metaobject/971662473\"\n }\n ],\n \"optionValuesToUpdate\": [\n {\n \"id\": \"gid://shopify/ProductOptionValue/1054672281\",\n \"linkedMetafieldValue\": \"gid://shopify/Metaobject/971662474\"\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation updateOption($productId: ID!, $option: OptionUpdateInput!, $optionValuesToAdd: [OptionValueCreateInput!], $optionValuesToUpdate: [OptionValueUpdateInput!], $optionValuesToDelete: [ID!]) {\n productOptionUpdate(productId: $productId, option: $option, optionValuesToAdd: $optionValuesToAdd, optionValuesToUpdate: $optionValuesToUpdate, optionValuesToDelete: $optionValuesToDelete) {\n userErrors {\n field\n message\n code\n }\n product {\n options {\n name\n linkedMetafield {\n namespace\n key\n }\n optionValues {\n name\n linkedMetafieldValue\n }\n }\n }\n }\n}"
input: { "productId": "gid://shopify/Product/1072481065", "option": { "id": "gid://shopify/ProductOption/1064576528" }, "optionValuesToAdd": [ { "linkedMetafieldValue": "gid://shopify/Metaobject/971662473" } ], "optionValuesToUpdate": [ { "id": "gid://shopify/ProductOptionValue/1054672281", "linkedMetafieldValue": "gid://shopify/Metaobject/971662474" } ] }
response: { "data": { "productOptionUpdate": { "userErrors": [], "product": { "options": [ { "name": "Color", "linkedMetafield": { "namespace": "shopify", "key": "color-pattern" }, "optionValues": [ { "name": "White", "linkedMetafieldValue": "gid://shopify/Metaobject/971662474" }, { "name": "Blue", "linkedMetafieldValue": "gid://shopify/Metaobject/971662472" }, { "name": "Yellow", "linkedMetafieldValue": "gid://shopify/Metaobject/971662473" } ] } ] } } } }