Query count of relation on connection

prisma

#1

ok… so let’s say I have 10 classes, each with 50 students, connected via @relation. I’d like to query each class, and only retrieve the number of students, and avoid querying every student.

classesConnection seems like the obvious choice – for each class query I would also aggregate { count } on the students field… is this possible?

query {
  classesConnection {
    edges {
      node {
        ...Class
      }
    },
    aggregate {
      students {
        count
      }
    }
  }
}

#2

Hey @Logan_Bernard, there are no inner connection fields yet (also see this feature request), but once they are added you will be able to run this query:

query {
  classes {
    id
    studentsConnection {
      aggregate {
        count
      }
    }
  }
}

Please track the feature request to stay informed :slight_smile:


#3

Hey @nilan This function is very necessary. When will it be finished


#4

Any update on this feature? Feature request link is invalid.

@nilan