[英]Get info about several repositories from Github Graphql API in a single call
我正在嘗試創建對 Github GraphQL API 的查詢,該查詢接收存儲庫列表作為參數,並在單個 API 調用中返回這些存儲庫的信息,有誰知道該怎么做?
像這樣的東西(我知道這行不通)
query myOrgRepos($repos: [String!]!) {
search(query:"""
repo in $repos
""", type: REPOSITORY, first: 100) {
repo: nodes {
... on Repository{
name
description
updatedAt
}
}
}
我花了一些時間來理解你的評論,所以我會完整地發布答案。 關鍵是在查詢字符串中使用 Github 的高級搜索“語法”,示例參見此處。
以下查詢將查找用戶“github”的所有存儲庫以及用戶“graphql”的 graphql-js 存儲庫:
query {
search(query: "user:github repo:graphql/graphql-js" type: REPOSITORY first: 10) {
nodes {
... on Repository {
name
description
updatedAt
}
}
}
}
我對您的問題的理解是您想輸入“已知”存儲庫列表並輸出有關它們的信息。 在這種情況下,您可以形成以下類型的查詢。
{
nodes(ids: ["node_id_1", "node_id_2"]) {
... on Repository {
nameWithOwner
createdAt
}
}
}
這里的ids
是您感興趣的存儲庫的node_ids
。您可以通過單獨的 GraphQL 調用獲取這些,如下所示
{
repository(owner: "owner", name: "name") {
id
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.