Sort Forks via Stargazers

schema-request

#1

In the old REST API, you could list a repository’s forks sorted by “stargazers”. However, the GraphQL API shows that you must sort them by a RepositoryOrderField which doesn’t include “stargazers”. I’m simply wondering if this was intentional, or if it was an oversight/missed feature (as I find sorting that way very useful :).


#2

I think it’s very much just that we haven’t built it yet :smile:. If you find this valuable, we can add this to our internal schema request tracker to prioritize.


#3

Hey @karagenit!

We’ve just shipped the ability to sort repositories by “stargazers” via RepositoryOrderField. An example query:

query {
  user(login: "tenderlove") {
    repositories(first: 10 orderBy: {field: STARGAZERS, direction: DESC}) {
      nodes {
        name
        stargazers {
          totalCount
        }
        forks(first: 10 orderBy: {field: STARGAZERS, direction: DESC}) {
          nodes {
            name
            stargazers {
              totalCount
            }
          }
        }
      }
    }
  }
}

If you have any more questions, or if something looks amiss, don’t hesitate to reply here!


Orderby field STARGAZERS not working
#4

Thanks a bunch, it seems like it’s working perfectly! :smiley: :smiley: