Skip to content
Draft
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
5 changes: 5 additions & 0 deletions .changeset/hungry-pens-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apollo/client": patch
---

Use a WeakCache as backend for `executeSelectionSet`, `executeSubSelectedArray` and `maybeBroadcastWatch`.
2 changes: 2 additions & 0 deletions src/cache/inmemory/inMemoryCache.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import { Policies } from "./policies.js";
import { hasOwn, normalizeConfig, shouldCanonizeResults } from "./helpers.js";
import type { OperationVariables } from "../../core/index.js";
import { getInMemoryCacheMemoryInternals } from "../../utilities/caching/getMemoryInternals.js";
import { WeakCache } from "@wry/caches";

type BroadcastOptions = Pick<
Cache.BatchOptions<InMemoryCache>,
Expand Down Expand Up @@ -131,6 +132,7 @@ export class InMemoryCache extends ApolloCache<NormalizedCacheObject> {
return this.broadcastWatch(c, options);
},
{
cache: WeakCache,
max:
this.config.resultCacheMaxSize ||
cacheSizes["inMemoryCache.maybeBroadcastWatch"] ||
Expand Down
3 changes: 3 additions & 0 deletions src/cache/inmemory/readFromStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type { DocumentNode, FieldNode, SelectionSetNode } from "graphql";
import { Kind } from "graphql";
import type { OptimisticWrapperFunction } from "optimism";
import { wrap } from "optimism";
import { WeakCache } from "@wry/caches";

import type {
Reference,
Expand Down Expand Up @@ -195,6 +196,7 @@ export class StoreReader {
return this.execSelectionSetImpl(options);
},
{
cache: WeakCache,
max:
this.config.resultCacheMaxSize ||
cacheSizes["inMemoryCache.executeSelectionSet"] ||
Expand Down Expand Up @@ -224,6 +226,7 @@ export class StoreReader {
return this.execSubSelectedArrayImpl(options);
},
{
cache: WeakCache,
max:
this.config.resultCacheMaxSize ||
cacheSizes["inMemoryCache.executeSubSelectedArray"] ||
Expand Down
Loading