如何使用 GraphQL 获取 GitHub 分支名称
How to fetch GitHub branch names using GraphQL
使用 GitHub GraphQL API (v.4) 我想获取给定存储库中存在的所有分支名称。
我的尝试
{
repository(name: "my-repository", owner: "my-account") {
... on Ref {
name
}
}
}
returns 错误:
{'data': None, 'errors': [{'message': "Fragment on Ref can't be spread inside Repository", 'locations': [{'line': 4, 'column': 13}]}]}
以下是从存储库中检索 10 个分支的方法:
{
repository(name: "git-point", owner: "gitpoint") {
refs(first: 10, , refPrefix:"refs/heads/") {
nodes {
name
}
}
}
}
PS:你通常在处理Union类型时使用spread(例如IssueTimeline,它由不同种类的对象组成,因此你可以在特定对象类型上展开以查询特定字段。
您可能需要使用 pagination 获取所有分支
使用 GitHub GraphQL API (v.4) 我想获取给定存储库中存在的所有分支名称。
我的尝试
{
repository(name: "my-repository", owner: "my-account") {
... on Ref {
name
}
}
}
returns 错误:
{'data': None, 'errors': [{'message': "Fragment on Ref can't be spread inside Repository", 'locations': [{'line': 4, 'column': 13}]}]}
以下是从存储库中检索 10 个分支的方法:
{
repository(name: "git-point", owner: "gitpoint") {
refs(first: 10, , refPrefix:"refs/heads/") {
nodes {
name
}
}
}
}
PS:你通常在处理Union类型时使用spread(例如IssueTimeline,它由不同种类的对象组成,因此你可以在特定对象类型上展开以查询特定字段。
您可能需要使用 pagination 获取所有分支