Solved

List of single line text fields posted OK but not visible

Stock23
Shopify Partner
4 1 0

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, 
Screenshot 2023-12-11 at 12.56.05.pngScreenshot 2023-12-11 at 12.56.20.png

 

 

Is this issue a bug in the API, or am I not using the API properly?

 

Thanks in advanced

Accepted Solution (1)

Stock23
Shopify Partner
4 1 0

This is an accepted solution.

Después de 2 días se solucionó el problema. Puedo pensar que mis llamadas iniciales generaron algun tipo de métrica interna que el equipo de Shopify solucionó rápidamente, ya que el problema ha desaparecido haciendo exactamente la misma batería de tests por mi parte. Marco el issue como solucionado.

View solution in original post

Replies 6 (6)

Liam
Shopify Staff
2731 302 777

Hi Stock23,

 

If you navigate to the product that you're looking to add a metafield value for on the admin, are you seeing the value that you are passing through the mutation appearing? (You should see it on the bottom of the product page, rather than on the metafield setting page). 

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Stock23
Shopify Partner
4 1 0

Hi Liam,

 

I don't see it because it is not pinned, that's why I took the screenshot from the setting page. Do you think that pinning a metafield could affect on that?

 

Thanks for the support!

 

Liam
Shopify Staff
2731 302 777

Do you see it if you click on "Show all" on the product page > metafields section?

Liam | Developer Advocate @ Shopify 
 - Was my reply helpful? Click Like to let me know! 
 - Was your question answered? Mark it as an Accepted Solution
 - To learn more visit Shopify.dev or the Shopify Web Design and Development Blog

Stock23
Shopify Partner
4 1 0

Yes, I see there the metafield "Gender", but without values. The screenshots above of the point 4 show exactly this section (with spanish interface).

Stock23
Shopify Partner
4 1 0

This is an accepted solution.

Después de 2 días se solucionó el problema. Puedo pensar que mis llamadas iniciales generaron algun tipo de métrica interna que el equipo de Shopify solucionó rápidamente, ya que el problema ha desaparecido haciendo exactamente la misma batería de tests por mi parte. Marco el issue como solucionado.

JurieW
Shopify Partner
1 0 0

I am experiencing the same issue as described. The solution seems to indicate that this was fixed internally by shopify, but it seems it may not have been. Would appreciate any guidance or support. @Liam