I’ve noticed that in some cases, after using writeFragment, while the cache item itself (e.g.
todo:123) is updated with the new data, the queries still have stale data. Despite that those queries are indeed references pointing to e.g.
After poking around a bit more I discovered a few things…
- The data being served instead of the cache data is coming from the query’s
- The fragment in question I was using writeFragment is fairly complex and can include arrays of references to other objects. The objects that returned correct, non-stale data from cache were always ones that included actual references to other objects. Whereas the ones that returned stale data from
lastResultwere ones that had an empty array, & thus no such references.
So my questions are…
- Most importantly… how do I make it so my queries return the actual fresh cache data instead of the stale
lastResult? Is there a way to prevent it from ever serving lastResult when cache data exists?
- Fundamentally, is there something I’m missing here- why is it a thing to return lastResult instead of cache results at all? Why would any developer ever want Apollo to silently return a stale lastResult instead of a fresh cache result?
- Why does the presence or absence of references to other object dictate whether Apollo serves fresh or stale data?