Find the most starred repositories created in the last week


#1

Just getting started with GraphQL.
Say I want to find the most starred of all Github repositories created during last week.

Two things I’m confused with:

  • It seems I don’t have a way to order repositories by totalCount of stargazers via my query. Does that mean I would have one query fetch the entirety of repositories created last week in several times using cursors and then process my JSON progamatically to sort them?
  • I need to query to all stargazers (in several times using cursors) to access simply the totalCount of stars on a specific repository?

Any help/advice welcome.


#2

:wave: @niwolive,

Right now I don’t believe that we have a way to query by all repositories created across GitHub, or all stargazers across GitHub.

You can either find a specific repository, a specific stargazer (user), or perhaps all of a user’s repositories.

It seems I don’t have a way to order repositories by totalCount of stargazers via my query.

Yes, that appears to be correct looking at the RepositoryOrder input field. This is a bit of an implementation detail, but generally speaking the reason that we limit the ways in which you can order the results is because we want to make sure that we can return them in a performant manner. This may include having the appropriate database indicies or optimizations - that’s why RepositoryOrderField is limited to just CREATED_AT, UPDATED_AT, PUSHED_AT, and NAME.

If querying the data in this manner is a workflow you think that we should support, I’d ask that you please make a request over in the Add your schema requests thread.

Cheers,
Brooks


#3

If you want to get the most starred repos of all time:
https://api.github.com/search/repositories?q=stars:>1&sort=stars

If you want in the past 7 days - https://stackoverflow.com/questions/30525330/how-to-get-list-of-trending-github-repositories-by-github-api


#4

have developed my own and deployed, you could check it out:


#5

Is this what you’re looking for?