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.

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

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:

  1. Run git grep -n "gqlClient\|fetchPolicy(\|createPolicy(\|updatePolicy(\|deletePolicy(" -- ee/app/assets/javascripts/policy_store ee/spec/frontend/policy_store and confirm there is no output.
  2. Run yarn jest ee/spec/frontend/policy_store and confirm it is green.
  3. 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.

Edited by Artur Fedorov

Merge request reports

Loading
Loading