Sorting by count of child node

Im trying to create a paginated list of authors in my GraphQL-based application, sorted descending by the total count of papers they have written. I have a simple schema of Author and Paper types, with an authored edge going from Author to Paper. The order argument only seems to work with predicates on Author, and cannot use count/count indexes etc.

The only solutions I have found so far is to:

  • pre calculate the number of papers per author and store it as a predicate (not very dynamic and an overhead on the loading code)
  • resort to a custom DQL query (would really like to use native graphQL as I will have many queries like this)

Any options I have missed?

1 Like