使用Github GraphQL API按消息搜索提交?

时间:2018-10-21 09:43:16

标签: api github graphql

我正在尝试使用Github GraphQL API通过消息搜索提交。在Github REST API中,我只需要发送POST请求到https://api.github.com/search/commits?q=examplemsg&sort=committer-date,但是在GraphQL API中,我找不到如何做到这一点。

我尝试使用search查询,但是枚举SearchType只有3种类型,ISSUEREPOSITORYUSER。有可能找到它吗?

谢谢。

2 个答案:

答案 0 :(得分:1)

当前,不可能通过Github GraphQL API搜索提交,但尚不支持。您将需要改用REST API。

答案 1 :(得分:0)

GitHub GraphQL API

Dev GraphQL link

Github帐户登录

  

GitHub的GraphQL Explorer

{
  viewer {
    login
    bio
    location
    isBountyHunter
  }
  viewer {
    login
    starredRepositories {
      totalCount
    }
    repositories(first: 5) {
      edges {
        node {
          name
          stargazers {
            totalCount
          }
          forks {
            totalCount
          }
          watchers {
            totalCount
          }
          issues(states: [OPEN]) {
            totalCount
          }
        }
      }
    }
  }
}
  

我们的API响应可能是:

{
  "data": {
    "viewer": {
      "login": "webmasters964",
      "bio": "",
      "location": "New Delhi",
      "isBountyHunter": false,
      "starredRepositories": {
        "totalCount": 4
      },
      "repositories": {
        "edges": [
          {
            "node": {
              "name": "WCFRESTfulService",
              "stargazers": {
                "totalCount": 0
              },
              "forks": {
                "totalCount": 1
              },
              "watchers": {
                "totalCount": 1
              },
              "issues": {
                "totalCount": 0
              }
            }
          },
          {
            "node": {
              "name": "Running-Node.js-server",
              "stargazers": {
                "totalCount": 0
              },
              "forks": {
                "totalCount": 0
              },
              "watchers": {
                "totalCount": 1
              },
              "issues": {
                "totalCount": 0
              }
            }
          },
          {
            "node": {
              "name": "Running-JavaScript-Files",
              "stargazers": {
                "totalCount": 0
              },
              "forks": {
                "totalCount": 0
              },
              "watchers": {
                "totalCount": 1
              },
              "issues": {
                "totalCount": 0
              }
            }
          },
          {
            "node": {
              "name": "Express.js-in-simple",
              "stargazers": {
                "totalCount": 0
              },
              "forks": {
                "totalCount": 0
              },
              "watchers": {
                "totalCount": 1
              },
              "issues": {
                "totalCount": 0
              }
            }
          },
          {
            "node": {
              "name": "angularquickstart",
              "stargazers": {
                "totalCount": 0
              },
              "forks": {
                "totalCount": 0
              },
              "watchers": {
                "totalCount": 1
              },
              "issues": {
                "totalCount": 0
              }
            }
          }
        ]
      }
    }
  }
}

enter image description here