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

documentTransform: use optimism and WeakCache #11389

Merged
merged 13 commits into from
Dec 1, 2023
Merged
5 changes: 0 additions & 5 deletions .api-reports/api-report-core.md
Original file line number Diff line number Diff line change
Expand Up @@ -594,11 +594,6 @@ export class DocumentTransform {
// (undocumented)
concat(otherTransform: DocumentTransform): DocumentTransform;
// (undocumented)
getStableCacheEntry(document: DocumentNode): {
key: DocumentTransformCacheKey;
value?: DocumentNode | undefined;
} | undefined;
// (undocumented)
static identity(): DocumentTransform;
// (undocumented)
resetCache(): void;
Expand Down
8 changes: 2 additions & 6 deletions .api-reports/api-report-react.md
Original file line number Diff line number Diff line change
Expand Up @@ -721,11 +721,6 @@ class DocumentTransform {
// (undocumented)
concat(otherTransform: DocumentTransform): DocumentTransform;
// (undocumented)
getStableCacheEntry(document: DocumentNode): {
key: DocumentTransformCacheKey;
value?: DocumentNode | undefined;
} | undefined;
// (undocumented)
static identity(): DocumentTransform;
// (undocumented)
resetCache(): void;
Expand All @@ -742,6 +737,8 @@ type DocumentTransformCacheKey = ReadonlyArray<unknown>;
interface DocumentTransformOptions {
// (undocumented)
cache?: boolean;
// Warning: (ae-forgotten-export) The symbol "DocumentTransformCacheKey" needs to be exported by the entry point index.d.ts
//
// (undocumented)
getCacheKey?: (document: DocumentNode) => DocumentTransformCacheKey | undefined;
}
Expand Down Expand Up @@ -2221,7 +2218,6 @@ interface WatchQueryOptions<TVariables extends OperationVariables = OperationVar
// src/core/watchQueryOptions.ts:191:3 - (ae-forgotten-export) The symbol "UpdateQueryFn" needs to be exported by the entry point index.d.ts
// src/react/hooks/useBackgroundQuery.ts:26:3 - (ae-forgotten-export) The symbol "FetchMoreFunction" needs to be exported by the entry point index.d.ts
// src/react/hooks/useBackgroundQuery.ts:27:3 - (ae-forgotten-export) The symbol "RefetchFunction" needs to be exported by the entry point index.d.ts
// src/utilities/graphql/DocumentTransform.ts:130:7 - (ae-forgotten-export) The symbol "DocumentTransformCacheKey" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)

Expand Down
8 changes: 2 additions & 6 deletions .api-reports/api-report-react_components.md
Original file line number Diff line number Diff line change
Expand Up @@ -628,11 +628,6 @@ class DocumentTransform {
// (undocumented)
concat(otherTransform: DocumentTransform): DocumentTransform;
// (undocumented)
getStableCacheEntry(document: DocumentNode): {
key: DocumentTransformCacheKey;
value?: DocumentNode | undefined;
} | undefined;
// (undocumented)
static identity(): DocumentTransform;
// (undocumented)
resetCache(): void;
Expand All @@ -649,6 +644,8 @@ type DocumentTransformCacheKey = ReadonlyArray<unknown>;
interface DocumentTransformOptions {
// (undocumented)
cache?: boolean;
// Warning: (ae-forgotten-export) The symbol "DocumentTransformCacheKey" needs to be exported by the entry point index.d.ts
//
// (undocumented)
getCacheKey?: (document: DocumentNode) => DocumentTransformCacheKey | undefined;
}
Expand Down Expand Up @@ -1753,7 +1750,6 @@ interface WatchQueryOptions<TVariables extends OperationVariables = OperationVar
// src/core/types.ts:178:3 - (ae-forgotten-export) The symbol "MutationQueryReducer" needs to be exported by the entry point index.d.ts
// src/core/types.ts:205:5 - (ae-forgotten-export) The symbol "Resolver" needs to be exported by the entry point index.d.ts
// src/core/watchQueryOptions.ts:191:3 - (ae-forgotten-export) The symbol "UpdateQueryFn" needs to be exported by the entry point index.d.ts
// src/utilities/graphql/DocumentTransform.ts:130:7 - (ae-forgotten-export) The symbol "DocumentTransformCacheKey" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)

Expand Down
8 changes: 2 additions & 6 deletions .api-reports/api-report-react_context.md
Original file line number Diff line number Diff line change
Expand Up @@ -611,11 +611,6 @@ class DocumentTransform {
// (undocumented)
concat(otherTransform: DocumentTransform): DocumentTransform;
// (undocumented)
getStableCacheEntry(document: DocumentNode): {
key: DocumentTransformCacheKey;
value?: DocumentNode | undefined;
} | undefined;
// (undocumented)
static identity(): DocumentTransform;
// (undocumented)
resetCache(): void;
Expand All @@ -632,6 +627,8 @@ type DocumentTransformCacheKey = ReadonlyArray<unknown>;
interface DocumentTransformOptions {
// (undocumented)
cache?: boolean;
// Warning: (ae-forgotten-export) The symbol "DocumentTransformCacheKey" needs to be exported by the entry point index.d.ts
//
// (undocumented)
getCacheKey?: (document: DocumentNode) => DocumentTransformCacheKey | undefined;
}
Expand Down Expand Up @@ -1649,7 +1646,6 @@ interface WatchQueryOptions<TVariables extends OperationVariables = OperationVar
// src/core/types.ts:178:3 - (ae-forgotten-export) The symbol "MutationQueryReducer" needs to be exported by the entry point index.d.ts
// src/core/types.ts:205:5 - (ae-forgotten-export) The symbol "Resolver" needs to be exported by the entry point index.d.ts
// src/core/watchQueryOptions.ts:191:3 - (ae-forgotten-export) The symbol "UpdateQueryFn" needs to be exported by the entry point index.d.ts
// src/utilities/graphql/DocumentTransform.ts:130:7 - (ae-forgotten-export) The symbol "DocumentTransformCacheKey" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)

Expand Down
8 changes: 2 additions & 6 deletions .api-reports/api-report-react_hoc.md
Original file line number Diff line number Diff line change
Expand Up @@ -613,11 +613,6 @@ class DocumentTransform {
// (undocumented)
concat(otherTransform: DocumentTransform): DocumentTransform;
// (undocumented)
getStableCacheEntry(document: DocumentNode): {
key: DocumentTransformCacheKey;
value?: DocumentNode | undefined;
} | undefined;
// (undocumented)
static identity(): DocumentTransform;
// (undocumented)
resetCache(): void;
Expand All @@ -634,6 +629,8 @@ type DocumentTransformCacheKey = ReadonlyArray<unknown>;
interface DocumentTransformOptions {
// (undocumented)
cache?: boolean;
// Warning: (ae-forgotten-export) The symbol "DocumentTransformCacheKey" needs to be exported by the entry point index.d.ts
//
// (undocumented)
getCacheKey?: (document: DocumentNode) => DocumentTransformCacheKey | undefined;
}
Expand Down Expand Up @@ -1694,7 +1691,6 @@ export function withSubscription<TProps extends TGraphQLVariables | {} = {}, TDa
// src/core/types.ts:178:3 - (ae-forgotten-export) The symbol "MutationQueryReducer" needs to be exported by the entry point index.d.ts
// src/core/types.ts:205:5 - (ae-forgotten-export) The symbol "Resolver" needs to be exported by the entry point index.d.ts
// src/core/watchQueryOptions.ts:191:3 - (ae-forgotten-export) The symbol "UpdateQueryFn" needs to be exported by the entry point index.d.ts
// src/utilities/graphql/DocumentTransform.ts:130:7 - (ae-forgotten-export) The symbol "DocumentTransformCacheKey" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)

Expand Down
8 changes: 2 additions & 6 deletions .api-reports/api-report-react_hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -692,11 +692,6 @@ class DocumentTransform {
// (undocumented)
concat(otherTransform: DocumentTransform): DocumentTransform;
// (undocumented)
getStableCacheEntry(document: DocumentNode): {
key: DocumentTransformCacheKey;
value?: DocumentNode | undefined;
} | undefined;
// (undocumented)
static identity(): DocumentTransform;
// (undocumented)
resetCache(): void;
Expand All @@ -713,6 +708,8 @@ type DocumentTransformCacheKey = ReadonlyArray<unknown>;
interface DocumentTransformOptions {
// (undocumented)
cache?: boolean;
// Warning: (ae-forgotten-export) The symbol "DocumentTransformCacheKey" needs to be exported by the entry point index.d.ts
//
// (undocumented)
getCacheKey?: (document: DocumentNode) => DocumentTransformCacheKey | undefined;
}
Expand Down Expand Up @@ -2115,7 +2112,6 @@ interface WatchQueryOptions<TVariables extends OperationVariables = OperationVar
// src/core/watchQueryOptions.ts:191:3 - (ae-forgotten-export) The symbol "UpdateQueryFn" needs to be exported by the entry point index.d.ts
// src/react/hooks/useBackgroundQuery.ts:26:3 - (ae-forgotten-export) The symbol "FetchMoreFunction" needs to be exported by the entry point index.d.ts
// src/react/hooks/useBackgroundQuery.ts:27:3 - (ae-forgotten-export) The symbol "RefetchFunction" needs to be exported by the entry point index.d.ts
// src/utilities/graphql/DocumentTransform.ts:130:7 - (ae-forgotten-export) The symbol "DocumentTransformCacheKey" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)

Expand Down
8 changes: 2 additions & 6 deletions .api-reports/api-report-react_ssr.md
Original file line number Diff line number Diff line change
Expand Up @@ -581,11 +581,6 @@ class DocumentTransform {
// (undocumented)
concat(otherTransform: DocumentTransform): DocumentTransform;
// (undocumented)
getStableCacheEntry(document: DocumentNode): {
key: DocumentTransformCacheKey;
value?: DocumentNode | undefined;
} | undefined;
// (undocumented)
static identity(): DocumentTransform;
// (undocumented)
resetCache(): void;
Expand All @@ -602,6 +597,8 @@ type DocumentTransformCacheKey = ReadonlyArray<unknown>;
interface DocumentTransformOptions {
// (undocumented)
cache?: boolean;
// Warning: (ae-forgotten-export) The symbol "DocumentTransformCacheKey" needs to be exported by the entry point index.d.ts
//
// (undocumented)
getCacheKey?: (document: DocumentNode) => DocumentTransformCacheKey | undefined;
}
Expand Down Expand Up @@ -1635,7 +1632,6 @@ interface WatchQueryOptions<TVariables extends OperationVariables = OperationVar
// src/core/types.ts:178:3 - (ae-forgotten-export) The symbol "MutationQueryReducer" needs to be exported by the entry point index.d.ts
// src/core/types.ts:205:5 - (ae-forgotten-export) The symbol "Resolver" needs to be exported by the entry point index.d.ts
// src/core/watchQueryOptions.ts:191:3 - (ae-forgotten-export) The symbol "UpdateQueryFn" needs to be exported by the entry point index.d.ts
// src/utilities/graphql/DocumentTransform.ts:130:7 - (ae-forgotten-export) The symbol "DocumentTransformCacheKey" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)

Expand Down
8 changes: 2 additions & 6 deletions .api-reports/api-report-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -575,11 +575,6 @@ class DocumentTransform {
// (undocumented)
concat(otherTransform: DocumentTransform): DocumentTransform;
// (undocumented)
getStableCacheEntry(document: DocumentNode): {
key: DocumentTransformCacheKey;
value?: DocumentNode | undefined;
} | undefined;
// (undocumented)
static identity(): DocumentTransform;
// (undocumented)
resetCache(): void;
Expand All @@ -596,6 +591,8 @@ type DocumentTransformCacheKey = ReadonlyArray<unknown>;
interface DocumentTransformOptions {
// (undocumented)
cache?: boolean;
// Warning: (ae-forgotten-export) The symbol "DocumentTransformCacheKey" needs to be exported by the entry point index.d.ts
//
// (undocumented)
getCacheKey?: (document: DocumentNode) => DocumentTransformCacheKey | undefined;
}
Expand Down Expand Up @@ -1698,7 +1695,6 @@ export function withWarningSpy<TArgs extends any[], TResult>(it: (...args: TArgs
// src/core/types.ts:178:3 - (ae-forgotten-export) The symbol "MutationQueryReducer" needs to be exported by the entry point index.d.ts
// src/core/types.ts:205:5 - (ae-forgotten-export) The symbol "Resolver" needs to be exported by the entry point index.d.ts
// src/core/watchQueryOptions.ts:191:3 - (ae-forgotten-export) The symbol "UpdateQueryFn" needs to be exported by the entry point index.d.ts
// src/utilities/graphql/DocumentTransform.ts:130:7 - (ae-forgotten-export) The symbol "DocumentTransformCacheKey" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)

Expand Down
8 changes: 2 additions & 6 deletions .api-reports/api-report-testing_core.md
Original file line number Diff line number Diff line change
Expand Up @@ -574,11 +574,6 @@ class DocumentTransform {
// (undocumented)
concat(otherTransform: DocumentTransform): DocumentTransform;
// (undocumented)
getStableCacheEntry(document: DocumentNode): {
key: DocumentTransformCacheKey;
value?: DocumentNode | undefined;
} | undefined;
// (undocumented)
static identity(): DocumentTransform;
// (undocumented)
resetCache(): void;
Expand All @@ -595,6 +590,8 @@ type DocumentTransformCacheKey = ReadonlyArray<unknown>;
interface DocumentTransformOptions {
// (undocumented)
cache?: boolean;
// Warning: (ae-forgotten-export) The symbol "DocumentTransformCacheKey" needs to be exported by the entry point index.d.ts
//
// (undocumented)
getCacheKey?: (document: DocumentNode) => DocumentTransformCacheKey | undefined;
}
Expand Down Expand Up @@ -1654,7 +1651,6 @@ export function withWarningSpy<TArgs extends any[], TResult>(it: (...args: TArgs
// src/core/types.ts:178:3 - (ae-forgotten-export) The symbol "MutationQueryReducer" needs to be exported by the entry point index.d.ts
// src/core/types.ts:205:5 - (ae-forgotten-export) The symbol "Resolver" needs to be exported by the entry point index.d.ts
// src/core/watchQueryOptions.ts:191:3 - (ae-forgotten-export) The symbol "UpdateQueryFn" needs to be exported by the entry point index.d.ts
// src/utilities/graphql/DocumentTransform.ts:130:7 - (ae-forgotten-export) The symbol "DocumentTransformCacheKey" needs to be exported by the entry point index.d.ts

// (No @packageDocumentation comment for this package)

Expand Down
5 changes: 0 additions & 5 deletions .api-reports/api-report-utilities.md
Original file line number Diff line number Diff line change
Expand Up @@ -752,11 +752,6 @@ export class DocumentTransform {
// (undocumented)
concat(otherTransform: DocumentTransform): DocumentTransform;
// (undocumented)
getStableCacheEntry(document: DocumentNode): {
key: DocumentTransformCacheKey;
value?: DocumentNode | undefined;
} | undefined;
// (undocumented)
static identity(): DocumentTransform;
// (undocumented)
resetCache(): void;
Expand Down
5 changes: 0 additions & 5 deletions .api-reports/api-report.md
Original file line number Diff line number Diff line change
Expand Up @@ -744,11 +744,6 @@ export class DocumentTransform {
// (undocumented)
concat(otherTransform: DocumentTransform): DocumentTransform;
// (undocumented)
getStableCacheEntry(document: DocumentNode): {
key: DocumentTransformCacheKey;
value?: DocumentNode | undefined;
} | undefined;
// (undocumented)
static identity(): DocumentTransform;
// (undocumented)
resetCache(): void;
Expand Down
5 changes: 5 additions & 0 deletions .changeset/dirty-kids-crash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apollo/client": patch
---

`documentTransform`: use `optimism` and `WeakCache` instead of directly storing data on the `Trie`
5 changes: 5 additions & 0 deletions .changeset/polite-avocados-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@apollo/client": patch
---

`print`: use `WeakCache` instead of `WeakMap`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps we just need to merge release-3.9 back into this branch? Odd this made it into the diff.

1 change: 1 addition & 0 deletions .size-limit.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ const checks = [
"react",
"react-dom",
"@graphql-typed-document-node/core",
"@wry/caches",
"@wry/context",
"@wry/equality",
"@wry/trie",
Expand Down
4 changes: 2 additions & 2 deletions .size-limits.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"dist/apollo-client.min.cjs": 38164,
"import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 32188
"dist/apollo-client.min.cjs": 38179,
"import { ApolloClient, InMemoryCache, HttpLink } from \"dist/index.js\" (production)": 32209
}
21 changes: 17 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,13 @@
},
"dependencies": {
"@graphql-typed-document-node/core": "^3.1.1",
"@wry/caches": "^1.0.0",
"@wry/context": "^0.7.3",
"@wry/equality": "^0.5.6",
"@wry/trie": "^0.4.3",
"graphql-tag": "^2.12.6",
"hoist-non-react-statics": "^3.3.2",
"optimism": "^0.17.5",
"optimism": "^0.18.0-pre.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the stable 0.18.0 version that is now released. This was merged into main already though so merging main -> release-3.9 -> this branch should resolve this.

"prop-types": "^15.7.2",
"rehackt": "0.0.3",
"response-iterator": "^0.2.6",
Expand Down
Loading
Loading