Skip to content

Commit b446daf

Browse files
Merge pull request #472 from apollographql/main
Create a new pull request by comparing changes across two branches
2 parents 122874b + b49983b commit b446daf

File tree

16 files changed

+193
-80
lines changed

16 files changed

+193
-80
lines changed

.api-reports/api-report-utilities_internal.api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,9 @@ export const AutoCleanedWeakCache: typeof WeakCache;
6060
// @internal @deprecated (undocumented)
6161
export type AutoCleanedWeakCache<K extends object, V> = WeakCache<K, V>;
6262

63+
// @public
64+
export function bindCacheKey(...prebound: object[]): (...args: any) => object;
65+
6366
// @public
6467
export const canonicalStringify: ((value: any) => string) & {
6568
reset(): void;

.api-reports/api-report.api.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2704,7 +2704,7 @@ interface WriteContext extends ReadMergeModifyContext {
27042704

27052705
// Warnings were encountered during analysis:
27062706
//
2707-
// src/cache/core/cache.ts:94:9 - (ae-forgotten-export) The symbol "MissingTree" needs to be exported by the entry point index.d.ts
2707+
// src/cache/core/cache.ts:95:9 - (ae-forgotten-export) The symbol "MissingTree" needs to be exported by the entry point index.d.ts
27082708
// src/cache/inmemory/policies.ts:98:3 - (ae-forgotten-export) The symbol "FragmentMap" needs to be exported by the entry point index.d.ts
27092709
// src/cache/inmemory/policies.ts:167:3 - (ae-forgotten-export) The symbol "KeySpecifier" needs to be exported by the entry point index.d.ts
27102710
// src/cache/inmemory/policies.ts:167:3 - (ae-forgotten-export) The symbol "KeyArgsFunction" needs to be exported by the entry point index.d.ts

.size-limits.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (CJS)": 44088,
3-
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production) (CJS)": 38925,
4-
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\"": 33546,
5-
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production)": 27621
2+
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (CJS)": 44208,
3+
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production) (CJS)": 39079,
4+
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\"": 33629,
5+
"import { ApolloClient, InMemoryCache, HttpLink } from \"@apollo/client\" (production)": 27641
66
}

CHANGELOG.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,25 @@
11
# @apollo/client
22

3+
## 4.0.13
4+
5+
### Patch Changes
6+
7+
- [#13094](https://github.com/apollographql/apollo-client/pull/13094) [`9cbe2c2`](https://github.com/apollographql/apollo-client/commit/9cbe2c2dd2282ac861327d3c394578db7706df05) Thanks [@phryneas](https://github.com/phryneas)! - Ensure that `compact` and `mergeOptions` preserve symbol keys.
8+
9+
This fixes an issue where the change introduced in 4.0.11 via #13049 would not
10+
be applied if `defaultOptions` for `watchQuery` were declared.
11+
12+
Please note that `compact` and `mergeOptions` are considered internal utilities
13+
and they might have similar behavior changes in future releases.
14+
Do not use them in your application code - a change like this is not considered
15+
breaking and will not be announced as such.
16+
17+
## 4.0.12
18+
19+
### Patch Changes
20+
21+
- [#13077](https://github.com/apollographql/apollo-client/pull/13077) [`f322460`](https://github.com/apollographql/apollo-client/commit/f322460fe9baae82c0980dd082c1b6b4956a4951) Thanks [@phryneas](https://github.com/phryneas)! - Fix a potential memory leak where Trie nodes would remain in memory too long.
22+
323
## 4.0.11
424

525
### Patch Changes

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@apollo/client",
3-
"version": "4.0.11",
3+
"version": "4.0.13",
44
"description": "A fully-featured caching GraphQL client.",
55
"private": true,
66
"keywords": [

patches/optimism+0.18.0.patch

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
diff --git a/node_modules/optimism/lib/index.d.ts b/node_modules/optimism/lib/index.d.ts
2+
index 06c3327..19868ac 100644
3+
--- a/node_modules/optimism/lib/index.d.ts
4+
+++ b/node_modules/optimism/lib/index.d.ts
5+
@@ -25,7 +25,7 @@ export interface CommonCacheConstructor<TCacheKey, TResult, TArgs extends any[]>
6+
export type OptimisticWrapOptions<TArgs extends any[], TKeyArgs extends any[] = TArgs, TCacheKey = any, TResult = any> = {
7+
max?: number;
8+
keyArgs?: (...args: TArgs) => TKeyArgs;
9+
- makeCacheKey?: (...args: NoInfer<TKeyArgs>) => TCacheKey | undefined;
10+
+ makeCacheKey: (...args: NoInfer<TKeyArgs>) => TCacheKey | undefined;
11+
normalizeResult?: (newer: TResult, older: TResult) => TResult;
12+
subscribe?: (...args: TArgs) => void | (() => any);
13+
cache?: CommonCache<NoInfer<TCacheKey>, Entry<NoInfer<TArgs>, NoInfer<TResult>>> | CommonCacheConstructor<NoInfer<TCacheKey>, NoInfer<TResult>, NoInfer<TArgs>>;

src/__tests__/__snapshots__/exports.ts.snap

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,7 @@ Array [
419419
"AutoCleanedWeakCache",
420420
"DeepMerger",
421421
"argumentsObjectFromField",
422+
"bindCacheKey",
422423
"canUseDOM",
423424
"canonicalStringify",
424425
"checkDocument",

src/cache/core/cache.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { cacheSizes } from "@apollo/client/utilities";
1818
import { __DEV__ } from "@apollo/client/utilities/environment";
1919
import type { NoInfer } from "@apollo/client/utilities/internal";
2020
import {
21+
bindCacheKey,
2122
equalByQuery,
2223
getApolloCacheMemoryInternals,
2324
getFragmentDefinition,
@@ -427,6 +428,7 @@ export abstract class ApolloCache {
427428
cacheSizes["cache.fragmentQueryDocuments"] ||
428429
defaultCacheSizes["cache.fragmentQueryDocuments"],
429430
cache: WeakCache,
431+
makeCacheKey: bindCacheKey(this),
430432
});
431433

432434
/**

src/cache/inmemory/fragmentRegistry.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@ import { wrap } from "optimism";
1010

1111
import { cacheSizes } from "@apollo/client/utilities";
1212
import type { FragmentMap } from "@apollo/client/utilities/internal";
13-
import { getFragmentDefinitions } from "@apollo/client/utilities/internal";
13+
import {
14+
bindCacheKey,
15+
getFragmentDefinitions,
16+
} from "@apollo/client/utilities/internal";
1417

1518
import { defaultCacheSizes } from "../../utilities/caching/sizes.js";
1619
export interface FragmentRegistryAPI {
@@ -69,18 +72,23 @@ class FragmentRegistry implements FragmentRegistryAPI {
6972
public resetCaches() {
7073
const proto = FragmentRegistry.prototype;
7174
this.invalidate = (this.lookup = wrap(proto.lookup.bind(this), {
75+
// This is intentionally an identity function - a string cannot be keyed weakly.
76+
// This is not a memory leak, as lifetime is bound to the `FragmentRegistry` instance,
77+
// and max size is configurable.
7278
makeCacheKey: (arg) => arg,
7379
max:
7480
cacheSizes["fragmentRegistry.lookup"] ||
7581
defaultCacheSizes["fragmentRegistry.lookup"],
7682
})).dirty; // This dirty function is bound to the wrapped lookup method.
7783
this.transform = wrap(proto.transform.bind(this), {
84+
makeCacheKey: bindCacheKey(this),
7885
cache: WeakCache,
7986
max:
8087
cacheSizes["fragmentRegistry.transform"] ||
8188
defaultCacheSizes["fragmentRegistry.transform"],
8289
});
8390
this.findFragmentSpreads = wrap(proto.findFragmentSpreads.bind(this), {
91+
makeCacheKey: bindCacheKey(this),
8492
cache: WeakCache,
8593
max:
8694
cacheSizes["fragmentRegistry.findFragmentSpreads"] ||

0 commit comments

Comments
 (0)