I am encountering an issue while using GraphQL to create and assign metafields to products in my Shopify store. Specifically, the problem arises when I attempt to assign a list of metafields of the type ‘single_line_text_field’.
Here’s a brief overview of the situation:
1. Issue Description:
- When assigning a list of ‘single_line_text_field’ metafields to products, the API’s response indicates success (no errors are reported, and it returns the data I submitted).
- However, upon checking the product’s metafields page in the Shopify admin, the metafields I attempted to post are not visible.
2. GraphQL Query Used:
I am attaching the exact GraphQL query I used for this operation. Note that I am using the “list.” + “single_line_text_field” as explained in the documentation
shopify.GraphQL().execute(
query="mutation metafieldsSet($metafields: [MetafieldsSetInput!]!) {
metafieldsSet(metafields: $metafields) {
metafields {
key,
namespace,
value
}
userErrors {
field
message
}
}
}",
variables={
"metafields": [
{
{
"key": "gender",
"namespace": "XXXXX",
"ownerId": "gid://shopify/Product/XXXXXXXXXXXXX",
"type": "list.single_line_text_field",
"value": "[\\"Female\\", \\"Male\\"]"
}
}
]
}
)
3. API Response Received:
The response from the API was as follows:
{
"data": {
"metafieldsSet": {
"metafields": [
{
"key": "gender",
"namespace": "XXXXXX",
"value": "[\"Female\",\"Male\"]"
}
],
"userErrors": []
}
},
"extensions": {
"cost": {
"requestedQueryCost": 10,
"actualQueryCost": 10,
"throttleStatus": {
"maximumAvailable": 1000.0,
"currentlyAvailable": 990,
"restoreRate": 50.0
}
}
}
}
4. Shopify backoffice
The metafiled definition is created but there is no values inside,
Is this issue a bug in the API, or am I not using the API properly?
Thanks in advanced

