Allow QueryWithVars with a list as argument instead of a map

Moved from GitHub dgo/127

Posted by blasrodri:

QueryWithVars allows adding a map of variables that will be interpolated into the query. But this is not sufficient for functions that are variadic (i.e. uid).


Add QueryWithListVars, which allows including a slice of elements instead of a map.

My current workaround is:

q := fmt.Sprintf(`
	query {
		getNodes(func: uid(%s)){
	`,strings.Join(listUids, ","))
	res, err := txn.Query(ctx, q)

And it would be nice to have

q := `
	query getNodesFunc($listUids: []string){
		getNodes(func: uid($listUids)){
	res, err := txn.QueryWithList(ctx, q, map[string]string{"$listUids": listUids})

parasssh commented :

are suggesting a
map[string][]string // map from string to a slice of strings
instead of the current
map[string]string // map from string to string ?

parasssh commented :

Looked a bit more. These Vars are evaluated by the parser on the server alpha side. As such, we would need to make changes on both the dgo as well as alpha dgraph side.

blasrodri commented :

@parasssh thanks for coming back! Is this a big change? I would like to help to make it happen :slight_smile:

parasssh commented :

Thanks for offering to help

I don’t think it is trivial as it mucks with the parser. Let’s start with you creating an issue on GitHub at so it goes through our pipeline and prioritization.