Improve performance of security policies graphql API with descendant relationship filter

Why are we doing this work

When querying security policies using GraphQL with the relationship filter set to descendant, the query performance degrades significantly for namespaces containing numerous security policy projects. This occurs because it queries all policy projects within the given namespace and validates each project's policy.yml file individually, potentially leading to timeout errors.

Relevant links

Non-functional requirements

  • Documentation:
  • Feature flag:
  • Performance:
  • Testing:

Implementation plan

Verification steps

  • Create a namespace with a large number of projects (50+) with each project having a security policy project
  • Execute the GraphQL query (Group.approvalPolicies) for the namespace with relationship: DESCENDANT
  • Observe the query time and potential timeout
Edited by 🤖 GitLab Bot 🤖