Using the @lang field in Slash GraphQL

I am exploring how to implement multi-language strings as this is a big part of my database. I have come across the Get Started with Dgraph - Multi-language strings tutorial which shows a nice solution to this.

I am new to creating back end GraphQL schemas and Dgraph, soI likely have am missing some knowledge or have a misunderstanding of how this could work.

From what I can understand the @lang is a Dgraph specific directive and doesn’t belong to native GraphQL. With this in mind, is it possible to use the Lamdba functions to resolve a query that can use these Dgraph enhancements?

As a very basic example, I am trying to achieve the following:

type Entry  {
  id: ID! 
  title: String!
  description: String!
}

Where both title and description are multi-language fields. And to get the correct result I could query:

query MyQuery {
  getEntry(id: "123", lang: "en") {
    title
    description
  }
}

And in the lambda function it would return the correct title@en, description@en etc.

Is this possible?

Hi @charklewis, We are working on supporting multi-language fields in GraphQL and will have them soon.
We already have RFC for this feature [WIP]RFC: Allow language Tag support in GraphQl - #6 by amaster507

1 Like

Ah ok thanks! Is there a solution you recommend while waiting for this feature to be ready? I’m thinking at the moment use a schema that doesn’t have translations.

Is the feature close to being released?

We will add this by this month in master branch and it will be part of 21.07 release.
Sorry, currently there is no workaround for this. You have to use schema that doesn’t have multi language fields.

1 Like