Add ability to filter standard roles by access level
What does this MR do and why?
We have a GraphQL query to get standard roles, which is used by the roles and permissions page. In a future frontend MR, we need more data and the ability to filter the standard roles. This MR does the following:
-
Adds a top-level
standardRole
query to get a single standard role for a self-managed GitLab instance. We already have astandardRoles
query. -
Adds a
group.standardRole
query to get a single standard role for a SaaS GitLab instance. We already have agroup.standardRoles
query. -
Adds a description field to standard roles and the description for each role. Previously, it was only available in frontend.
-
Adds the ability to filter standard roles by its access level enum.
-
Corrected some inaccurate field descriptions.
How to set up and validate locally
- In GraphQL Explorer, run this query for
standardRoles
and verify that it returns the expected data:
standardRoles query
query {
standardRoles {
nodes {
id
name
accessLevel
description
}
}
}
Expected standardRoles response
{
"data": {
"standardRoles": {
"nodes": [
{
"id": "gid://gitlab/StandardRole/MINIMAL_ACCESS",
"name": "Minimal Access",
"accessLevel": 5,
"description": "The Minimal Access role is for users who need visibility into a project or group but should not have the ability to make changes, such as external stakeholders."
},
{
"id": "gid://gitlab/StandardRole/GUEST",
"name": "Guest",
"accessLevel": 10,
"description": "The Guest role is for users who need visibility into a project or group but should not have the ability to make changes, such as external stakeholders."
},
{
"id": "gid://gitlab/StandardRole/REPORTER",
"name": "Reporter",
"accessLevel": 20,
"description": "The Reporter role is suitable for team members who need to stay informed about a project or group but do not actively contribute code."
},
{
"id": "gid://gitlab/StandardRole/DEVELOPER",
"name": "Developer",
"accessLevel": 30,
"description": "The Developer role strikes a balance between giving users the necessary access to contribute code while restricting sensitive administrative actions."
},
{
"id": "gid://gitlab/StandardRole/MAINTAINER",
"name": "Maintainer",
"accessLevel": 40,
"description": "The Maintainer role is primarily used for managing code reviews, approvals, and administrative settings for projects. This role can also manage project memberships."
},
{
"id": "gid://gitlab/StandardRole/OWNER",
"name": "Owner",
"accessLevel": 50,
"description": "The Owner role is normally assigned to the individual or team responsible for managing and maintaining the group or creating the project. This role has the highest level of administrative control, and can manage all aspects of the group or project, including managing other Owners."
}
]
}
}
}
- Run this query for a single
standardRole
and verify that it returns the expected data:
standardRole query
query {
standardRole(accessLevel: REPORTER) {
id
name
accessLevel
description
}
}
Expected standardRole response
{
"data": {
"standardRole": {
"id": "gid://gitlab/StandardRole/REPORTER",
"name": "Reporter",
"accessLevel": 20,
"description": "The Reporter role is suitable for team members who need to stay informed about a project or group but do not actively contribute code."
}
}
}
- Run this query for a filtered
standardRoles
query and verify that it returns the expected data:
filtered standardRoles query
query {
standardRoles(accessLevel: [GUEST, DEVELOPER, OWNER]) {
nodes {
id
name
accessLevel
description
}
}
}
Expected filtered standardRoles response
{
"data": {
"standardRoles": {
"nodes": [
{
"id": "gid://gitlab/StandardRole/GUEST",
"name": "Guest",
"accessLevel": 10,
"description": "The Guest role is for users who need visibility into a project or group but should not have the ability to make changes, such as external stakeholders."
},
{
"id": "gid://gitlab/StandardRole/DEVELOPER",
"name": "Developer",
"accessLevel": 30,
"description": "The Developer role strikes a balance between giving users the necessary access to contribute code while restricting sensitive administrative actions."
},
{
"id": "gid://gitlab/StandardRole/OWNER",
"name": "Owner",
"accessLevel": 50,
"description": "The Owner role is normally assigned to the individual or team responsible for managing and maintaining the group or creating the project. This role has the highest level of administrative control, and can manage all aspects of the group or project, including managing other Owners."
}
]
}
}
}
- Run your local GDK in SaaS mode by running the following shell commands:
export GITLAB_SIMULATE_SAAS=1
gdk restart
then follow this video to enable the Ultimate license for a top-level group and re-run the 3 queries, but under the group
query:
Related to #468398