How can I get results in a specific language or in more than one language?
  • 29 Jun 2022
  • 1 Minute to read
  • Contributors
  • Dark
    Light

How can I get results in a specific language or in more than one language?

  • Dark
    Light

Article Summary

Use the "language switch" to request multi-language fields in a specific language or use aliases to get multiple languages at the same time.

Enforce a language

Some fields are multi-language. With (language: "de") directly behind the field you can request the German version.

query byText {
  utsearch(query: "weight") {
    content {
      code
      name(language: "de")
      description(language: "de")
    }
  }
}

You can spot multi-language fields easily in the built-in documentation -> eingebauten Dokumentation.

Multiple languages using aliases

In GraphQL, you can name fields by giving them an alias. This is always required when requesting the same field twice. In this example, we request the fields "name" and "description" twice: In English and German. Hence, we give the each of the fields an alias.

query byText {
  utsearch(query: "weight") {
    content {
      code
      name_de:        name       (language: "de")
      description_de: description(language: "de")
      name_en:        name       (language: "en")
      description_en: description(language: "en")
    }
  }
}

Was this article helpful?