Skip to content

Instantly share code, notes, and snippets.

@yeikel
Created March 5, 2022 04:34
Show Gist options
  • Save yeikel/63d81384f1989e78131241e2bc1f1221 to your computer and use it in GitHub Desktop.
Save yeikel/63d81384f1989e78131241e2bc1f1221 to your computer and use it in GitHub Desktop.
Find status of latest commit Github API Grapqhql
query MyQuery {
repository(name: "spark", owner: "apache") {
pullRequest(number: 35738) {
commits(last: 1) {
nodes {
commit {
statusCheckRollup {
state
contexts(last: 10) {
edges {
node {
... on CheckRun {
name
conclusion
status
}
}
}
}
}
}
}
}
mergeable
viewerCanMergeAsAdmin
}
}
}
@yeikel
Copy link
Author

yeikel commented Mar 5, 2022

Explorer https://docs.github.com/en/graphql/overview/explorer

Sample response

{
  "data": {
    "repository": {
      "pullRequest": {
        "commits": {
          "nodes": [
            {
              "commit": {
                "statusCheckRollup": {
                  "state": "PENDING",
                  "contexts": {
                    "edges": [
                      {
                        "node": {
                          "name": "Notify test workflow",
                          "conclusion": "SUCCESS",
                          "status": "COMPLETED"
                        }
                      },
                      {
                        "node": {
                          "name": "Label pull requests",
                          "conclusion": "SUCCESS",
                          "status": "COMPLETED"
                        }
                      },
                      {
                        "node": {
                          "name": "Build and test",
                          "conclusion": null,
                          "status": "IN_PROGRESS"
                        }
                      }
                    ]
                  }
                }
              }
            }
          ]
        },
        "mergeable": "MERGEABLE",
        "viewerCanMergeAsAdmin": false
      }
    }
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment