Query variable value as array

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)
}

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)
}

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.