Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Get Metafield translation with graphql api

Get Metafield translation with graphql api

antonioreale
Shopify Partner
19 1 3

Hello How can I get metafield definition translation with graphql api?

The code:

query ($first: Int, $filter: String)
            { productVariants(first:$first, query:$filter) {
                edges {
                node {
                    displayName
                    title
                    id
                    sku
es:translations (locale: "es"){ key locale value } product { id title description es:translations (locale: "es"){ key locale value } } inventoryItem { id } } } } }

 Output:

    "data": {
        "productVariants": {
            "edges": [
                {
                    "node": {
                        "displayName": "Dissipatore Cpu Acqua Mag Coreliquid V2 Msi - 3",
                        "title": "3",
                        "id": "gid://shopify/ProductVariant/xxxx",
                        "sku": "MSIDCORELIQUID360RV2",
                        "es": [],
                        "product": {
                            "id": "gid://shopify/Product/xxxx",
                            "title": "Dissipatore Cpu Acqua Mag Coreliquid V2 Msi",
                            "description": "Dissipatore Cpu Acqua Mag Coreliquid V2 Msi",
                            "es": [
                                {
                                    "key": "body_html",
                                    "locale": "es",
                                    "value": "<p> <strong>Enfriador de CPU Msi Water Mag Coreliquid V2<br></strong></p>\n\n<p></p>"
                                },
                                {
                                    "key": "title",
                                    "locale": "es",
                                    "value": "Enfriador de CPU Msi Water Mag Coreliquid V2"
                                }
                            ]
                        },
                        "inventoryItem": {
                            "id": "gid://shopify/InventoryItem/xxxx"
                        }
                    }
                }
            ]
        }
    },
    "extensions": {
        "cost": {
            "requestedQueryCost": 7,
            "actualQueryCost": 7,
            "throttleStatus": {
                "maximumAvailable": 1000.0,
                "currentlyAvailable": 993,
                "restoreRate": 50.0
            }
        }
    }
}
Replies 3 (3)

ShopifyDevSup
Shopify Staff
1453 238 527

Hey @antonioreale thanks for reaching out- if the metafields are publicly available and the translations have been created, you should be able to query them using the methods outlined here in our dev docs. This example query should be what is required if you needed to pull ES-localized metafields though:

{
 translatableResources(first: 1, resourceType: METAFIELD) {
   edges {
     node {
       translations (locale:"er") {
         value
       }
       resourceId
       translatableContent {
         key
         value
         digest
         locale
       }
     }
   }
 }
}

Hope this helps - let us know we can clarify anything further on our end. 

Al | Shopify Developer Support

Developer Support @ Shopify
- Was this reply helpful? Click Like to let us 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

antonioreale
Shopify Partner
19 1 3

Can I call it inside the productVariants query?

alejandro-vice
Shopify Partner
1 0 0

Hi, were you able to do so ?