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?