Help
cancel
Showing results for 
Search instead for 
Did you mean: 
Copilot Lvl 2
Message 1 of 3

Get Array of repositoryOwner in GraphQL

Solved! Go to Solution.

I'm not super experienced in GraphQL, and I was not using it for a while, but I've recently wanted to give GitHub API another try. I was using my old Query to get most stared repos from the user (when I was testing this first time, stargazers was not yet implemented, or sorting bystargazers):

 

query { 
  repositoryOwner(login: "jcubic") {
    repositories(first: 20, orderBy: {field: STARGAZERS, direction: DESC}, privacy: PUBLIC) {
      edges {
        repository:node {
          name
          stargazers {
            totalCount
          }
        }
      }
    }
  }
}

 

My question is: can I use the same query but return array of users? So I don't need to query multiple times If I need to get stars from more then one user. If this is possible how this query should look like?

 

I've already asked on StackOverflow didn't wait a while (only 3 hours) but wanted to ask here as well:

Get array of repositoryOwner from GitHub GraphQL

2 Replies
Highlighted
Copilot Lvl 2
Message 2 of 3

Re: Get Array of repositoryOwner in GraphQL

Highlighted
Solution
Copilot Lvl 2
Message 3 of 3

Re: Get Array of repositoryOwner in GraphQL

Just if someone need this here is the answer (if you can get id of the user then you can get them all in one query):

 

{
  nodes(ids: ["MDQ6VXNlcjI4MDI0MQ==", "MDQ6VXNlcjEwMjQwMjU="]) {
    ... on User {
      name
      login
    }
    ... on RepositoryOwner {
      repositories(first: 20, orderBy: {field: STARGAZERS, direction: DESC}, privacy: PUBLIC) {
        edges {
          repository: node {
            name
            stargazers {
              totalCount
            }
          }
        }
      }
    }
  }
}