Closed VillePakarinenPosti closed 3 months ago
Ah good catch! Would you be interested in spinning up a PR to relay those optional parameters? Otherwise I'll get to it when I have time. Thanks for the report.
Sounds good to me & would love to get this merged. 👍
See https://github.com/NerdWalletOSS/apollo-cache-policies/pull/87 @danReynolds
Issue with InvalidationPolicyCache Handling of Broadcasts in Apollo Client
I encountered a minor issue when using the
InvalidationPolicyCache
instead of Apollo's built-inInMemoryCache
. It appears there are subtle differences in how the extended class handles broadcasts.While experimenting with Apollo's
client.refetchQueries
, I noticed that the onQueryUpdated callback was never triggered when usingInvalidationPolicyCache
. After investigating, I traced the issue to thebroadcastWatches
method in the Apollo Client. This method seems responsible for this functionality: https://github.com/apollographql/apollo-client/blob/717421c2817f655bea9eec6aca42e3fa0edb1be5/src/cache/inmemory/inMemoryCache.ts#L531-L535.The issue seems to arise because
InvalidationPolicyCache
does not pass the optionalBroadcastOptions
to the underlyingsuper.broadcastWatches
method. This omission appears to prevent theonQueryUpdated
callback from being invoked as expected.Here is the relevant section of the
InvalidationPolicyCache
code: https://github.com/NerdWalletOSS/apollo-cache-policies/blob/42b9004feeaebfc3cdfa175ad2a9798e33aee03e/src/cache/InvalidationPolicyCache.ts#L132-L136.Thank you for looking into this!