Add accessLevel & isLastOrganizationOwner fields to organizationUser
What does this MR do and why?
This is part of the ongoing organization work https://docs.gitlab.com/ee/architecture/blueprints/organization/.
We are adding these fields to the organizationUser
GraphQL query so
check if the current user is the last owner of the organization to see
if the user can leave the organization or not.
Query plan
Raw query 1
EXPLAIN
SELECT 1 AS one
FROM "organization_users"
INNER JOIN "users" ON "users"."id" = "organization_users"."user_id"
WHERE "organization_users"."organization_id" = 1
AND "organization_users"."access_level" = 50
AND ("users"."state" IN ('active'))
AND "users"."user_type" IN (0, 6, 4, 13)
AND "organization_users"."id" != 10000
LIMIT 1;
https://console.postgres.ai/gitlab/gitlab-production-main/sessions/27273/commands/84790
Raw query 2
EXPLAIN
SELECT 1 AS one
FROM "organization_users"
WHERE "organization_users"."organization_id" = 1
AND "organization_users"."access_level" = 50
AND "organization_users"."id" != 10327656
LIMIT 1;
https://console.postgres.ai/gitlab/gitlab-production-main/sessions/27273/commands/84791
MR acceptance checklist
Please evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
How to set up and validate locally
Run the below query on https://gdk.test:3000/-/graphql-explorer:
{
organization(id: "gid://gitlab/Organizations::Organization/1") {
organizationUsers {
nodes {
id
accessLevel {
integerValue
stringValue
}
isLastOrganizationOwner
}
}
}
}
Related to #441577 (closed)
Edited by Abdul Wadood