GraphQL - Issue Creating Multiple Options on Initial Product Creation

Trying to create Products with multiple options.

Here is the query I am running in postman on the 2024-07 Endpoint

{
  "query": "mutation createProduct($input: ProductInput!) { productCreate(input: $input) { product { id title options { id name values } } userErrors { field message } } }",
  "variables":{
  "input": {
    "title": "Test Item",
    "vendor": "XXX",
    "status": "DRAFT",
    "productOptions": [
      {
        "name": "Size",
        "values": [
          { "name": "Large" },
          { "name": "Small" }
        ]
      },
      {
        "name": "Lens Type",
        "values": [
          { "name": "Polarized" }
        ]
      }
    ]
  }
}


}

The issue I’m seeing is that only the first of each option type is being created. So in this case only the ‘Large’ size is being created.

I know I could go in and add the options in a separate call but that seems illogical for our integration.

How can I make the mutation work as desired?

Are you saying only the first choice in the options are being created?

So Size Large and Lens Type Polarized? Or only The Size option set?

Only the first choice for each option!

So Large and Polarized are both being created. Small is not

Strange. I ran it with productCreate and it worked but when you go in the admin you don’t see it. Probably some way to see them as you get ids back

t

I know only creates one variant so I immediately run the query to add the variants with the values I created. So maybe that’s just what you need to do?

I did confirm when I query it back to get the product the options are there. They just don’t display without variants (my guess as to what your seeing)

Thanks for testing that. When I submit the exact query I posted in my original issue this is the response I get: Is there something different you did in your createProduct mutation that enabled you to get the large/small values for the Size Option to both show up in the results body?

No, I used your exact data. My graphql query was a bit different and ran against the 2025-01 version. So maybe the query difference is what returns the different data.

mutation productCreate($input: ProductCreateInput!) {
  productCreate(product: $input) {
    product {
      id
      title
      description
      handle
      options {
        id
        name
        position
        optionValues {
          id
          name
          hasVariants
        }
      }
      variants(first: 250) {
        edges {
          node {
            id
            title
            price
            sku
          }
        }
      }
    }
    userErrors {
      field
      message
    }
  }
}