GraphQL product.options.optionValues returns more values than Shopify Admin shows

When querying a product via the Admin GraphQL API, product.options.optionValues
returns option values that have no corresponding variants

Product ID: 9100534612180 (Strong Tees)

The product has only 2 Theme variants: “Strong Tee 1” and “Strong Tee 2”

But product.options.optionValues returns 8 values for Theme:

  • Strong Tee 1
  • Strong Tee 2
  • My Therapist Loves These Socks ← no variants exist
  • I Chose Me ← no variants exist
  • Strong - Syle 1 ← no variants exist
  • Strong - Syle 2 ← no variants exist
  • Mentally Somewhere Sunny - Golden ← no variants exist
  • Mentally Somewhere Sunny - Coral ← no variants exist

You can verify this by querying the product (9100534612180) the 6 extra option values have no variants associated with them.

1 Like

Hi @Umid_Aydemir,

This is actually fully expected behaviour, as the Product Model has the Options and Option Values separate from the Variants.

Essentially you can create products with options and values first, with the productCreate API mutation, resulting in Option Values not connected to any Variants, then later you’d add the Variants that are associated with the Option Values with the productVariantsBulkCreate mutation.

This is described in more detail in the Shopify.dev documentation:

With the following caution message included in the Add product data doc:

Caution

Avoid leaving option values unused. Always create variants for all option values you define, or remove option values that you don’t need. Unused option values can cause confusion and unexpected behavior.