Remove the policy store fetch and write wrappers
What does this MR do and why?
This is the third and last of three stacked MRs. They move the Policy Store frontend (ee/app/assets/javascripts/policy_store) detail and editor pages from an imperative fetch helper to idiomatic Vue Apollo.
- !258519 (merged) did the detail page and the shared building blocks.
- !258725 (merged) did the editor page.
Behaviour change: triggers now come back on the policies query. Before, a failed catalog read only fell back to the raw trigger id. Now a field error on triggers puts the detail and list pages into their error state, along with the policies read. This is deliberate.
Summary
This change simplifies how the policy store connects to GraphQL by removing a shared, lazily-initialized Apollo client that was previously used by standalone JavaScript modules outside of Vue components. Instead, each Vue app now creates its own fresh Apollo client when it starts up.
As part of this cleanup, several functions that directly performed GraphQL queries and mutations — including fetching, creating, updating, and deleting policies — were removed from the policies.js module. These operations are now handled entirely within Vue components using Apollo directly, rather than through standalone helper functions.
The test file was also tidied up by moving repeated mock data builders into shared test helpers, and the test Apollo setup was updated to include the correct cache configuration to match how the real app builds its client.
References
- Resolves https://gitlab.com/gitlab-org/gitlab/-/issues/624217
- Approved plan and progress: https://gitlab.com/gitlab-org/gitlab/-/work_items/624217#note_3923851183
- Stacked on !258725 (merged) (target branch
624217-vue-apollo-editor), which is stacked on !258519 (merged), which targetsmaster. This MR retargets as each one merges. Independent of !258173 (merged), which runs as a parallel chain. - Epic: https://gitlab.com/groups/gitlab-org/-/work_items/22542
- Superseded earlier draft, to be closed: !256270 (closed)
Screenshots or screen recordings
There is no visual change.
How to set up and validate locally
The pages are behind the security_policies_v2 feature flag, which is off by default. Enable it in the Rails console with Feature.enable(:security_policies_v2). The policy store experiment must be active for the organization or a top-level group.
Pages:
/organizations/<org-path>/-/security/policy_store/groups/<group-path>/-/security/policy_store
Steps:
- Run
git grep -n "gqlClient\|fetchPolicy(\|createPolicy(\|updatePolicy(\|deletePolicy(" -- ee/app/assets/javascripts/policy_store ee/spec/frontend/policy_storeand confirm there is no output. - Run
yarn jest ee/spec/frontend/policy_storeand confirm it is green. - Open the list, a detail page and the editor for both an organization and a group. Confirm they load and save as before, since this MR removes code only.
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.