3

使用 GitHub GraphQL API (v.4) 我想获取给定存储库中存在的所有分支名称。

我的尝试

{
  repository(name: "my-repository", owner: "my-account") {
    ... on Ref {
      name
    }
  }
}

返回错误:

{'data': None, 'errors': [{'message': "Fragment on Ref can't be spread inside Repository", 'locations': [{'line': 4, 'column': 13}]}]}
4

1 回答 1

9

以下是从 repo 中检索 10 个分支的方法:

{
  repository(name: "git-point", owner: "gitpoint") {
    refs(first: 10, , refPrefix:"refs/heads/") {
      nodes {
        name
      }
    }
  }
}

PS:在处理Union类型时通常使用spread(例如IssueTimeline,它由不同类型的对象组成,因此您可以在特定的对象类型上展开以查询特定字段。


您可能需要使用分页来获取所有分支

于 2018-06-13T12:20:14.640 回答