Order By field count


#1

I have query like this:


{
  repositoryOwner(login:"jcubic") {
    repositories(first: 5, orderBy: {field:PUSHED_AT,direction:DESC}, isFork:false) {
      edges {
        node {
          name
          stargazers {
            totalCount
          }
        }
      }
    }
  }
}

it display last 5 repos that I pushed into, but I want to get repos that have most stars, there should be a way to sort by field you have selected like “node.stargazers.totalCount”


#2

Hey @jcubic!

I agree that being able sort a connection by arbitrary edge fields like that would be really useful, but unfortunately it’s something that we can’t support efficiently in the general case.

Some sorts would require that we materialise the entire connection on our backend to sort it, which would be prohibitively expensive for large connections (such as sorting Git commit history on large repos, for instance)

However, being able to sort RepositoryConnection by stargazer count would definitely be useful - thanks for that suggestion!

We’d probably implement that by adding a STARGAZER_COUNT value to the RepositoryOrderField enum. Would that work for you?


Add your schema requests
#3

yes, that would be great.


#4

I want to get repos Order By stars (STARGAZER_COUNT) as well.

Hope that it’s available soon. thx.