Skip to content

Allow QueryWithVars with a list as argument instead of a map #127

@blasrodri

Description

@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).

Proposal

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)){
			uid
		}
	}
	`,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)){
			uid
		}
	}
	`
	res, err := txn.QueryWithList(ctx, q, map[string]string{"$listUids": listUids})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions