API GraphQL ProductCreate with options error

AI-generated summary

A developer encounters an error when attempting to create a product with options using Shopify’s GraphQL productCreate mutation. The error indicates that the options field is being rejected with a type coercion issue: “Could not coerce value {name:“Size”,values:[“EACH”]} to String”.

Key Details:

  • The mutation includes product title, options (Size: EACH), variants with SKU/pricing/barcode, and custom metafields
  • Error suggests the options array structure may be incorrectly formatted or incompatible with the expected input type
  • Multiple variations of the options field have been attempted without success

Related Issues:

  • Another user reports similar problems creating products with multiple variants
  • A third user can create basic products (title, vendor, tags) but cannot include variant-specific details like SKU, price, cost, inventory, and barcode

Status: Unresolved. No solutions have been identified, and the discussion remains open with users seeking guidance on proper mutation syntax for product variants and options.

Trying to create new product with options. Get an error!
Tried different variations of “options”, still same error
Here is my mutation query:

{
“query” : “mutation productCreate($input: ProductInput!) { productCreate(input: $input) { product { metafields(first: 5) { edges { node { id namespace key value } } } id title description options(first: 25) { name values } variants(first: 25) { nodes { id sku price compareAtPrice selectedOptions { name optionValue { id name } } sku price taxable taxCode barcode weight weightUnit requiresShipping inventoryItem { harmonizedSystemCode } inventoryPolicy metafields(first: 5) { edges { node { id namespace key value } } } } } } } }”,
“variables” : {
“synchronous” : true,
“input” : {
“title” : “MOLLY Product 5.3”,
“options” : [
{
“name” : “Size”,
“values” : [“EACH”]
}
],
“variants” : [
{
“barcode” : “4447771111333-EACH”,
“sku” : “444888”,
“price” : 9.01,
“compareAtPrice” : 10.50,
“taxCode” : “MMM9966”
}
],
“metafields” : [
{
“namespace” : “custom”,
“key” : “ns_internalid”,
“value” : “731”,
“type” : “number_integer”
}
]
}
}
}
Error:
{“errors”:[{“message”:"Variable $input of type ProductInput! was provided invalid value for options.0 (Could not coerce value {name:"Size",values:["EACH"]}

“problems”:[{“path”:[“options”,0],“explanation”:“Could not coerce value {name:"Size",values:["EACH"]} to String”}]}}]

Were you able to find a solution? I am trying to create a product with multiple variants but the mutation is not working.

I am attempting to create a product without multiple variants. While I can successfully create a product with fields like title, vendor, tags, and status, I am unable to include and retrieve additional details such as SKU, price, cost, inventory, and barcode. If you know how to achieve this using the productCreate mutation, your guidance would be greatly appreciated. For more details: https://community.shopify.com/topic/2964382