图表QL查询给定作者PR的所有评论

时间:2017-07-12 00:19:56

标签: graphql github-api

我能够想出这个:

{
  repository(owner: "hawkular", name: "hawkular.github.io") {
    pullRequest(number: 237) {
      comments(first: 10) {
        nodes {
          body
          author {
            login
          }
        }
      }
    }
  }
}

返回给定PR的所有注释:

{
  "data": {
    "repository": {
      "pullRequest": {
        "comments": {
          "nodes": [
            {
              "body": "PR was auto-deployed here: http://209.132.178.114:10237 and it will be available for 4 days.\n",
              "author": {
                "login": "hawkular-website-bot"
              }
            },
            {
              "body": "Any ETA for this blog post to be finished/published ?",
              "author": {
                "login": "theute"
              }
            },
            {
              "body": "After PR696 in hawkular-metrics I will continue.. helps me to create something repetable",
              "author": {
                "login": "burmanm"
              }
            },
            {
              "body": "PR was auto-deployed here: http://209.132.178.114:10237 and it will be available for 4 days.",
              "author": {
                "login": "hawkular-website-bot"
              }
            },
            {
              "body": "The article cites `CompressionData` job, but it should be `CompressData`.",
              "author": {
                "login": "jsanda"
              }
            },
            {
              "body": "Is this PR active ? Severla months without activity.",
              "author": {
                "login": "lucasponce"
              }
            }
          ]
        }
      }
    }
  }

然而,我只对hawkular-website-bot所写的内容感兴趣。有没有办法在Git Hub Graph QL api中指定作者?

1 个答案:

答案 0 :(得分:1)

类型PullRequestConnection上的作者没有过滤条件。因此,您无法根据作者过滤请求请求。但是您可以使用类似

的搜索查询功能
{
  search(query: "repo: hawkular/hawkular.github.io is:pr is:open author:hawkular-website-bot", last:10, type:ISSUE){
    edges{
      node{
        ... on PullRequest{
          body
          title
        }
      }
    }
  }
}

有关详细信息,请参见this