Commit 3e16ae6
fix(graphcache): preserve entity data when creating new entities
Previously, when a mutation created a truly new entity, graphcache would
incorrectly invalidate existing entities of the same type. This happened
because the "entity exists" check occurred AFTER writing, so the check
was always truthy for new entities. The actual trigger was `!count`
(no active references), which wiped data from existing entities.
Changes:
- Check if entity existed BEFORE writing mutation data to cache
- Only auto-invalidate for existing entities with no references
- Update test to reflect corrected behavior
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>1 parent 77663e8 commit 3e16ae6
File tree
2 files changed
+22
-9
lines changed- exchanges/graphcache/src
- operations
2 files changed
+22
-9
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2229 | 2229 | | |
2230 | 2230 | | |
2231 | 2231 | | |
2232 | | - | |
| 2232 | + | |
2233 | 2233 | | |
2234 | 2234 | | |
2235 | 2235 | | |
| |||
2326 | 2326 | | |
2327 | 2327 | | |
2328 | 2328 | | |
2329 | | - | |
2330 | | - | |
2331 | | - | |
2332 | | - | |
2333 | | - | |
2334 | | - | |
| 2329 | + | |
| 2330 | + | |
| 2331 | + | |
2335 | 2332 | | |
2336 | 2333 | | |
2337 | 2334 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
330 | 330 | | |
331 | 331 | | |
332 | 332 | | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
333 | 349 | | |
334 | 350 | | |
335 | 351 | | |
| |||
400 | 416 | | |
401 | 417 | | |
402 | 418 | | |
403 | | - | |
404 | 419 | | |
405 | | - | |
| 420 | + | |
| 421 | + | |
406 | 422 | | |
407 | 423 | | |
408 | 424 | | |
| |||
0 commit comments