Skip Navigation code drift

GitHub's Hidden Discussion IDs

written  &  updated
in TIL, but also Code, & GraphQL

So that I don't forget this in the future, the Discussion API for GitHub behaves a differently than a lot of the other endpoints. As I implemented GitHub as a CMS, I needed to filter by discussion category, there's an example in the docs

List the discussions within a repository. If categoryId is specified, only results within that category will be returned.

The only way to get the categoryId field is by making a GraphQL call to get the list of discussion categories. You can run this against the GitHub GraphQL Explorer. The below snip grabs the id/name of categories for this repo, codedrift.

query {
  repository(owner: "jakobo", name: "codedrift") {
    discussionCategories(first: 100) {
      edges {
        node {
          id
          name
        }
      }
    }
  }
}