How to retrieve blocked users using GitHub's GraphQL API

I’ve been working with GitHub’s GraphQL API recently and while I can easily fetch followers and following lists, I’m struggling to get blocked users through GraphQL.

For followers, this query works perfectly:

query FetchFollowersList {
  user(login: "myusername") {
    followers(first: 50) {
      nodes {
        login
        name
        avatarUrl
      }
    }
  }
}

But I can’t figure out how to get blocked users. I tried this approach:

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

This doesn’t return any results and requires me to first get the node ID:

query GetNodeID {
  user(login: "myusername") {
    id
  }
}

Is there a way to fetch blocked users directly through GraphQL? I know this works fine with the REST API but I’d prefer to use GraphQL for consistency. Any help would be great!

Yeah, everyone’s right - GraphQL doesn’t support blocked users directly. But don’t bother juggling two APIs manually. Just automate it.

I did this for a user analytics dashboard that needed data from multiple APIs. Instead of writing custom code for GraphQL and REST separately, I automated the whole process.

The workflow grabs user data through GraphQL, hits /user/blocks via REST, then combines everything into one clean response. You can cache results and sync on a schedule since blocked lists don’t change much.

This keeps things consistent without messy API calls scattered through your main code. Easy to extend later when you need other endpoints that GraphQL doesn’t cover.

Latenode makes API orchestration like this super easy - whole pipeline set up in minutes: https://latenode.com

I ran into this exact problem building a user profile tool. GitHub’s GraphQL schema doesn’t have a blockedUsers field like it does for followers. That UserBlockedEvent you’re trying is for events only - it won’t give you current blocking relationships. I ended up using a hybrid approach: GraphQL for most user info, then the REST API for blocked users through /user/blocks. Not the cleanest solution since you’re mixing APIs, but it’s the most reliable way to get that data right now.

yeah, GitHub’s GraphQL API doesn’t expose blocked users - it’s a known limitation. I’ve been stuck with this for months. you’ll have to use the REST endpoint /user/blocks instead. annoying when you want everything in GraphQL, but that’s all we’ve got :person_shrugging:

Unfortunately, GitHub’s GraphQL API doesn’t let you query blocked users like you can with followers or following lists. That UserBlockedEvent you’re trying to use is for timeline events, not for getting a list of currently blocked users.

I hit this same wall building a user management tool last year. The GraphQL schema just doesn’t expose blocked users as a queryable field on the User type - probably because blocking relationships are more sensitive than follows.

Your best bet is sticking with the REST API endpoint /user/blocks which returns the blocked users list directly. You could make the REST call alongside your GraphQL queries, or if you want everything in one request, just use GitHub’s REST API for all user relationship data. GraphQL is great for many things but this use case isn’t well supported yet.