Hi,
I encountered an issue when using the productSet
mutation in Shopify’s GraphQL Admin API to create a custom product metafield of type list.single_line_text_field
. The mutation succeeds, but when I go in the unstructured fields section and try to add it to my definitions, it allows me to select single_line_text_field
but it doesn’t recognize it as a list even if my value is a JSON array, making it unusable for storefront filtering.
Is there a reason why this wouldn’t work?
I am using the latest api 2025-01
.
Here is my sample mutation.
mutation createProductAsynchronous($productSet: ProductSetInput!, $synchronous: Boolean!) {
productSet(synchronous: $synchronous, input: $productSet) {
product {
id
}
productSetOperation {
id
status
userErrors {
code
field
message
}
}
userErrors {
code
field
message
}
}
}
{
"synchronous": true,
"productSet": {
"status": "DRAFT",
"title": "test K",
"metafields": [
{
"key": "test",
"namespace": "custom",
"type": "list.single_line_text_field",
"value": "[\"Interior\", \"Exterior\"]"
}
]
}
}
If I manually create the metafield definition and then run this mutation, it will work fine.
Any help is appreciated.