Skip to content

[BE] Add a way to get number of users assigned to standard roles

On the Role and Permissions page, we are adding standard roles (a.k.a. built-in roles) to the table. The table has a Direct users assigned count column:

ksnip_20240715-162025

backend needs to add a new endpoint that shows the number of users directly assigned to each standard role. It should have the following behavior:

  1. For self-managed, the count should be instance-wide, across all projects and all groups. Proposed GraphQL endpoint:
query {
  standardRoles {
    nodes {
      stringValue
      integerValue
      membersCount
    }
  }
}
{
  standardRoles: {
    nodes: [
      { stringValue: 'Guest', integerValue: 10, membersCount: 52 },
      { stringValue: 'Reporter', integerValue: 20, membersCount: 11 },
      { stringValue: 'Developer', integerValue: 30, membersCount: 185 }
    ]
  }
}
  1. For SAAS, the count should be for the current group/project and all sub-group/sub-projects. Proposed GraphQL endpoint:
query {
  group(fullPath: $fullPath) {
    standardRoles {
      nodes {
        stringValue
        integerValue
        membersCount
      }
    }
  }
}
{
  group: {
    standardRoles: {
      nodes: [
        { stringValue: 'Guest', integerValue: 10, membersCount: 52 },
        { stringValue: 'Reporter', integerValue: 20, membersCount: 11 },
        { stringValue: 'Developer', integerValue: 30, membersCount: 185 }
      ]
    }
  }
}
Edited by Daniel Tian