【问题标题】:Search commits by message with Github GraphQL API?使用 Github GraphQL API 按消息搜索提交?
【发布时间】:2019-03-25 14:52:23
【问题描述】:

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

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

谢谢。

【问题讨论】:

    标签: api github graphql


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

      GitHub GraphQL API

      Dev GraphQL link

      Github 账号登录

      GitHub 的 GraphQL 浏览器

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

      【讨论】:

        猜你喜欢
        • 2013-08-09
        • 2017-12-07
        • 2018-10-24
        • 2019-12-06
        • 1970-01-01
        • 2017-11-27
        • 2021-12-30
        • 2018-01-05
        相关资源
        最近更新 更多