[简记] github 上的 GraphQL v4 API

突发奇想,想用github做一个支持rss的blog体系,或者就是知识管理体系,简单看了下,把测试用的暂存起来

# Type queries into this side of the screen, and you will 
# see intelligent typeaheads aware of the current GraphQL type schema, 
# live syntax, and validation errors highlighted within the text.

# We'll get you started with a simple query showing your username!
query { 
  viewer { 
    login
  }
  repository(owner:"hsxfjames", name:"SCNUSE-Beginners-Guide") {
    pullRequests(first:1) {
      totalCount
      nodes {
        title
        url
        resourcePath
        bodyHTML
        timeline(first:100) {
          totalCount
          nodes {
            ... on Commit {
              messageBodyHTML
              messageHeadlineHTML
            }
            ... on LabeledEvent {
              actor {
                login
              }
              label {
                color
                name
              }
            }
            ... on ReferencedEvent {
              actor {
                login
              }
              commit {
                committer {
                  name
                }
                messageBodyHTML
             	  messageHeadlineHTML
              }
            }
            ... on MergedEvent {
              actor {
                login
              }
              commit {
                committer {
                  name
                }
                messageBodyHTML
             	  messageHeadlineHTML
              }
              mergeRefName
              createdAt
            }
          }
        }
      }
    }
  }
}

结果:

{
  "data": {
    "viewer": {
      "login": "hsxfjames"
    },
    "repository": {
      "pullRequests": {
        "totalCount": 1,
        "nodes": [
          {
            "title": "来自Reborn的一些修改",
            "url": "https://github.com/hsxfjames/SCNUSE-Beginners-Guide/pull/1",
            "resourcePath": "/hsxfjames/SCNUSE-Beginners-Guide/pull/1",
            "bodyHTML": "<p>新增了一些书目,增加了一些对买书的建议</p>",
            "timeline": {
              "totalCount": 6,
              "nodes": [
                {
                  "messageBodyHTML": "",
                  "messageHeadlineHTML": "test-rt"
                },
                {
                  "messageBodyHTML": "",
                  "messageHeadlineHTML": "test-rt"
                },
                {
                  "messageBodyHTML": "",
                  "messageHeadlineHTML": "test-rt"
                },
                {
                  "actor": {
                    "login": "hsxfjames"
                  },
                  "label": {
                    "color": "84b6eb",
                    "name": "enhancement"
                  }
                },
                {
                  "actor": {
                    "login": "hsxfjames"
                  },
                  "commit": {
                    "committer": {
                      "name": "Black Strom"
                    },
                    "messageBodyHTML": "",
                    "messageHeadlineHTML": "新增了一些书目,增加了一些对买书的建议 (<a href=\"https://github.com/hsxfjames/SCNUSE-Beginners-Guide/pull/1\" class=\"issue-link js-issue-link\" data-url=\"https://github.com/hsxfjames/SCNUSE-Beginners-Guide/issues/1\" data-id=\"244392967\" data-error-text=\"Failed to load issue title\" data-permission-text=\"Issue title is private\">#1</a>)"
                  }
                },
                {
                  "actor": {
                    "login": "hsxfjames"
                  },
                  "commit": {
                    "committer": {
                      "name": "Black Strom"
                    },
                    "messageBodyHTML": "",
                    "messageHeadlineHTML": "新增了一些书目,增加了一些对买书的建议 (<a href=\"https://github.com/hsxfjames/SCNUSE-Beginners-Guide/pull/1\" class=\"issue-link js-issue-link\" data-url=\"https://github.com/hsxfjames/SCNUSE-Beginners-Guide/issues/1\" data-id=\"244392967\" data-error-text=\"Failed to load issue title\" data-permission-text=\"Issue title is private\">#1</a>)"
                  },
                  "mergeRefName": "master",
                  "createdAt": "2017-07-21T00:47:44Z"
                }
              ]
            }
          }
        ]
      }
    }
  }
}
posted @ 2017-07-21 10:11  BlackStorm  阅读(1489)  评论(0编辑  收藏  举报