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
- Rollout issue: #587972
- Migration epic: gitlab-org#20609
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
- Run
yarn jest spec/frontend/graphql_shared/issuable_client_spec.js. - Revert the
mergebody toconst merged = { ...existing, ...incoming };and re-run, two of the three examples should fail. - Open a work item, add a label, and confirm in the network tab that
workItemAgentPlanisn'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.