Fix N+1 queries in project.aiFlowTriggers

What does this MR do and why?

The project.aiFlowTriggers GraphQL field ran queries for each trigger. The service account behind user, the item consumer and its item, and each flowSchedules connection loaded once per row, so the query count grew with the number of triggers on the page.

This change preloads those associations through LooksAhead in FlowTriggersResolver, only when the client selects the field. flowSchedules now uses a LazyRelationLoader, the same pattern as StateVersionsLoader, because the keyset connection ignores preloaded associations. ItemConsumerType#item also preloads the item organization, which ItemPolicy reads for each item. A new request spec shows that the query count does not grow with the number of triggers.

References

Screenshots or screen recordings

Before After

How to set up and validate locally

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.

Merge request reports

Loading
Loading