Merge work item features widget by widget in the Apollo cache

What does this MR do and why?

The WorkItem.features Apollo type policy merged with a shallow spread, so an incoming write replaced a widget wrapper wholesale. When two documents carry different parts of the same widget, whichever writes last wins and the other's fields are dropped from the cache. The reader then gets a partial hit and refetches.

We now merge wrapper by wrapper, which is what the widgets[] policy right below already does. Because a custom merge is installed, Apollo emits no "Cache data may be lost" warning here, so ConsoleWatcher never flagged it. That's why this comes with a dedicated spec.

References

Screenshots or screen recordings

NA, no visual change. The effect is one fewer network request per work item update.

How to set up and validate locally

  1. Run yarn jest spec/frontend/graphql_shared/issuable_client_spec.js.
  2. Revert the merge body to const merged = { ...existing, ...incoming }; and re-run, two of the three examples should fail.
  3. Open a work item, add a label, and confirm in the network tab that workItemAgentPlan isn't refetched.

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