我可以使用 GraphQL 列出 Github 的 public 存储库吗?

Can I list Github's public repositories using GraphQL?

我正在尝试使用 GraphQL 在 Github 中列出 public 个存储库,因为它允许我从 Object 中准确选择哪些信息我想。

使用 REST 我可以简单地通过向 https://api.github.com/repositories 发出请求来列出 public 个存储库。这没关系,但响应带有一堆我不需要的东西。所以,我想知道我是否可以使用 GraphQL 来完成同样的工作。

问题是,我找不到任何高级存储库 Object 我可以使用 GraphQL 列出 public 个存储库。对我来说,我似乎只能使用 GraphQL 来列出来自组织或用户的存储库。比如像这样做:

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

那么,我如何使用(如果有的话)Github 的 GraphQL 端点来列出 Github 的 public 存储库?

我也在这条线上尝试了一些东西,使用 search,但我怀疑 Github 只有 54260 个存储库,因为 repositoryCount 变量返回了我。

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

您可以在搜索查询中使用 is:public

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

Try it in the explorer

Repository对象还有一个inPrivate属性可以查询 https://docs.github.com/en/graphql/reference/objects#repository