0

I'm trying to use Github GraphQL API to search commits by message. In Github REST API, I just need to send POST request to https://api.github.com/search/commits?q=examplemsg&sort=committer-date, but in GraphQL API, I cannot find how I can do this.

I tried to use search query, but enum SearchType has only 3 types, ISSUE, REPOSITORY, and USER. Is it possible to find it?

Thanks.

20chan
  • 167
  • 1
  • 10

2 Answers2

1

Currently, it is not possible to search commits by Github GraphQL API, it has not been supported yet. You will need use REST API instead.

Weihang Jian
  • 7,826
  • 4
  • 44
  • 55
-1

GitHub GraphQL API

Dev GraphQL link

Github Account login

GitHub's 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
          }
        }
      }
    }
  }
}

The response from our API might be:

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

Sanjay kumar
  • 1,653
  • 12
  • 18