How can I match products and metafields?

Hi,

I have a question about metafield translation.

I retrieve translations for a resource type and locale using your document that is https://shopify.dev/api/examples/i18n-app-translations#retrieve-translations-for-a-resource-type-and-locale.

I create a query as below;
{
translatableResources(first: 200, resourceType: METAFIELD) {
edges {
node {
resourceId
translatableContent {
key
value
digest
locale
}
translations(locale: “en”) {
key
value
locale
}
}
}
}
}

I have a response that like below;
{
“data”: {
“translatableResources”: {
“edges”: [
{
“node”: {
“resourceId”: “gid://shopify/Metafield/1234567890”,
“translatableContent”: [
{
“key”: “value”,
“value”: “xxxx”,
“digest”: “11111”,
“locale”: “fr”
}
],
“translations”: [{
“locale”: “en-US”,
“key”: “xxxx”,
“value”: “YYYY”
}]
},

}
]
}
},
“extensions”: {

}
}

However, I couldn’t find a product id for matching products and metafields. How can I match products and metafields?

Hi,

You need to use the resourceId for the translated metafield value (“gid://shopify/Metafield/1234567890”) in a new query for the Metafield object. If you ask for the owner field on that Metafield you’ll get back the Product object.

https://shopify.dev/api/admin-graphql/2021-10/objects/Metafield#fields-Metafield-OBJECT