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 linkedResources from 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 the closingMergeRequestsCount scalar added in !253747 (merged). Saves 20 points at page size 100.
  • Narrowed the milestone selection from MilestoneFragment to the three fields issuable_milestone.vue actually reads, id, title and webPath. Saves 10 points.
  • Removed a duplicate startAndDueDate block 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 returns null rather than erroring. issue_card_statistics.vue falls back to the connection, which the widgets and 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

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

  1. Enable the flag with Feature.enable(:work_item_features_field).
  2. Sign in as a non-admin user. As an admin you will not hit the limit, the cap is 300.
  3. Open a group work items list with ?first_page_size=100.
  4. Confirm the list loads and that getWorkItemsFullEE returns no complexity error.
  5. Confirm cards that have a closing merge request still show the merge request count.
  6. Repeat with the flag disabled to check the widgets path 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.

Edited by Kushal Pandya

Merge request reports

Loading
Loading