We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

translatableResource for Article Metafield is null

Solved

translatableResource for Article Metafield is null

redochkaya
Shopify Partner
20 0 1

Trying to retrieve translatableResource for Article Metafield is returning null.

 

query {
  translatableResource(resourceId: "gid://shopify/Metafield/22357251096634") {
    resourceId
    translatableContent {
      key
      value
      digest
      locale
    } 
  }
}

The gid://shopify/Metafield/22357251096634 is correct as it's returned by the REST API.

 

The graphql request is returning:

 

{
    "data": {
        "translatableResource": null
    },
    "extensions": {
        "cost": {
            "requestedQueryCost": 2,
            "actualQueryCost": 1,
            "throttleStatus": {
                "maximumAvailable": 1000.0,
                "currentlyAvailable": 999,
                "restoreRate": 50.0
            }
        }
    }
}

 

Strangely, the Shopify app (Translate & Adapt) seems to be able to translate the article metafields. 

 

I had a similar issue previously with product handle and it was indeed a bug in Shopify API. (see https://community.shopify.com/c/products-variants-and/how-to-localize-the-product-handle-by-using-gr...)

Accepted Solution (1)
richbrown_staff
Shopify Staff
654 97 176

This is an accepted solution.

In short: query the article not the metafield. E.g. this is the SEO field on the article, where the data is stored on the metafield, but it acts like another field on the Article model. So translation wise, this is only translatable as a field on the Article object. We recognise it’s confusing if you're querying directly with an ID, but it’s not a bug as such:

image (85).png

To learn more visit the Shopify Help Center or the Community Blog.

View solution in original post

Replies 6 (6)

redochkaya
Shopify Partner
20 0 1

Dear shopify team, any help with this? 

richbrown_staff
Shopify Staff
654 97 176

Hi @redochkaya from the team behind Translate & Adapt and store localization at Shopify. Could you help me understand more specifically what you're aiming to do here (perhaps by video or screenshots) - is this with respect to translated content or content in the default language? Thanks

To learn more visit the Shopify Help Center or the Community Blog.

richbrown_staff
Shopify Staff
654 97 176

This is an accepted solution.

In short: query the article not the metafield. E.g. this is the SEO field on the article, where the data is stored on the metafield, but it acts like another field on the Article model. So translation wise, this is only translatable as a field on the Article object. We recognise it’s confusing if you're querying directly with an ID, but it’s not a bug as such:

image (85).png

To learn more visit the Shopify Help Center or the Community Blog.

Dalmas
Shopify Partner
1 0 0

Could you please clarify? I'm having the same problem as OP and I can't figure out how to get this to work.

I have added a product metafield, but neither:

translatableResource(resourceId: "gid://shopify/Metafield/xxxxxxxxxxx")

nor

translatableResource(resourceId: "gid://shopify/Product/yyyyyyyyyy")

... works as expected. Querying by metafield returns null, and when querying by product the metafield is not included in the list of translatable keys/values.

 

redochkaya
Shopify Partner
20 0 1

As @richbrown_staff explained, meta title and meta description are special metafields. To query their translatable resource respectively, you can not target them directly. Instead you need to target the resource owning them (in your case: gid://shopify/Product/yyyyyyyyyy) then filter the response based on the key: meta_title or meta_description

redochkaya
Shopify Partner
20 0 1

@richbrown_staff thanks for the solution. If you can have a look at this issue, that would be great: https://community.shopify.com/c/shopify-apps/translatablecontent-is-an-empty-array/td-p/2995247