在 Github 的 GraphQL API 中,如何获取没有特定 repositoryTopic 的存储库?



使用Github的GraphQL API,我最近找到了&;Github API:获取Github存储库的主题&;它提到您可以获得主题计数:

{
repository(owner: "twbs", name: "bootstrap") {
repositoryTopics(first: 10) {
edges {
node {
topic {
name
}
}
}
}
}
}

但是在文档和我的搜索中,我没有找到如何查询不包含主题template的存储库,例如:

query ($github_org: String!, $repo_count: Int!) {
organization(login: $github_org) {
repositories(first: $repo_count, privacy: PUBLIC, isFork: false) {
nodes {
id
name
openGraphImageUrl
createdAt
stargazerCount
url
description
repositoryTopics(first: 10, after: "template") {
edges {
node {
id
}
}
}
}
}
}
}

是使用after的正确实现吗?在Github的GraphQL API如何排除存储库,如果它包含某个主题?

我的理解是,对于组织查询,您不能执行这种存储库过滤。

相反,您可以像这样使用搜索查询:

query ($repo_count: Int!) {
search (first: $repo_count,
type: REPOSITORY,
query: "org:my-organization topic:my-topic") {
nodes {
... on Repository {
name
}
}
}
}

上面的查询搜索给定组织中具有给定主题的所有存储库。

但是你正在寻找没有的存储库一个主题,理论上根据文档,你应该能够做到这一点与-topic:my-topic。不幸的是,对主题的否定不起作用,似乎有一个错误。: - (

最新更新