Using GraphQL's `productOptionsCreate` only adds the first option in `option.values`

Hey everyone,

I’m currently experimenting ways to optimize cost in our API that creates Shopify products externally.

I’m looking at the productOptionsCreate mutation but as I experimented on it by adding an option with multiple values, it creates the optionValues successfully, but when I look at options.values it only contains the first created option.

e.g.

  • I use productOptionsCreate to create an option named Size and add S, M, and L as values
  • The created options will look like this:
options: {
  values: [ "S"],
  optionValues: [{name: "S"}, {name: "M"}, {name: "L"}]
}

Is this a bug? Or does this mean I have to manually add the other options to the options.values field? That seems too much of a hassle and a waste of another call…

I am experiencing the same issue, while using productcreate mutation

Hey folks - from digging into this, it does seem that this is not a bug, but an intentional way that the API is set up. When creating a product option with multiple values, the optionValues field will correctly list all the values you specified, but the values field only includes the first value.

but we want all values to be added

@Liam-Shopify we are experiencing the same issue: this is the GraphQL call I’m sending:

{
“query”: “mutation { productCreate(product: {title: "Test GRAPHQL bis", productOptions: [{name: "Colore", values: [{name: "Rosso"}, {name: "Blu"}]}, {name: "Taglia", values: [{name: "S"}, {name: "L"}]}, {name: "Fit", values: [{name: "Regular"}, {name: "Slim"}, {name: "Tailored"}]}]}) { product { id } userErrors { field message } } }”
}

but in the administration page all I see is this:

I also tried running this query

{
“query”: “query ProductMetafields($ownerId: ID!) { product(id: $ownerId) { options { name values } } }”,
“variables”: {
“ownerId”: “gid://shopify/Product/MY_PRODUCT_ID”
}
}

and this was the result

{
“data”: {
“product”: {
“options”: [
{
“name”: “Colore”,
“values”: [
“Rosso”
]
},
{
“name”: “Taglia”,
“values”: [
“S”
]
},
{
“name”: “Fit”,
“values”: [
“Regular”
]
}
]
}
},
“extensions”: {
“cost”: {
“requestedQueryCost”: 2,
“actualQueryCost”: 2,
“throttleStatus”: {
“maximumAvailable”: 20000.0,
“currentlyAvailable”: 19998,
“restoreRate”: 1000.0
}
}
}
}


Hi @bm-electa

Only the first value per option is used to create a single default variant, and in your case that single variant is something like Rosso / S / Regular. Other values (Blu, L, Slim, Tailored) exist as potential option values but no variants use them yet, so they don’t appear in options.values; they would appear under optionValues if you requested that field.

When you pass productOptions into productCreate, You’re defining the set of possible option values per option. Shopify then creates one default variant using the first value of each option:

  • Colore = Rosso
  • Taglia = S
  • Fit = Regular

It does not automatically create all combinations of variants (e.g., Rosso / S / Slim, Blu / L / Tailored, etc.). That’s why you only see the first value on the admin and in options.values: those are the values currently in use by at least one variant.

If you want to verify that all your values (e.g. Blu, L, Slim, Tailored) are registered as possible values on the product, you should query optionValues as well as values.

Here is a validated query you can run to inspect the product’s options after creation:

query ProductOptionsAndVariants($id: ID!) {
  product(id: $id) {
    id
    options {
      name
      values
      optionValues {
        name
        hasVariants
      }
    }
    variants(first: 10) {
      nodes {
        id
        title
        selectedOptions {
          name
          value
        }
      }
    }
  }
}

It sounds like you want to have all combinations of those options as variants, so you’ll need to explicitly create the variants yourself. There are two common approaches:

  1. Create the product with options only, then use a separate mutation to add variants (e.g., productVariantsBulkCreate).
  2. Or, create the product first, then call productOptionsCreate etc. if you’re doing more advanced option management.