Reduce work items list query complexity
What does this MR do and why?
This MR brings the work items list query back under the authenticated complexity limit by trimming what the features fragment selects.
A user reported #627710 (closed), the list query failing with Query has complexity of 277, which exceeds max complexity of 250. It reproduces at first_page_size=100 as a non-admin user. It does not reproduce for us as admins, because admins get a 300 point cap.
The cause is that features sums the complexity of its fields, whereas widgets returns the maximum across the union's branches. The same selection therefore costs far more through features than it did through widgets.
Implementation notes
- Dropped
linkedResourcesfrom the list fragment. Every consumer of it is in the detail view, so the list was paying 7 points for data it never rendered. - Replaced
closingMergeRequests { count }with theclosingMergeRequestsCountscalar added in !253747 (merged). Saves 20 points at page size 100. - Narrowed the milestone selection from
MilestoneFragmentto the three fieldsissuable_milestone.vueactually reads,id,titleandwebPath. Saves 10 points. - Removed a duplicate
startAndDueDateblock from the EE fragment. It was already in the base fragment, so it cost nothing, it was just dead duplication. - The new field is tagged
@gl_introduced(version: "19.4.0"), so a backend that predates it returnsnullrather than erroring.issue_card_statistics.vuefalls back to the connection, which thewidgetsand REST paths still return. - Added a page size 100 example to
ee/spec/graphql/all_queries_spec.rb. The existing examples stop at 50, which is why this reached production.
Complexity, measured with query_complexity_with_typename and useWorkItemFeatures: true:
| Page size | Before | After |
|---|---|---|
| 20 | 167 | 145 |
| 50 | 209 | 180 |
| 100 | 277 | 240 |
240 against a 250 cap is 10 points of headroom, which is thin. Worth keeping in mind before anything else is added to this fragment.
References
- Work item queries that previously ran now repor... (#627710 - closed)
- Work item features - Rollout `work_item_feature... (#587972)
- Optimize work item list query to fetch only nec... (#589609 - closed)
- Depends on !253747 (merged), which adds the field this MR selects. This MR cannot merge before it.
Screenshots or screen recordings
NA, no visual change. The list renders the same cards with the same merge request counts.
How to set up and validate locally
- Enable the flag with
Feature.enable(:work_item_features_field). - Sign in as a non-admin user. As an admin you will not hit the limit, the cap is 300.
- Open a group work items list with
?first_page_size=100. - Confirm the list loads and that
getWorkItemsFullEEreturns no complexity error. - Confirm cards that have a closing merge request still show the merge request count.
- Repeat with the flag disabled to check the
widgetspath still renders the count.
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.