Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use graphql endpoint for stargazers #120

Closed
ericboucher opened this issue May 17, 2022 · 0 comments · Fixed by #123
Closed

Use graphql endpoint for stargazers #120

ericboucher opened this issue May 17, 2022 · 0 comments · Fixed by #123

Comments

@ericboucher
Copy link
Contributor

The GitHub REST API makes it impossible to traverse the stargazers endpoint for large repos and limits how many pages we can query.

For example, querying https://api.github.com/repositories/10270250/stargazers?page=500&per_page=100 will result in the following error:

{
    "message": "In order to keep the API fast for everyone, pagination is limited for this resource. Check the rel=last link relation in the Link response header to see how far back you can traverse.",
    "documentation_url": "https://docs.github.com/v3/#pagination"
}

And contrary to what the message suggests, querying the "last" link still gives an error...

To make things worse, the API does NOT allow any of the following params for this endpoint:

  • "since"
  • "sort"

A solution is to paginate through a Graphql version instead:

query { 
  repository(name: "react" owner: "facebook") { 
    stargazers(first: 100 orderBy: {field: STARRED_AT direction: DESC}) {
      edges {
        node {
          id
          login
        }
        starredAt
      }
    }
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant