How to query an array field by count (or check for emptiness)

Lets say you have a schema like so.

type school {
  students: [student]
}

type student {
name: String
}

How would you be able to query schools that have X number of students or schools that are empty of students?

Something like

query {
  queryschool(filter: { students: {lt: 2}) {
    students
  }
}

or

query {
  queryschool(filter: { students: {eq: 0}) {
    students
  }
}

thanks!

AFAIK, you still can’t query by count, but you can query by existence and non-existence using the has filter.

I see thanks for the answer here, are you able to do a “reverse” has to query empty schools for example?

Well, this is tagged GraphQL, so as far as GraphQL “reverse” actually uses hasInverse directive that creates an edge from both directions it is definitely possible. I’m not sure 100% if DQL @reverse allows you to use has on a reverse edge though, i would have to trial-and-error that one to know for sure.

Thanks for your help on this. Seems like I can at least get empty schools with something like

query {
  queryschool(filter: {not: {has: students} }) {
    students
  }
}