GitHub 的 GraphQL API:如何获取我为特定 public 存储库所做的所有提交?

GitHub's GraphQL API: How can I get all of the commits I've contributed to a particular public repo?

我正在尝试查询 GitHub 的 GraphQL API (v4)。此 API 的哪个 GraphQL 查询可用于获取我为特定 public 存储库贡献的所有提交?

我想出了解决办法。 (下面显示的解决方案用于从 master 获取相关提交,但可以很容易地适应其他 qualifiedName 值。)

首先,执行初始查询以获取用户 ID:

query {
  viewer {
    id
  }
}

然后可以使用以下查询获取对特定存储库的所有贡献提交:

query($repository_owner:String!, $repository_name:String!, $user_id:ID!) {
    repository(owner: $repository_owner, name: $repository_name) {
        ref(qualifiedName: "master") {
            target {
                ... on Commit {
                    history(author: {id: $user_id}) {
                        totalCount
                        nodes {
                            id
                            authoredDate
                            message
                        }
                    }
                }
            }
        }
    }
}

查询变量采用以下形式:

{
  "repository_owner": "REPOSITORY_OWNER_STRING",
  "repository_name": "REPOSITORY_NAME_STRING",
  "user_id": "USER_ID_FROM_STEP_1"
}