Route group policy store writes through the GraphQL mutations
What does this MR do and why?
Summary
Group-level policies now go through the same GraphQL API as organization-level policies, instead of using a separate REST API. Previously, creating, updating, or deleting a policy for a group would call a different backend endpoint than for an organization. Now, a single unified path handles both — the code simply passes a groupPath for groups or an organizationId for organizations, and the server knows which one to use.
A safety guard was also added: if a caller accidentally includes a container argument (like groupPath or organizationId) in the policy parameters themselves, the code will immediately reject the request with a clear error, preventing any ambiguity about which container the policy belongs to.
Tests were updated to reflect this consolidation — REST API mocks were removed, and new tests confirm that the correct container argument is sent for each namespace type.
References
- Related to https://gitlab.com/gitlab-org/gitlab/-/work_items/630066
- Group frontend: !255586 (merged)
- Backend mutation change (merged): !256765 (merged)
- Approved plan and progress: https://gitlab.com/gitlab-org/gitlab/-/work_items/630066#note_3916531280
- Stacked follow-up MR (REST cleanup): !258173 (merged)
Screenshots or screen recordings
| Description | UI |
|---|---|
| Group path for a group level call | ![]() |
How to set up and validate locally
The feature is behind the security_policies_v2 flag (default off). Policy store pages live at /groups/<group-path>/-/security/policy_store and /organizations/<org-path>/-/security/policy_store.
- Enable the flag in the rails console:
Feature.enable(:security_policies_v2). - Make sure the policy store experiment is active for a top-level group.
- Open the group's policy store list and create a policy through the wizard.
- Edit the policy and toggle its status from the detail page.
- Delete the policy.
- Check the browser network tab: requests are
governPolicyCreate,governPolicyUpdate,governPolicyDeleteGraphQL calls carryinggroupPath, and there are no requests to/api/v4/groups/:id/security/policy_store. - Try creating a second policy with the same name and confirm the error appears inline under the name field.
- Repeat one write on an organization page and confirm the request carries
organizationIdand nogroupPath.
Locally, jest ee/spec/frontend/policy_store passed (32 suites, 622 tests). The three mutation documents were also validated against a freshly dumped GraphQL schema.
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist. It helps you analyze changes to reduce risks in quality, performance, reliability, security, and maintainability.
