Most starred repositories


#1

Hello,

I understood that GraphQL strength is that let you query only what you need. In my usecase however, it doesn’t seem to apply :s

I want to list popular repositories (>10 stars) that a user has contributed to. If the Repository object let you sort repositories by how much stars they got, they’re not attribute like totalStars or something…

It seems like I need to fetch all “stargazers” in order to count them.

I tried the follow code on a Repository object but it give me an html error (not a graphql one)

stargazers(first:1) { totalCount }

#2

I didn’t get any answer. Maybe my question wasn’t clear enough. I’ll try again with more details.

I got a webpage titled “Oh snap!” as answer to my query.

So here’s my graphql request as pasted from GraphiQL (too long for a one-line curl command line):

{
  toptunisians: search(type: USER, query: "location:Tunisia", first: 10) {
edges {
  node {
    ... on User {
      login
      name
      contributedRepositories(orderBy: {field: STARGAZERS, direction: DESC}, first: 10, privacy: PUBLIC) {
        totalCount
        edges {
          node {
            ... on Repository {
              name
              primaryLanguage {
                name
              }
              stargazers(first: 1) {
                edges {
                  node {
                    id
                  }
                }
                totalCount
              }
            }
          }
        }
      }
    }
  }
  cursor
}
userCount
  }
}

#3

Hi @baderdean!

Thanks for the clarification, that helps a lot!

This is a known issue, and we’ve got a fix in place that we’re hoping to deploy within the next couple of days. I’ll comment on this issue when it’s been rolled out, and we can test again to see if that solves the issue.

If there is ever a time when you need more urgent support, don’t hesitate to use our contact form, which is checked more actively than this community board.

Thanks!