A space to discuss GraphQL queries, mutations, troubleshooting, throttling, and best practices.
Hi all!
I am trying to retrieve orders in multiple languages, for now it is possible to retrieve it in default langauge using:
'''
query {
products(first:1, after:null) {
edges {
cursor
node {
title
description
}
}
}
}
'''
But I can not seem to get it working for a different language, I have tried a lot and read about @inContext, but when I use that I get the error:
'''
query @inContext(language:"DE") {
products(first:1, after:null) {
edges {
cursor
node {
title
description
}
}
}
}
'''
{'errors': [{'message': 'Directive @inContext is not defined', 'locations': [{'line': 2, 'column': 7}], 'path': ['query'], 'extensions': {'code': 'undefinedDirective', 'directiveName': 'inContext'}}]}
I read somewhere that @inContext only works for Storefront API, is this true? And if so, how can I select a different language for my use case?
Thanks in advance!
Hey @WollyMeister
Here's an example of pulling out translations with the Admin API: https://shopify.dev/docs/api/admin-graphql/2023-07/queries/product#examples-Loading_translations_and...
Scott | Developer Advocate @ Shopify
Thanks for the reply, I managed to get it working.
However, I tried the same for productVariants, but that does not work... Is it not possible to retrieve productVariants in multiple languages?
Hey @WollyMeister!
Translations are also available on variants as well https://shopify.dev/docs/api/admin-graphql/2023-07/objects/ProductVariant#field-productvariant-trans...
Here's an example of an order query that will get the variant translations in German:
```{
order(id: "gid://shopify/Order/12345678910") {
lineItems(first: 10) {
nodes {
variant {
id
translations(locale: "de") {
key
value
}
}
}
}
}
}```
Hope that helps!
- Kyle G.
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
Thanks for the response?
I have a last question, is it possible to retrieve the default countryCode of a webshop using a query in graphql?
Hey @WollyMeister , yes, that's available in the ShopAddress object https://shopify.dev/docs/api/admin-graphql/2023-10/objects/ShopAddress#field-shopaddress-countrycode...
- Kyle G.
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