Skip to content

Instantly share code, notes, and snippets.

@mkcode
Last active June 22, 2020 21:29
Show Gist options
  • Save mkcode/c5078ed173b470b8d5e97975468ca4f0 to your computer and use it in GitHub Desktop.
Save mkcode/c5078ed173b470b8d5e97975468ca4f0 to your computer and use it in GitHub Desktop.
Student Pull Request GraphQL Query

Get List of your fellows' PRs'

Get list of Student Node Ids

Do this once and save the user ids

Url is https://api.github.com/users/[GITHUB_USER_NAME]

I used the following command, filling in the different user names. (jsonpath is not available by default):

curl https://api.github.com/users/johndbritton | jsonpath node_id

Run the Query

  1. Go to the GitHub GraphQL API explorer https://developer.github.com/v4/explorer/ and sign in.

  2. Add the following the the query section:

query inputArray($ids: [ID!]!) {
  nodes(ids: $ids) {
    ... on User {
      id
      name
      pullRequests(states: [OPEN, MERGED, CLOSED], last: 10) {
        nodes {
          id
          title
          body
          url
          createdAt
          repository {
            name
            nameWithOwner
          }
          labels(first: 10) {
            edges {
              node {
                name
              }
            }
          }
        }
      }
    }
  }
}
  1. Add a list of your student node Ids to the query variables section:
{
  "ids": [
    "MDQ6VXNlcjI4MzQ5Ng==",
    "MDQ6VXNlcjEyMzM0NQ==",
    "MDQ6VXNlcjM1NzE1MzI5"
  ]
}
  1. Open the Explorer tab to add / remove info as you like

And improve

This was the simplest way to get this up in running. If you want to take the time to properly set up authentication and a query explorer, you'll have a better experience.

Also, I highly recommend Insomnia over Postman for MacOS if you haven't checked it out yet

@mkcode
Copy link
Author

mkcode commented Jun 22, 2020

Screenshot of the result:
image

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