Can GraphQL be used to create new products and their variants?

Topic summary

Issue: Users are encountering errors when attempting to create products with multiple variants using Shopify’s GraphQL productVariantsBulkCreate mutation.

Error Details:

  • The mutation returns: “The option doesn’t exist”
  • Error occurs when trying to create variants with option values (e.g., Color: Red, Material: Silk)
  • Problem persists in API version 2024-04

Attempted Solutions:

  • Following official Shopify documentation examples
  • Trying different approaches including adding "strategy": "REMOVE_STANDALONE_VARIANT"
  • None have resolved the issue

Current Status: The discussion remains unresolved with multiple users experiencing the same problem. No working solution or explanation has been provided yet for why the documented approach fails.

Summarized with AI on November 9. AI used: claude-sonnet-4-5-20250929.

Hi there!,

I’m trying to create new products and variants using GraphQl. I’ve tried different approaches using the examples given by the Shopify docs but I received an error as output. These are the examples we’ve used and the error. Any ideas ?

What we are trying to do is create a product and all its variants. Is it possible ?

Thank you in advance

mutation productVariantsBulkCreate($productId: ID!, $variants: [ProductVariantsBulkInput!]!) {
  productVariantsBulkCreate(productId: $productId, variants: $variants) {
    userErrors {
      field
      message
    }
    product {
      id
      options {
        id
        name
        values
        position
        optionValues {
          id
          name
          hasVariants
        }
      }
    }
    productVariants {
      id
      title
      selectedOptions {
        name
        value
      }
    }
  }
}
{
  "productId": "gid://shopify/Product/8332936610007",
  "variants": [
    {
      "optionValues": [
        {
          "name": "Red",
          "optionName": "Color"
        },
        {
          "name": "Brand new style",
          "optionName": "Brand and Style"
        },
        {
          "name": "Silk",
          "optionName": "Material"
        }
      ],
      "price": 22
    }
  ]
}
{
  "errors": [
    {
      "message": "The option doesn't exist",
      "locations": [
        {
          "line": 2,
          "column": 3
        }
      ],
      "path": [
        "productVariantsBulkCreate"
      ]
    }
  ],
  "data": {
    "productVariantsBulkCreate": null
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 13,
      "actualQueryCost": 10,
      "throttleStatus": {
        "maximumAvailable": 2000,
        "currentlyAvailable": 1924,
        "restoreRate": 100
      }
    }
  }

We’re following the examples in this part of the docs:

https://shopify.dev/docs/api/admin-graphql/2024-04/mutations/productVariantsBulkCreate#examples-Create_product_variants_using_existing_and_new_option_values

1 Like

Hi Omar Hernandez,

I have the same problem with version 2024-04.. any solution?
even adding: “strategy”: “REMOVE_STANDALONE_VARIANT”

Thank’s