Skip to content

[BE] Add GraphQL data for member role users info

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

In #468398, we are adding a Users tab role details page that shows the users that are using a role:

In order to show this tab, we need the following data from backend through GraphQL:

  1. The list of users that have at least 1 group/project where they are assigned the role. This applies to both default roles and custom roles.
  2. A count of the total number of groups and projects (separate counts) where the role is assigned to the user.
  3. For the user, the created date and the last activity date.
  4. For each group and project, the group/project name, URL to the project, access granted date, access expires date, and last activity date.

Proposed implementation

!168207 has the required implementation, it needs to be cleaned up and made review-ready. Here are the examples queries copied from that MR's description:

Example query for custom roles
query memberRole {
  memberRole(id: "gid://gitlab/MemberRole/3") {
    name
    roleUsers {
      nodes {
        user {
          name
        }
        groupsCount
        projectsCount
        members {
          nodes {
            fullName
          }
        }
      }
    }
  }
}
Example response for custom roles
{
  "data": {
    "memberRole": {
      "name": "Test",
      "roleUsers": {
        "nodes": [
          {
            "user": {
              "name": "Eleanore Berge"
            },
            "groupsCount": 0,
            "projectsCount": 1,
            "members": {
              "nodes": [
                {
                  "fullName": "Gitlab Org / Gitlab Test"
                }
              ]
            }
          },
          {
            "user": {
              "name": "Aleshia Gutmann"
            },
            "groupsCount": 1,
            "projectsCount": 1,
            "members": {
              "nodes": [
                {
                  "fullName": "Gitlab Org / Gitlab Test"
                },
                {
                  "fullName": "Flightjs"
                }
              ]
            }
          },
          {
            "user": {
              "name": "John Doe"
            },
            "groupsCount": 1,
            "projectsCount": 0,
            "members": {
              "nodes": [
                {
                  "fullName": "Security Group"
                }
              ]
            }
          }
        ]
      }
    }
  }
}
Example query for default roles
query {
  standardRoles(accessLevel: 30) {
    nodes {
      name
      roleUsers(search: "car") {
        nodes {
          groupsCount
          projectsCount
          user {
            name
          }
          members {
            nodes {
              fullName
            }
          }
        }
      }
    }
  }
}
Example response for default roles
{
  "data": {
    "standardRoles": {
      "nodes": [
        {
          "name": "Developer",
          "roleUsers": {
            "nodes": [
              {
                "groupsCount": 0,
                "projectsCount": 1,
                "user": {
                  "name": "Aleshia Gutmann"
                },
                "members": {
                  "nodes": [
                    {
                      "fullName": "Jashkenas / Underscore"
                    }
                  ]
                }
              }
            ]
          }
        }
      ]
    }
  }
}

Tasks

Edited by 🤖 GitLab Bot 🤖