10

I'm trying to get repositories of user with login name "somelogin".

It returns all repositories but I'm trying to get repositories owned by him only. Because new API uses GraphQL I couldn't did it.

Currently I'm using:

{
   "query": "query { user(login:\"furknyavuz\") {repositories(first: 50) { nodes { name url }}}}"
}
Furkan Yavuz
  • 1,858
  • 5
  • 30
  • 51

2 Answers2

6

You can use isFork: false to exclude fork. In the explorer :

{
  user(login: "furknyavuz") {
    repositories(first: 50, isFork: false) {
      nodes {
        name
        url
      }
    }
  }
}

With curl :

curl -H "Authorization: bearer token" -d '
 {
   "query": "query { user(login: \"furknyavuz\") { repositories(first: 50, isFork: false) { nodes { name url } } } }"
 }
' https://api.github.com/graphql
Bertrand Martel
  • 42,756
  • 16
  • 135
  • 159
1

It's super easy to build graph QL using the Github GraphQL explorer. Please refer to the attached screenshot. https://docs.github.com/en/graphql/overview/explorer

{ user(login: "leerob") { name email company bio followers { totalCount } following { totalCount } repositories(first: 50, isFork: false) { nodes { name url stargazerCount primaryLanguage { id name } } } } }

enter image description here

Chamath Jeevan
  • 5,072
  • 1
  • 24
  • 27