productOptionsCreate mutation creates only 1 option value

Hello ,

I’m a little bit stuck on this and I’ll really appreciate your help.
I try to create an option with multiple values, using the mutation productOptionsCreate.
Whatever I do, it only creates one option (the first one : Yellow). When I check the specs, values is indeed an array.
https://shopify.dev/docs/api/admin-graphql/latest/mutations/productoptionscreate

Your help will be greatly appreciated. :grinning_face:

mutation AddOptions {
  productOptionsCreate(
    options: {name: "myColors", values:   [
        {
          name: "Yellow"
        },
        {
          name: "Red"
        }
    ]},
    productId: "gid://shopify/Product/14843488108876"
  ) {
    product {
      options {
        id
        name
        values
      }
    }

Thanks a lot !

Thanks a lot for your very fast reply ! I tried this on GraphiQL and I think it’s not working because values expects an OptionValueCreateInput datatype.
Did you tried that by yourself on GraphiQL. Thx again :-).

And there is an exemple of multiple name (for value), here https://shopify.dev/docs/api/admin-graphql/latest/mutations/productoptionupdate.
Apparently it’s not working with the create :slightly_smiling_face:

Hi @jaadtoly

If you’re open to trying an app instead of working with the code, you can check out Easify Product Options. It lets you create product options with multiple values easily—no coding needed. Might save you some time. Here’s an example of a product that has a lot of options:

  • This is the result:

  • This is the app setting:

This app is easy to use, and I highly recommend giving it a try. If you need any help, feel free to ask or contact Easify!

Thanks a lot for the info, but that’s not applicable in my case, as I develop a full nodejs app. I’ll try with productOptionUpdate (optionValuesToAdd). Apparently there is a bug with productOptionsCreate.

Have a lovely day

1 Like

Can you help me with the same issue?

I am developing an app that creates products using mutations in Shopify. I have successfully created the product creation and media creation APIs, but I am currently encountering errors while creating the variants.

When I attempt to create variants, I receive an error saying “no options exist.” And, when I try to add options before creating variants, it only generates the first option.

Hi Aima,

I didn’t tried yet, but my next try will be a call to the mutation ProductSet. Apparently with that mutation, you can create the product, images, variants, options, etc.. in 1 (asynchronous) call. No need to call one mutation for the product, one for the variant, one for the options, etc… Give it a try and tell me if it works. :grinning_face:

1 Like

Yes, ProductSet mutation is working, Thank you

1 Like