You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Actual outcome:
The code works i.e. gets executed as expected. However, Apollo garbage collector misbehaves. The value that gets written to ROOT_QUERY.someQuery is a Promise wrapping the underlying cache references. That way, whenever the Apollo's garbage collector is run, it cannot establish a relationship between those wrapped values from the query entry AND the actual cache entries. Yielding in those values being mysteriously being garbage collected.
How to reproduce the issue:
The repro steps:
Define async type policies
Trigger those by writing/reading the query
Capture the values' cache entry ids
Execute client.cache.gc()
Validate that those entries are no longer present in client.cache.data.data
We don’t support async read functions right now, but that’s part of a larger plan to support arbitrary scalar wrapping values (like Date and Promise). Right now, returning a Promise is the same as returning an object with no own properties, which is probably not what you want, but may explain some of the downstream behavior.
Hey @ruiconti, we just released some docs updates that help better describe this behavior (#10282). This is now reflected in our docs.
@benjamn has some more context in this comment about the challenges of using asyncread functions.
I'm doing a bit of housekeeping right now so I'm going to close this issue as working-as-intended. Do feel free to reopen the issue if you need more from us! 🙏
Intended outcome:
I need to wait for perform async operations inside a query type policy's merge/read functions.
e.g.
Actual outcome:
The code works i.e. gets executed as expected. However, Apollo garbage collector misbehaves. The value that gets written to
ROOT_QUERY.someQuery
is aPromise
wrapping the underlying cache references. That way, whenever the Apollo's garbage collector is run, it cannot establish a relationship between those wrapped values from the query entry AND the actual cache entries. Yielding in those values being mysteriously being garbage collected.How to reproduce the issue:
The repro steps:
client.cache.gc()
client.cache.data.data
Versions
The text was updated successfully, but these errors were encountered: