A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
I'm trying to use the GraphQL API to translate a product metafield in Shopify. I'm currently using the following GraphQL mutation:
mutation translationsRegister($resourceId: ID!, $translations: [TranslationInput!]!) {
translationsRegister(resourceId: $resourceId, translations: $translations) {
userErrors {
message
field
}
translations {
key
value
}
}
}
Here are the variables I'm using:
"variables": map[string]interface{}{
"resourceId": fmt.Sprintf("gid://shopify/Product/%s", args.ProductID),
"translations": JSON{
"locale": args.Locale,
"key": args.Target,
"value": args.Translation,
"translatableContentDigest": fmt.Sprintf("%x", bs),
},
},
The query works well for translating fields like title and body_html, but I'm having trouble getting it to work for metafields.
Has anyone else encountered this issue or have any suggestions on how to make this work for metafields?
Thanks in advance for your help!
Hi there
is this helpful for you.
mutation {
translationsRegister(resourceId: "gid://shopify/Metafield/xxxxxx", translations: [
{
key: "namespace.key",
value: "translated value",
locale: "es",
translatableContentDigest: "digest_value"
}
]) {
userErrors {
message
field
}
translations {
locale
key
value
}
}
}