GitHub API GraphQL snippets

Every time I try to use GitHib’s GraphQL API I find myself totally lost, so here are some snippets I have found useful.

All of these can be pasted into the GitHub GraphQL API Explorer, which can run the code as your logged-in user in the browser without the need to go through an authentication dance.

I will add more over time, and feel free to add any you like in the comments.

List all the projects in an organisation

query{
    organization(login: "matrix-org") {
      projectsV2(first: 20) {
        nodes {
          id
          title
        }
      }
    }
}

Live code reviews make life better

I’ve just got off a call with a colleague. During that call I:

  • learned a lot about how the work he is doing fits in with what my team is working on
  • understood the specific code we were discussing much better than if I’d looked at it alone
  • helped him find a whole bit of code we didn’t actually need (the best kind of code)!
  • helped him figure out something else he has been musing about, that was mostly unrelated
  • had a nice chat and felt much better about life

Asynchronous code reviews can feel like a duty I must perform, and one that distracts me from what I’m doing. Meanwhile, when receiving such reviews, if we’re not careful it can feel like someone criticising for criticism’s sake, or just making your work take longer. As an offline reviewer I don’t often remember to say what I like as well as what I’d want to change, and I normally feel a push to suggest at least one change just to prove I read the code.

Live reviews are so much better! They:

  • are full of opportunities to learn, for both people
  • help you understand the code so you can do a better review
  • often lead the person who wrote the code to spot improvements that the reviewer had no chance of seeing
  • don’t have to be the whole review: you can still take your time to think carefully after the discussion, before clicking Submit
  • can be fun, and give you a chance to interact with your colleagues

I much prefer them. I’m going to do more.