Skip to content

Support lists in query variables (DQL Variable) #2726

@F21

Description

@F21

Experience Report

I often have queries where I want to match a list of things (similar to an IN query in SQL). For example:

{
  someQuery(func: eq(somePredicate, val1, val2){
    someField
  }
}

Often, these values come from user input and I want to pass these values to the query using query variables.

Effectively, this would allow a query like so:

query($vals: []string){
  someQuery(func: eq(somePredicate, $vals){
    someField
  }
}

What you wanted to do

I wanted to pass a list of values as a query variable into a query.

What you actually did

I had to create the query programmatically using string concatenation.

Why that wasn't great, with examples

Having to use string concatenation introduced a lot of noise into the code and the query was very unreadable.

Any external references to support your case

None.

Metadata

Metadata

Assignees

Labels

Stalearea/querylangIssues related to the query language specification and implementation.area/querylang/varsIssues related to queries with GraphQL variableskind/featureSomething completely new we should consider.popularpriority/P2Somehow important but would not block a release.status/acceptedWe accept to investigate/work on it.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions