如何使用GitHub GraphQL API获取所有具有特定主题的存储库?

3
我想使用Github GraphQL API获取所有包含主题“portfolio”的存储库。
目前,我只知道如何获取具有特定主题的Github上的所有存储库,就像这样:
{
  search(type: REPOSITORY, query: "topic: portfolio", last: 50) {
    repos: edges {
      repo: node {
        ... on Repository {
          url
        }
      }
    }
  }
}

我知道如何获取特定用户的所有存储库,就像这样:

{
  user(login: "VitFL") {
    repositories(last: 50) {
      repos: nodes {
        url
      }
    }
  }
}

但我不知道如何组合这些查询,以便我可以接收特定用户的所有主题为“portfolio”的存储库。

有人知道如何实现此结果吗?

1个回答

1
使用search(),可以向query值中添加user参数。
此外,应删除冒号后的空格,即topic: portfolio -> topic:portfolio。您会注意到这个更改会产生更多的结果。
{
  search(type: REPOSITORY, query: "user:VitFL topic:portfolio", last: 50) {
    repos: edges {
      repo: node {
        ... on Repository {
          url
        }
      }
    }
  }
}

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接