diggy
(Dgraph Bot)
1
Moved from GitHub dgo/7
Posted by AlexandreRoba:
Hi,
I’ve tried to perform a query which returns localized fields. I would like to pass the localization as variables such as:
var variables = map[string]string{
"$local":"en:fr:.",
}
const q = `
{
items(func: has(item)){
id: uid
short_description: title@$local.
long_description: description@$local.
}
}
`
response, err := txn.QueryWithVars(ctx, q,variables)
I’m getting a lexical error when I try this.
It would make sense to be able to query with a local as variable
diggy
(Dgraph Bot)
2
manishrjain commented :
Can you please file this in Dgraph?
diggy
(Dgraph Bot)
3
srfrog commented :
also, how about using this instead:
var variables = map[string]string{
"$local":"en:fr:.",
}
const q = `
{
items(func: has(item)){
id: uid
short_description: title@%[1]s.
long_description: description@%[1]s.
}
}
`
response, err := txn.QueryWithVars(ctx, fmt.Sprintf(q, variables["$local"]))
diggy
(Dgraph Bot)
4
srfrog commented :
Dgraph feature, closing here.