5

我正在尝试使用GraphQL在 Github 中列出公共存储库,因为它允许我准确地选择Object我想要的信息。

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

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

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

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

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

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

1 回答 1

10

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

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

在资源管理器中尝试

于 2018-01-14T01:49:35.613 回答