Add `membersCount` to `memberRole`
What does this MR do and why?
A MemberRole
cannot be deleted if it has 1 or more members. In order to allow the frontend code to determine if a Delete icon can be rendered next to a MemberRole
record it needs to know how many members have a specific role. This MR adds a membersCount
field to the memberRole
GraphQL type to provide this information to the frontend.
SELECT
member_roles.*,
COUNT(members.id) AS members_count
FROM "member_roles"
LEFT OUTER JOIN "members" ON "members"."member_role_id" = "member_roles"."id"
WHERE "member_roles"."namespace_id" = 9970
GROUP BY "member_roles"."id"
ORDER BY "member_roles"."name" ASC
LIMIT 100
OFFSET 0;
https://console.postgres.ai/gitlab/gitlab-production-tunnel-pg12/sessions/24446/commands/78064
Screenshots or screen recordings
How to set up and validate locally
-
Open GraphQL Explorer: http://gdk.test:3000/-/graphql-explorer
-
Execute the following query
query findMemberRole($id: MemberRoleID!){ memberRole(id:$id) { id name membersCount } }
{ "id": "gid://gitlab/MemberRole/1" }
-
Verify the correct
membersCount
is returned in the results
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by mo khan