github - 在 graphql 查询中区分私有/内部 github 存储库
问题描述
我正在尝试从我们的组织中获取所有私有存储库。在以下 graphql 查询中,它返回内部和私有存储库。
因为privacy
只能过滤PRIVATE
和PUBLIC
。似乎只有一个字段称为isPrivate
,isInternal
就我所见而言,没有什么不同。
query organizationRepositories($owner: String!) {
organization(login:$owner) {
repositories(first: 100, privacy: PRIVATE) {
totalCount
nodes {
owner {
login
}
name
id
url
isPrivate
}
}
}
}
使用上述查询显示的所有结果isPrivate: true
,我知道其中一些是内部的,有些是私有的。
有没有办法区分私有和内部存储库?通过基于指示私有与内部的某些字段组合的结果循环或通过以不同方式查询。
解决方案
您可以使用搜索查询:
query {
search(query: "org:<my-org> is:internal", type: REPOSITORY, first: 100) {
repositoryCount
nodes {
... on Repository {
name
}
}
}
}