Hi @jlnrrg,
Yes, this seems like a legit use case for supporting nested filters .
We will be looking into adding support for it.
Current work around could be to have a roomName: String! @search(by: [hash])
field inside type Class
. This may store number of the Room. (501, 502 etc.)
If this field is added, the query to find such students could be rewritten as:
query {
queryClass(filter:{or:[{and:[{description:{anyofterms:"Math"}}, {roomName:{eq:"501"}}]},
{and:[{description:{anyofterms:"English"}}, {roomName:{eq:"502"}}]}]}){
students{
firstName
...
}
}
}
I am assuming in above query that description
field contains name of the class.
The other possible workaround which should work around with current schema is as follows:
- Fetch all students taking Math class in Room 501 using
queryRoom(filter: \* Apply filter where room name is 501*\) {
classes(filter: \* Apply filter where class description is Math*\) {
students{
...
}
}
}
- Similarly fetch all students taking English in Room 502.
- Combine the results and perform union or intersection on student list at the client side.