Read the policy store detail page through Vue Apollo

What does this MR do and why?

Summary

This change replaces the old manual API calls for loading, updating, and deleting policies with GraphQL queries and mutations managed by Apollo (the app's data-fetching layer). Previously, the detail page fetched policy data by calling custom JavaScript functions directly; now it uses Apollo's built-in mechanisms to load data automatically and keep it in sync.

A key benefit is that when a policy is updated (e.g., toggled active/disabled), Apollo automatically refreshes the displayed information from its local cache without making an extra network request. For deletions, no cache update is needed since the user is redirected away afterward.

Error handling is also streamlined: a new shared utility (throwStoreErrors) ensures that both network failures and backend-reported errors are handled the same way. The policy-loading logic (including error and not-found states) is extracted into a shared query definition (single_policy_query.js) so both the detail page and the editor page can reuse it. The tests are updated accordingly, replacing mocked function calls with mocked GraphQL responses.

References

Related to https://gitlab.com/gitlab-org/gitlab/-/work_items/624217 (the last MR of the stack closes it)

Screenshots or screen recordings

No visual change; the detail page renders the same as before.

How to set up and validate locally

The pages are behind the security_policies_v2 feature flag, default off. Enable it with Feature.enable(:security_policies_v2) in the Rails console. The policy store experiment must also be active for the organization or a top-level group.

Policy store pages live at /organizations/<org-path>/-/security/policy_store and /groups/<group-path>/-/security/policy_store.

Steps:

  • Open a policy's detail page from the list. In the browser network tab, confirm a single getPolicyStorePolicies (or getGroupPolicyStorePolicies for a group) request on load and no separate catalogs request.
  • Click Disable or Enable and confirm one governPolicyUpdate request, the status badge flips, and no second policies query is sent.
  • Open a policy id that does not exist and confirm the page error.
  • Delete a policy and confirm governPolicyDelete followed by navigation to the list.
  • Repeat the toggle on a group page and confirm the request carries groupPath and no organizationId.

Local verification: jest ee/spec/frontend/policy_store/components/detail/app_spec.js ee/spec/frontend/policy_store/policies_spec.js ee/spec/frontend/policy_store/utils_spec.js passed with 143 tests. eslint is clean on all touched files.

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.

Edited by Artur Fedorov

Merge request reports

Loading
Loading