Loading
Migrate policy store policy delete to GraphQL
What does this MR do and why?
Migrates the policy store detail page's policy delete from the REST endpoint to the governPolicyDelete GraphQL mutation, called directly from the detail component via this.$apollo.mutate (the detail app gains an apolloProvider for this). The store's rejection message is now surfaced in the delete alert instead of only a generic message. The deletePolicy wrapper is removed from policies.js along with the now-unused Api.deletePolicyStorePolicy REST method.
Closes #617793.
REST wrapper audit
Api.deletePolicyStorePolicywas the last consumer of the REST delete and is removed together with its spec; thedeletePolicywrapper inpolicies.jsis removed entirely since the component now calls the mutation itself (verified by grep — no references remain).fetchPoliciesandupdatePolicystill call REST and still have consumers (list page, status toggle) — they belong to the remaining migration issues.- The now-unused
getPolicyStorePolicyREST method is left for the open fetch-migration MR !252321 (merged) to clean up.
Notes for reviewers
- Policy store ids are plain
Intat the GraphQL boundary, not GlobalIDs — theNumber(policyId)cast follows the convention established in !250240 (merged) and continued in !251612 (merged) (ids are frozen gem value objects, not ActiveRecord models, so no GlobalID exists; REST takes the same plain integer). - The only payload error the backend can currently return for delete is the store's
Policy was not foundconstant (already externalized ass_('GovernPolicies|Policy was not found')inbase_service.rb). Surfacing it follows the acceptance criteria and matches how the create flow already surfaces store messages. Any other failure (experiment gate, unmapped reasons) arrives as a top-level GraphQL error and keeps the translated generic alert. - An adversarial review of the first revision (wrapper-based) returned "pass with findings" (verbatim verdict). The mutation call then moved from a
policies.jswrapper into the component at the author's direction; error semantics, variables, and spec coverage carried over unchanged. Non-blocking findings kept as follow-ups: the payload destructure assumes a non-null payload (safe under Apollo's defaulterrorPolicy: 'none', and consistent withcreatePolicy); Sentry still captures not-found deletes (pre-existing behavior); after a not-found the page still renders the deleted policy (pre-existing under REST).
References
- Issue: #617793 (confidential)
- Approved plan: https://gitlab.com/gitlab-org/gitlab/-/issues/617793#note_3754638849
- Epic: &22542
- Related: !252321 (merged) — adds the identical
apolloProviderwiring todetail.js; whichever merges second rebases trivially - Backend mutation (already merged):
ee/app/graphql/mutations/govern/policy_delete.rb
Screenshots or screen recordings
No visual changes. The delete flow keeps the same confirmation modal and button; only the failure alert can now carry the store's message instead of always the generic copy.
How to set up and validate locally
- Enable the policy store experiment for an organization (GDK): in
rails console, ensureorganization.policy_store_experiment_active?returnstruefor your organization, and sign in as a user with thedelete_govern_policyability (instance admin / organization owner). - Create a policy via the wizard at
/-/organizations/<organization_path>/security/policy_store/new. - Open the policy's detail page at
/-/organizations/<organization_path>/security/policy_store/<id>and click Delete, then confirm. - Expected: the network tab shows a
governPolicyDeleteGraphQL request (noDELETE /api/v4/organizations/:id/security/policy_store/:policy_idcall), and the browser returns to the policy list. - Delete the same policy again from a second tab opened beforehand: the alert shows the store's message (
Policy was not found) instead of the generic copy.
Verification evidence:
- local
jeston the three changed spec files —Test Suites: 3 passed, Tests: 92 passed eslintclean on all changed JS/Vue files- the new mutation document validated against
tmp/tests/graphql/gitlab_schema.graphqlwith thegraphqlpackage (document valid)
MR acceptance checklist
Evaluate this MR against the MR acceptance checklist.
Edited by Artur Fedorov