Fetch Translated Products in a Single GraphQL Query

Hi everyone,

We want to fetch products translated into a specific language directly through the Products GraphQL query in a single call, rather than making a separate GraphQL query to fetch translations.

I tried using @inContext(language: FR, country: FR) in the query, but it returned an error.

curl:
curl --location '``https://xxx.myshopify.com/admin/api/2027-01/graphql.json``'
--header 'Content-Type: application/json'
--header 'X-Shopify-Access-Token: shpat_'
--data-raw '{"query":"query @inContext(language: FR) { products(first: 2) { edges { node { id title descriptionHtml } } } }","variables":{}}'

error:

Is there an alternative way to retrieve translated product details directly within the Products query itself, in a single API call, without making a separate GraphQL request for translations?

Any help or suggestions would be greatly appreciated!

Hi @shravan_das, that error is expected. @inContext is a Storefront API directive, and it isn’t defined in the Admin GraphQL schema, so the admin endpoint rejects it at any API version.

You can still get everything in one Admin query by selecting the translations field on each product.

query ProductsWithFrench {
  products(first: 2) {
    nodes {
      id
      title
      descriptionHtml
      translations(locale: "fr") {
        key
        value
        outdated
      }
    }
  }
}

This returns key/value pairs (title, body_html, and so on) that you map onto the base fields yourself. Add marketId to translations if you need market-specific content. The Translation object documents the fields, and the translations guide walks through the full setup.

If this is for a storefront-facing experience, the Storefront API supports exactly what you tried. With query @inContext(language: FR) { products { nodes { title descriptionHtml } } } those fields come back already translated. It only returns products published to the channel and market you query, so results can differ from the Admin API.

Hi Donal, thanks for the reply!

Would it be possible to include the translations directly in the response fields themselves, such as title, description, html, and productType, instead of returning them separately in a translations array?

For example, having the French text directly in the title and description fields of each product rather than in a separate field (translations array) with key: title and value: French text.

Hi @shravan_das, short answer is no. The Admin API won’t put translated values into title, descriptionHtml, or productType itself. Those fields always return the base values, and translations stay in the separate translations field.

You can shape that output in your app instead. Take the translations(locale: "fr") results from the same query, overlay title → title, body_html → descriptionHtml, and product_type → productType, then drop the array from your own response. The translatableResources examples show which keys exist per resource. If a key has no translation for that locale, keep the base value as your fallback. If you want a plain-text description, derive it from the translated body_html rather than copying the markup in.

If this is for a buyer-facing experience, the Storefront API with @inContext returns title and descriptionHtml already translated in one call. productType isn’t in its documented translatable fields, so don’t count on that one coming back localized.