简体   繁体   English

CommitAuthor 上的 Github GraphQL API v4 查询

[英]Github GraphQL API v4 Query on CommitAuthor

I am trying to run the following query on Githubs GraphQL api:我正在尝试在 Githubs GraphQL api 上运行以下查询:

{
  user(login: "davekaj") {
    id
    repositories(first: 10, orderBy: {field: NAME, direction: ASC}) {
      nodes {
        ref(qualifiedName: "master") {
          target {
            ... on Commit {
              history(first: 15, author: "WHAT DO I PUT HERE") {
                totalCount
                nodes {
                  additions
                  author {
                    name
                    user {
                      id
                    }
                  }
                  committedDate
                  deletions
                }
              }
            }
          }
        }
      }
    }
  }
}

It wants me to filter on a CommitAuthor for history(author: ) .它要我过滤一个CommitAuthor for history(author: ) I tried passing my username, or my unique user ID, but it doesn't work.我尝试传递我的用户名或我的唯一用户 ID,但它不起作用。 I am essentially passing it a string, but it wants the type CommitAuthor .我本质上是向它传递一个字符串,但它需要类型CommitAuthor How do I pass a CommitAuthor value?如何传递CommitAuthor值?

It isn't clear to me, and I searched through the docs and the schema and I couldn't find anything.我不清楚,我搜索了文档和架构,但找不到任何东西。

Please help!请帮忙!

Ah, so the answer is actually very simple once I looked at the graphql documentation (rather than just the github documentation).啊,所以一旦我查看了 graphql 文档(而不仅仅是 github 文档),答案实际上非常简单。 CommitAuthor is an input type, which is described here https://graphql.org/graphql-js/mutations-and-input-types/ . CommitAuthor是一种输入类型,这里有描述https://graphql.org/graphql-js/mutations-and-input-types/

The result is you pass an object of CommitAuthor .结果是您传递了CommitAuthor的对象。 In this case I just have to pass the id, which looks like this: author: {id: "MDQ6VXNlcjIyNDE3Mzgy"}在这种情况下,我只需要传递 id,如下所示: author: {id: "MDQ6VXNlcjIyNDE3Mzgy"}

See the completed code below.请参阅下面的完整代码。

{
  user(login: "davekaj") {
    id
    repositories(first: 10, orderBy: {field: NAME, direction: ASC}) {
      nodes {
        ref(qualifiedName: "master") {
          target {
            ... on Commit {
              history(first: 15, author: {id: "MDQ6VXNlcjIyNDE3Mzgy"}) {
                totalCount
                nodes {
                  additions
                  author {
                    name
                    user {
                      id
                    }
                  }
                  committedDate
                  deletions
                }
              }
            }
          }
        }
      }
    }
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM