Skip to content

Commit

Permalink
fix: Run cleanup function if name is available
Browse files Browse the repository at this point in the history
  • Loading branch information
JeangelLF committed Oct 16, 2024
1 parent d166e1b commit 26f01ab
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/hooks/useApollo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -158,14 +158,14 @@ class FullResultCache extends ApolloCache<NormalizedCacheObject> {
watch.callback(this.diff(watch));
};

if (entry) {
log('GraphQL Cache', 'immediately fire watcher');
watch.callback(this.diff(watch));
}

if (name) {
log('GraphQL Cache', 'store watcher');
this.watchers.set(name, this.watchers.get(name)?.concat(watcher) ?? []);
}

if (entry && name) {
log('GraphQL Cache', 'immediately fire watcher');
watch.callback(this.diff(watch));
return () => {
const updatedWatchers = this.watchers.get(name)?.filter((it) => it !== watcher) ?? [];
this.watchers.set(name, updatedWatchers);
Expand Down

0 comments on commit 26f01ab

Please sign in to comment.