Get Blocked Users with GitHub GraphQL

178 Views Asked by At

I stumbled on GitHub GraphQL today and at first glance, it seemed to me I could do more with it than I already do with their regular RESTful API. I created some Adapters in my existing application and managed to authenticate Users based on a Personal Access Token without much trouble.

Going further, I tried then list Followers, Followees and Blocked Users:

query GetFollowers {
  user(login: "username") {
    followers(first: 100) {
      nodes {
        login
        name
        avatarUrl
      }
    }
  }
}

Obviously, replacing username with a real GitHub username

However, I couldn't find a way to list the Blocked Users, which is something I can do with the RESTful API. Reading the (extensive) documentation, the closest I could build was:

query GetBlockedUsers {
  node(id: "node_id") {
    ... on UserBlockedEvent {
      subject {
        avatarUrl
        login
        name
      }
    }
  }
}

This not only didn't work — or, at least, didn't yield any results — but would also require an extra step when requesting the endpoint, as I would first need to retrieve the node_id of a given username:

Yes, there are some Users blocked on my list :Þ

query GetUserID {
  user(login: "username") {
    id
  }
}

Is it possible to list/add/remove Users to the Blocked List with their GraphQL API? Preferably, but not required, in one single query, filtering by username instead of this node_id

Thank you for your time :D

0

There are 0 best solutions below