【问题标题】:Github GraphQL API v4 Query on CommitAuthorCommitAuthor 上的 Github GraphQL API v4 查询
【发布时间】:2023-03-08 15:00:02
【问题描述】:

我正在尝试在 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
                }
              }
            }
          }
        }
      }
    }
  }
}

它要我在CommitAuthor 上过滤history(author: )。我尝试传递我的用户名或我的唯一用户 ID,但它不起作用。我实际上是在传递一个字符串,但它需要CommitAuthor 类型。如何传递CommitAuthor 值?

我不清楚,我搜索了文档和架构,但找不到任何东西。

请帮忙!

【问题讨论】:

    标签: graphql github-api github-api-v4


    【解决方案1】:

    啊,所以一旦我查看了 graphql 文档(而不仅仅是 github 文档),答案实际上非常简单。 CommitAuthor 是一种输入类型,此处描述为https://graphql.org/graphql-js/mutations-and-input-types/

    结果是你传递了一个CommitAuthor 的对象。在这种情况下,我只需要传递 id,如下所示:author: {id: "MDQ6VXNlcjIyNDE3Mzgy"}

    请参阅下面的完整代码。

    {
      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
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    

    【讨论】:

      猜你喜欢
      • 2018-08-21
      • 2019-10-12
      • 2018-03-10
      • 2018-06-23
      • 2020-01-12
      • 2018-06-17
      • 2018-10-01
      • 2019-08-20
      • 2018-03-26
      相关资源
      最近更新 更多