Github GraphQL API 获取用户的所有提交

问题描述 投票:0回答:1

我正在尝试使用 GitHub GraphQL API 来获取用户所做的所有添加(可以从他们的提交中找到添加)。我已经能够从拉取请求中获取添加内容,但我还没有找到对提交执行相同操作的方法。如何获取用户的所有提交?

这是我的查询(我是 GraphQL 新手):

query AllAdditions($username: String!, $from: DateTime, $to: DateTime) {
  user(login: $username) {
    name
    contributionsCollection(from: $from, to: $to) {
      commitContributionsByRepository(maxRepositories: 100) {
        repository {
          nameWithOwner
        }
        contributions(first: 30) {
          totalCount
          # I'm trying to get additions like this, but there is no 'commit' field    
          # nodes {
          #   commit {
          #     additions
          #   }
          # }
        }
      }
      pullRequestContributionsByRepository(maxRepositories: 100) {
        repository {
          nameWithOwner
        }
        contributions(first: 30) {
          nodes {
            pullRequest {
              additions
            }
          }
        }
      }
    }
  }
}
graphql github-api github-api-v4
1个回答
0
投票

正如 GraphQL - 获取所有用户的所有提交中的 lee-dhom 所提到的:

{
  search(query: "org:test", type: REPOSITORY, last: 100) {
    nodes {
      ... on Repository {
        name
        defaultBranchRef {
          name
          target {
            ... on Commit {
              history(first: 100, since: "2013-07-11T00:00:00") {
                totalCount
                nodes {
                  ... on Commit {
                    committedDate
                    additions
                    author {
                      name
                      email
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

至于获取所有组织,目前还没有办法通过 GraphQL API,因为搜索连接需要以下内容 搜索查询。也没有顶级连接可以让您 列出所有用户、组织或存储库。

希望有帮助!

© www.soinside.com 2019 - 2024. All rights reserved.