Skip to content

Commit

Permalink
InMemoryCache.gc: also trigger FragmentRegistry.resetCaches (#11355)
Browse files Browse the repository at this point in the history
  • Loading branch information
phryneas authored Nov 14, 2023
1 parent b0bf0d8 commit 7d8e184
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .api-reports/api-report-cache.md
Original file line number Diff line number Diff line change
Expand Up @@ -488,6 +488,8 @@ export interface FragmentRegistryAPI {
// (undocumented)
register(...fragments: DocumentNode[]): this;
// (undocumented)
resetCaches(): void;
// (undocumented)
transform<D extends DocumentNode>(document: D): D;
}

Expand Down
2 changes: 2 additions & 0 deletions .api-reports/api-report-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -885,6 +885,8 @@ interface FragmentRegistryAPI {
// (undocumented)
register(...fragments: DocumentNode[]): this;
// (undocumented)
resetCaches(): void;
// (undocumented)
transform<D extends DocumentNode>(document: D): D;
}

Expand Down
2 changes: 2 additions & 0 deletions .api-reports/api-report-utilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -1028,6 +1028,8 @@ interface FragmentRegistryAPI {
// (undocumented)
register(...fragments: DocumentNode[]): this;
// (undocumented)
resetCaches(): void;
// (undocumented)
transform<D extends DocumentNode>(document: D): D;
}

Expand Down
2 changes: 2 additions & 0 deletions .api-reports/api-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,8 @@ interface FragmentRegistryAPI {
// (undocumented)
register(...fragments: DocumentNode[]): this;
// (undocumented)
resetCaches(): void;
// (undocumented)
transform<D extends DocumentNode>(document: D): D;
}

Expand Down
5 changes: 5 additions & 0 deletions .changeset/violet-lions-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apollo/client": patch
---

InMemoryCache.gc now also triggers FragmentRegistry.resetCaches (if there is a FragmentRegistry)
4 changes: 2 additions & 2 deletions .size-limit.cjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const checks = [
{
path: "dist/apollo-client.min.cjs",
limit: "38142",
limit: "38164",
},
{
path: "dist/main.cjs",
Expand All @@ -10,7 +10,7 @@ const checks = [
{
path: "dist/index.js",
import: "{ ApolloClient, InMemoryCache, HttpLink }",
limit: "32167",
limit: "32188",
},
...[
"ApolloProvider",
Expand Down
1 change: 1 addition & 0 deletions src/cache/inmemory/fragmentRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface FragmentRegistryAPI {
register(...fragments: DocumentNode[]): this;
lookup(fragmentName: string): FragmentDefinitionNode | null;
transform<D extends DocumentNode>(document: D): D;
resetCaches(): void;
}

// As long as createFragmentRegistry is not imported or used, the
Expand Down
1 change: 1 addition & 0 deletions src/cache/inmemory/inMemoryCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ export class InMemoryCache extends ApolloCache<NormalizedCacheObject> {
canonicalStringify.reset();
print.reset();
this.addTypenameTransform.resetCache();
this.config.fragments?.resetCaches();
const ids = this.optimisticData.gc();
if (options && !this.txCount) {
if (options.resetResultCache) {
Expand Down

0 comments on commit 7d8e184

Please sign in to comment.