Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

'Invalid Value' Error when Setting Status to "ACTIVE" in New Product Creation via API

'Invalid Value' Error when Setting Status to "ACTIVE" in New Product Creation via API

shmuel
Shopify Partner
2 0 0

I am working on a feature to create new products in a Shopify environment using GraphQL. While trying to create a product using a mutation, I encountered an unexpected error related to the 'status' field. Even though I've verified that "ACTIVE" is a valid enum value, I'm still receiving an error. 

When I run the following GraphQL mutation:

mutation {
  productCreate(input: {
    title: "DRAWER HUTCH TOWER",
    status: "ACTIVE",
    // ... other options
  })
}

I get this error:

{
    "errors": [
        {
            "message": "Argument 'status' on InputObject 'ProductInput' has an invalid value (\"ACTIVE\"). Expected type 'ProductStatus'.",
            // ...
        }
    ]
}

 

To make sure "ACTIVE" is indeed a valid value, I queried the ProductStatus enum:

 

 

{
  __type(name: "ProductStatus") {
    enumValues {
      name
    }
  }
}

And received:

{
    "data": {
        "__type": {
            "enumValues": [
                {"name": "ACTIVE"},
                {"name": "ARCHIVED"},
                {"name": "DRAFT"}
            ]
        }
    },
    // ...
}

This clearly shows that "ACTIVE" is a valid value, so why am I getting this error?

 

Replies 4 (4)

gsmaverick
Shopify Partner
21 3 4

You probably need to update your URL to explicitly include an API version, see this post for more details: https://community.shopify.com/c/graphql-basics-and/passing-an-enum-in-graphql-variable/m-p/1134872/h...

shmuel
Shopify Partner
2 0 0

I still get the same error event using explicit version, this is the link I have used

https://example.myshopify.com/admin/api/2023-07/graphql.json

 

aratot
Shopify Partner
2 0 0

Did you found a solution for this issue?
I have the same problem with GraphQL mutation: I can't change the product status ACTIVE/ARCHIVED.
(Error: Expected type 'ProductStatus'.)

If you found the solution, please write!

aratot
Shopify Partner
2 0 0

I have found the solution:
This is the correct syntax:     ... , status: ACTIVE }
instead of this:            ...  , status: "ACTIVE" }

Thanks to: shopify-graphiql-app !