'Can I list Github's public repositories using GraphQL?

I am trying to list public repositories in Github using GraphQL as it allows me to choose exactly which information from an Object I want.

Using REST I could list public repositories simply by making requests to https://api.github.com/repositories. This is OK, but the response comes with a bunch of stuff I don't need. So, I was wondering if I could use GraphQL to do the same job.

The problem is, I couldn't find any high level repositories Object I could use to list public repositories using GraphQL. For me it seems I can only use GraphQL to list repositories from organizations or from users. For example, like doing so:

query{
    user(login: "someuser"){
        repositories(first: 50){
            nodes{
                name
            }
            pageInfo{
                hasNextPage
            }
        }
    }
}

So, how can I use (if at all) Github's GraphQL endpoint to list Github's public repositories?

I have also tried something on this line, using search, but I doubt Github has only 54260 repositories as the repositoryCount variable returned me.

query{
    search(query:"name:*", type:REPOSITORY, first:50){
        repositoryCount
        pageInfo{
            endCursor
            startCursor
        }
        edges{
            node{
                ... on Repository{
                    name
                }
            }
        }
    }
}


Solution 1:[1]

You can use is:public in the search query :

{
  search(query: "is:public", type: REPOSITORY, first: 50) {
    repositoryCount
    pageInfo {
      endCursor
      startCursor
    }
    edges {
      node {
        ... on Repository {
          name
        }
      }
    }
  }
}

Try it in the explorer

Solution 2:[2]

There is also an inPrivate attribute on the Repository object you can query https://docs.github.com/en/graphql/reference/objects#repository

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bertrand Martel
Solution 2 dancl