Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

InMemoryCache.gc: also trigger FragmentRegistry.resetCaches #11355

Merged
merged 4 commits into from
Nov 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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