I am using GraphQL in my Node.js application. And I want to store an object that uses keys as a locale short code and values for the string in the corresponding language. (like { en: "Hello", ru: "Привет" }
etc.)
I want to represent this using GraphQL, both in input (like that):
mutation {
addExercise(name: { en: "Hello", ru: "Привет" })
}
and in output (like that)
{
exercises {
_id, name
}
}
(name
should return an object of key-value pairs:)
[
{_id: 1, name: { en: "Hello", ru: "Привет" }}
]
How can I do something like that?
I know I can store my data this way
{ name: "en", value: "Hello }`
but the previous one seems to be easier.