sharonjl
(Sharon)
January 29, 2018, 7:24pm
1
How do I go about passing an array for a query variable?
q := `
query {
blogs(func: eq(blog.id, $id)){
expand(_all_)
}
}`
ids := []string{"1","2","3"}
resp, err := dg.NewTxn().QueryWithVars(ctx, q, map[string]string{"$id": ids})
if err != nil {
log.Fatal(err)
}
pawan
(Pawan Rawal)
January 29, 2018, 10:13pm
2
This is not supported yet. Please file an issue on Github and we can support it. As a workaround for now, you could pass an array with the values as part of the args.
q := `
query {
blogs(func: eq(blog.id, [1, 2, 3])){
expand(_all_)
}
}`
resp, err := dg.NewTxn().Query(ctx, q)
if err != nil {
log.Fatal(err)
}
system
(system)
Closed
February 28, 2018, 10:13pm
3
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.