Multiconditional query

I want to filter through multiple criteria to get the node information which I want.These nodes have the same field properties,I’m going to filter one or more of these conditions.

For example,node of People, it is a node type with predicates name, age, school,grade, class, height, weight.

And I want to look up information for everyone from Class 2, Grade 3, at St. Mary’s

If your query is about GraphQL:

query {
    queryPeople(filter:  {class: 2}, and: {grade: 3}, and: {school: "St. Mary's"} ) {
        # fields that you want
    }
}

The syntax is a bit painful and unclear but it is what it is

If your query is about DQL:

{
    q(func: type(People))  @filter(eq(class, 2) and eq(grade, 3) and eq(school: "St. Mary's") {
     # fields you want
    }
}

Thank you for your help, I’ll try it

That syntax is just plain wrong. The concept is right but wrong syntax. The filter is a single object containing at most one and property. However, additional and clauses can be added as nested properties of clause.

@Soultrans, what problem are you facing? What is your schema? What have you tried so far? Do you have an error message?

1 Like

Argh. I wrote that out as a clarity thing and then proceed to forget to write the additional {}.

I even commented that the syntax is not great -____- .

The corrected code is as follows:

query {
    queryPeople(filter:  {class: 2, and: {grade: 3, and: {school: "St. Mary's"}}} ) {
        # fields that you want
    }
}

This should be correct now.

p/s: the ideal syntax is lisp clearly.