fix: Update cached children.count when adding a work item child
What does this MR do and why?
addHierarchyChild wrote widget.count, a field the work item tree query does
not select, so Apollo dropped the write and the cached children.count went
stale as soon as a child was added. This updates children.count on the
connection the tree query actually selects, and fills in the previously pending
it.todo spec.
Changelog: fixed Closes #629889
Before / After
Before: Adding a child to a work item left the cached child count stale.
addHierarchyChild set widget.count, which the tree query does not select, so
Apollo discarded the write and the displayed children.count only corrected
itself after the tree was re-fetched.
After: addHierarchyChild updates children.count on the connection the
tree query selects, so the cached count reflects the new child immediately. The
previously it.todo spec now asserts the count is kept in sync.
How to set up and validate locally
- Run the updated spec:
yarn jest spec/frontend/work_items/graphql/cache_utils_spec.js - Or exercise it in the UI: open a work item that has a children hierarchy and add a child — the children count updates immediately, without re-fetching the tree.
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.
Related to #629889