@apollo/client 3.9.0-alpha.5 → 3.9.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.changeset/chatty-comics-yawn.md +8 -0
- package/.changeset/curvy-seas-hope.md +13 -0
- package/.changeset/dirty-tigers-matter.md +13 -0
- package/.changeset/late-rabbits-protect.md +7 -0
- package/.changeset/mighty-coats-check.md +47 -0
- package/.changeset/pre.json +15 -1
- package/.changeset/rare-snakes-melt.md +24 -0
- package/.changeset/smooth-plums-shout.md +5 -0
- package/.changeset/spicy-drinks-camp.md +5 -0
- package/.changeset/swift-zoos-collect.md +19 -0
- package/.changeset/thick-tips-cry.md +9 -0
- package/.changeset/tough-timers-begin.md +8 -0
- package/.changeset/unlucky-rats-decide.md +5 -0
- package/.changeset/wet-forks-rhyme.md +5 -0
- package/.changeset/wise-news-grab.md +7 -0
- package/CHANGELOG.md +151 -4
- package/apollo-client.cjs +337 -88
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +78 -6
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +78 -6
- package/cache/core/cache.d.ts +9 -0
- package/cache/core/cache.js +11 -2
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +7 -0
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/core/types/DataProxy.d.ts +12 -0
- package/cache/core/types/DataProxy.js.map +1 -1
- package/cache/core/types/common.d.ts +4 -0
- package/cache/core/types/common.js.map +1 -1
- package/cache/inmemory/fragmentRegistry.js +19 -3
- package/cache/inmemory/fragmentRegistry.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +9 -0
- package/cache/inmemory/inMemoryCache.js +8 -2
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/readFromStore.js +7 -3
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +18 -0
- package/cache/inmemory/types.js.map +1 -1
- package/core/ApolloClient.d.ts +82 -0
- package/core/ApolloClient.js +4 -0
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +2 -0
- package/core/ObservableQuery.js +15 -5
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +1 -0
- package/core/QueryInfo.js +4 -0
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +1 -1
- package/core/QueryManager.js +15 -10
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +107 -16
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +107 -16
- package/core/watchQueryOptions.d.ts +20 -1
- package/core/watchQueryOptions.js.map +1 -1
- package/dev/dev.cjs +1 -1
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +1 -1
- package/link/core/ApolloLink.d.ts +15 -0
- package/link/core/ApolloLink.js +8 -4
- package/link/core/ApolloLink.js.map +1 -1
- package/link/core/core.cjs +8 -4
- package/link/core/core.cjs.map +1 -1
- package/link/core/core.cjs.native.js +8 -4
- package/link/persisted-queries/index.d.ts +11 -1
- package/link/persisted-queries/index.js +28 -3
- package/link/persisted-queries/index.js.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs +26 -3
- package/link/persisted-queries/persisted-queries.cjs.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.native.js +26 -3
- package/link/remove-typename/remove-typename.cjs +18 -2
- package/link/remove-typename/remove-typename.cjs.map +1 -1
- package/link/remove-typename/remove-typename.cjs.native.js +18 -2
- package/link/remove-typename/removeTypenameFromVariables.d.ts +9 -1
- package/link/remove-typename/removeTypenameFromVariables.js +19 -3
- package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
- package/link/retry/retry.cjs +15 -74
- package/link/retry/retry.cjs.map +1 -1
- package/link/retry/retry.cjs.native.js +15 -74
- package/link/retry/retryLink.js +15 -93
- package/link/retry/retryLink.js.map +1 -1
- package/package.json +21 -21
- package/react/components/Mutation.d.ts +6 -0
- package/react/components/Mutation.js +6 -0
- package/react/components/Mutation.js.map +1 -1
- package/react/components/Query.d.ts +6 -0
- package/react/components/Query.js +6 -0
- package/react/components/Query.js.map +1 -1
- package/react/components/Subscription.d.ts +6 -0
- package/react/components/Subscription.js +6 -0
- package/react/components/Subscription.js.map +1 -1
- package/react/components/components.cjs.map +1 -1
- package/react/hoc/graphql.d.ts +5 -0
- package/react/hoc/graphql.js +5 -0
- package/react/hoc/graphql.js.map +1 -1
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/mutation-hoc.d.ts +5 -0
- package/react/hoc/mutation-hoc.js +5 -0
- package/react/hoc/mutation-hoc.js.map +1 -1
- package/react/hoc/query-hoc.d.ts +5 -0
- package/react/hoc/query-hoc.js +5 -0
- package/react/hoc/query-hoc.js.map +1 -1
- package/react/hoc/subscription-hoc.d.ts +5 -0
- package/react/hoc/subscription-hoc.js +5 -0
- package/react/hoc/subscription-hoc.js.map +1 -1
- package/react/hoc/withApollo.d.ts +5 -0
- package/react/hoc/withApollo.js +5 -0
- package/react/hoc/withApollo.js.map +1 -1
- package/react/hooks/hooks.cjs +48 -257
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +48 -257
- package/react/hooks/index.d.ts +2 -0
- package/react/hooks/index.js +1 -0
- package/react/hooks/index.js.map +1 -1
- package/react/hooks/useBackgroundQuery.d.ts +13 -10
- package/react/hooks/useBackgroundQuery.js +2 -4
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +2 -2
- package/react/hooks/useLoadableQuery.js +2 -4
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.d.ts +35 -0
- package/react/hooks/useQueryRefHandlers.js +48 -0
- package/react/hooks/useQueryRefHandlers.js.map +1 -0
- package/react/hooks/useReadQuery.d.ts +1 -1
- package/react/hooks/useReadQuery.js +8 -2
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSuspenseQuery.js +1 -1
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/index.d.ts +2 -0
- package/react/index.js +1 -0
- package/react/index.js.map +1 -1
- package/react/{cache → internal/cache}/QueryReference.d.ts +13 -7
- package/react/{cache → internal/cache}/QueryReference.js +93 -57
- package/react/internal/cache/QueryReference.js.map +1 -0
- package/react/{cache → internal/cache}/SuspenseCache.d.ts +1 -1
- package/react/{cache → internal/cache}/SuspenseCache.js +1 -1
- package/react/internal/cache/SuspenseCache.js.map +1 -0
- package/react/{cache → internal/cache}/getSuspenseCache.d.ts +3 -3
- package/react/internal/cache/getSuspenseCache.js.map +1 -0
- package/react/internal/cache/types.js.map +1 -0
- package/react/internal/index.d.ts +6 -0
- package/react/internal/index.js +3 -0
- package/react/internal/index.js.map +1 -0
- package/react/internal/internal.cjs +283 -0
- package/react/internal/internal.cjs.map +1 -0
- package/react/internal/internal.cjs.native.js +283 -0
- package/react/internal/package.json +8 -0
- package/react/parser/index.js +6 -3
- package/react/parser/index.js.map +1 -1
- package/react/parser/parser.cjs +11 -3
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +11 -3
- package/react/query-preloader/createQueryPreloader.d.ts +253 -0
- package/react/query-preloader/createQueryPreloader.js +29 -0
- package/react/query-preloader/createQueryPreloader.js.map +1 -0
- package/react/react.cjs +14 -2
- package/react/react.cjs.map +1 -1
- package/react/react.cjs.native.js +14 -2
- package/react/types/types.d.ts +7 -1
- package/react/types/types.js.map +1 -1
- package/testing/internal/ObservableStream.js +16 -8
- package/testing/internal/ObservableStream.js.map +1 -1
- package/testing/internal/index.d.ts +4 -0
- package/testing/internal/index.js +2 -0
- package/testing/internal/index.js.map +1 -1
- package/testing/internal/renderHelpers.d.ts +12 -0
- package/testing/internal/renderHelpers.js +22 -0
- package/testing/internal/renderHelpers.js.map +1 -0
- package/testing/internal/scenarios/index.d.ts +41 -0
- package/testing/internal/scenarios/index.js +48 -0
- package/testing/internal/scenarios/index.js.map +1 -0
- package/testing/matchers/index.js +2 -0
- package/testing/matchers/index.js.map +1 -1
- package/testing/matchers/toBeDisposed.d.ts +3 -0
- package/testing/matchers/toBeDisposed.js +26 -0
- package/testing/matchers/toBeDisposed.js.map +1 -0
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.js +1 -1
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.js.map +1 -1
- package/utilities/caching/caches.d.ts +34 -0
- package/utilities/caching/caches.js +64 -0
- package/utilities/caching/caches.js.map +1 -0
- package/utilities/caching/getMemoryInternals.d.ts +76 -0
- package/utilities/caching/getMemoryInternals.js +112 -0
- package/utilities/caching/getMemoryInternals.js.map +1 -0
- package/utilities/caching/index.d.ts +4 -0
- package/utilities/caching/index.js +3 -0
- package/utilities/caching/index.js.map +1 -0
- package/utilities/caching/sizes.d.ts +311 -0
- package/utilities/caching/sizes.js +27 -0
- package/utilities/caching/sizes.js.map +1 -0
- package/utilities/common/canUse.js +1 -1
- package/utilities/common/canUse.js.map +1 -1
- package/utilities/common/canonicalStringify.js +8 -2
- package/utilities/common/canonicalStringify.js.map +1 -1
- package/utilities/globals/globals.cjs +1 -1
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +1 -1
- package/utilities/graphql/DocumentTransform.d.ts +14 -1
- package/utilities/graphql/DocumentTransform.js +9 -5
- package/utilities/graphql/DocumentTransform.js.map +1 -1
- package/utilities/graphql/print.js +6 -2
- package/utilities/graphql/print.js.map +1 -1
- package/utilities/index.d.ts +2 -0
- package/utilities/index.js +1 -0
- package/utilities/index.js.map +1 -1
- package/utilities/utilities.cjs +57 -9
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +57 -9
- package/version.js +1 -1
- package/react/cache/QueryReference.js.map +0 -1
- package/react/cache/SuspenseCache.js.map +0 -1
- package/react/cache/getSuspenseCache.js.map +0 -1
- package/react/cache/index.d.ts +0 -3
- package/react/cache/index.js +0 -2
- package/react/cache/index.js.map +0 -1
- package/react/cache/types.js.map +0 -1
- /package/react/{cache → internal/cache}/getSuspenseCache.js +0 -0
- /package/react/{cache → internal/cache}/types.d.ts +0 -0
- /package/react/{cache → internal/cache}/types.js +0 -0
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
declare global {
|
|
2
|
+
interface Window {
|
|
3
|
+
[cacheSizeSymbol]?: Partial<CacheSizes>;
|
|
4
|
+
}
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* The cache sizes used by various Apollo Client caches.
|
|
8
|
+
*
|
|
9
|
+
* @remarks
|
|
10
|
+
* All configurable caches hold memoized values. If an item is
|
|
11
|
+
* cache-collected, it incurs only a small performance impact and
|
|
12
|
+
* doesn't cause data loss. A smaller cache size might save you memory.
|
|
13
|
+
*
|
|
14
|
+
* You should choose cache sizes appropriate for storing a reasonable
|
|
15
|
+
* number of values rather than every value. To prevent too much recalculation,
|
|
16
|
+
* choose cache sizes that are at least large enough to hold memoized values for
|
|
17
|
+
* all hooks/queries on the screen at any given time.
|
|
18
|
+
*/
|
|
19
|
+
export interface CacheSizes {
|
|
20
|
+
/**
|
|
21
|
+
* Cache size for the [`print`](https://github.com/apollographql/apollo-client/blob/main/src/utilities/graphql/print.ts) function.
|
|
22
|
+
*
|
|
23
|
+
* It is called with transformed `DocumentNode`s.
|
|
24
|
+
*
|
|
25
|
+
* @defaultValue
|
|
26
|
+
* Defaults to `2000`.
|
|
27
|
+
*
|
|
28
|
+
* @remarks
|
|
29
|
+
* This method is called to transform a GraphQL query AST parsed by `gql`
|
|
30
|
+
* back into a GraphQL string.
|
|
31
|
+
*
|
|
32
|
+
* @privateRemarks
|
|
33
|
+
* This method is called from the `QueryManager` and various `ApolloLink`s,
|
|
34
|
+
* always with the "serverQuery", so the server-facing part of a transformed
|
|
35
|
+
* `DocumentNode`.
|
|
36
|
+
*/
|
|
37
|
+
print: number;
|
|
38
|
+
/**
|
|
39
|
+
* Cache size for the [`parser`](https://github.com/apollographql/apollo-client/blob/main/src/react/parser/index.ts) function.
|
|
40
|
+
*
|
|
41
|
+
* It is called with user-provided `DocumentNode`s.
|
|
42
|
+
*
|
|
43
|
+
* @defaultValue
|
|
44
|
+
* Defaults to `1000`.
|
|
45
|
+
*
|
|
46
|
+
* @remarks
|
|
47
|
+
* This method is called by HOCs and hooks.
|
|
48
|
+
*
|
|
49
|
+
* @privateRemarks
|
|
50
|
+
* This function is used directly in HOCs, and nowadays mainly accessed by
|
|
51
|
+
* calling `verifyDocumentType` from various hooks.
|
|
52
|
+
* It is called with a user-provided DocumentNode.
|
|
53
|
+
*/
|
|
54
|
+
parser: number;
|
|
55
|
+
/**
|
|
56
|
+
* Cache size for the cache of [`DocumentTransform`](https://github.com/apollographql/apollo-client/blob/main/src/utilities/graphql/DocumentTransform.ts)
|
|
57
|
+
* instances with the `cache` option set to `true`.
|
|
58
|
+
*
|
|
59
|
+
* Can be called with user-defined or already-transformed `DocumentNode`s.
|
|
60
|
+
*
|
|
61
|
+
* @defaultValue
|
|
62
|
+
* Defaults to `2000`.
|
|
63
|
+
*
|
|
64
|
+
* @remarks
|
|
65
|
+
* The cache size here should be chosen with other `DocumentTransform`s in mind.
|
|
66
|
+
* For example, if there was a `DocumentTransform` that would take `x` `DocumentNode`s,
|
|
67
|
+
* and returned a differently-transformed `DocumentNode` depending if the app is
|
|
68
|
+
* online or offline, then we assume that the cache returns `2*x` documents.
|
|
69
|
+
* If that were concatenated with another `DocumentTransform` that would
|
|
70
|
+
* also duplicate the cache size, you'd need to account for `4*x` documents
|
|
71
|
+
* returned by the second transform.
|
|
72
|
+
*
|
|
73
|
+
* Due to an implementation detail of Apollo Client, if you use custom document
|
|
74
|
+
* transforms you should always add `n` (the "base" number of user-provided
|
|
75
|
+
* Documents) to the resulting cache size.
|
|
76
|
+
*
|
|
77
|
+
* If we assume that the user-provided transforms receive `n` documents and
|
|
78
|
+
* return `n` documents, the cache size should be `2*n`.
|
|
79
|
+
*
|
|
80
|
+
* If we assume that the chain of user-provided transforms receive `n` documents and
|
|
81
|
+
* return `4*n` documents, the cache size should be `5*n`.
|
|
82
|
+
*
|
|
83
|
+
* This size should also then be used in every other cache that mentions that
|
|
84
|
+
* it operates on a "transformed" `DocumentNode`.
|
|
85
|
+
*
|
|
86
|
+
* @privateRemarks
|
|
87
|
+
* Cache size for the `performWork` method of each [`DocumentTransform`](https://github.com/apollographql/apollo-client/blob/main/src/utilities/graphql/DocumentTransform.ts).
|
|
88
|
+
*
|
|
89
|
+
* No user-provided DocumentNode will actually be "the last one", as we run the
|
|
90
|
+
* `defaultDocumentTransform` before *and* after the user-provided transforms.
|
|
91
|
+
* For that reason, we need the extra `n` here - `n` for "before transformation"
|
|
92
|
+
* plus the actual maximum cache size of the user-provided transform chain.
|
|
93
|
+
*
|
|
94
|
+
* This method is called from `transformDocument`, which is called from
|
|
95
|
+
* `QueryManager` with a user-provided DocumentNode.
|
|
96
|
+
* It is also called with already-transformed DocumentNodes, assuming the
|
|
97
|
+
* user provided additional transforms.
|
|
98
|
+
*
|
|
99
|
+
*/
|
|
100
|
+
"documentTransform.cache": number;
|
|
101
|
+
/**
|
|
102
|
+
* A cache inside of [`QueryManager`](https://github.com/apollographql/apollo-client/blob/main/src/core/QueryManager.ts).
|
|
103
|
+
*
|
|
104
|
+
* It is called with transformed `DocumentNode`s.
|
|
105
|
+
*
|
|
106
|
+
* @defaultValue
|
|
107
|
+
* Defaults to `2000`.
|
|
108
|
+
*
|
|
109
|
+
* @privateRemarks
|
|
110
|
+
* Cache size for the `transformCache` used in the `getDocumentInfo` method of `QueryManager`.
|
|
111
|
+
* Called throughout the `QueryManager` with transformed DocumentNodes.
|
|
112
|
+
*/
|
|
113
|
+
"queryManager.getDocumentInfo": number;
|
|
114
|
+
/**
|
|
115
|
+
* A cache inside of [`PersistedQueryLink`](https://github.com/apollographql/apollo-client/blob/main/src/link/persisted-queries/index.ts).
|
|
116
|
+
*
|
|
117
|
+
* It is called with transformed `DocumentNode`s.
|
|
118
|
+
*
|
|
119
|
+
* @defaultValue
|
|
120
|
+
* Defaults to `2000`.
|
|
121
|
+
*
|
|
122
|
+
* @remarks
|
|
123
|
+
* This cache is used to cache the hashes of persisted queries.
|
|
124
|
+
*
|
|
125
|
+
* @privateRemarks
|
|
126
|
+
* Cache size for the `hashesByQuery` cache in the `PersistedQueryLink`.
|
|
127
|
+
*/
|
|
128
|
+
"PersistedQueryLink.persistedQueryHashes": number;
|
|
129
|
+
/**
|
|
130
|
+
* Cache used by [`canonicalStringify`](https://github.com/apollographql/apollo-client/blob/main/src/utilities/common/canonicalStringify.ts).
|
|
131
|
+
*
|
|
132
|
+
* @defaultValue
|
|
133
|
+
* Defaults to `1000`.
|
|
134
|
+
*
|
|
135
|
+
* @remarks
|
|
136
|
+
* This cache contains the sorted keys of objects that are stringified by
|
|
137
|
+
* `canonicalStringify`.
|
|
138
|
+
* It uses the stringified unsorted keys of objects as keys.
|
|
139
|
+
* The cache will not grow beyond the size of different object **shapes**
|
|
140
|
+
* encountered in an application, no matter how much actual data gets stringified.
|
|
141
|
+
*
|
|
142
|
+
* @privateRemarks
|
|
143
|
+
* Cache size for the `sortingMap` in `canonicalStringify`.
|
|
144
|
+
*/
|
|
145
|
+
canonicalStringify: number;
|
|
146
|
+
/**
|
|
147
|
+
* A cache inside of [`FragmentRegistry`](https://github.com/apollographql/apollo-client/blob/main/src/cache/inmemory/fragmentRegistry.ts).
|
|
148
|
+
*
|
|
149
|
+
* Can be called with user-defined or already-transformed `DocumentNode`s.
|
|
150
|
+
*
|
|
151
|
+
* @defaultValue
|
|
152
|
+
* Defaults to `2000`.
|
|
153
|
+
*
|
|
154
|
+
* @privateRemarks
|
|
155
|
+
*
|
|
156
|
+
* Cache size for the `transform` method of FragmentRegistry.
|
|
157
|
+
* This function is called as part of the `defaultDocumentTransform` which will be called with
|
|
158
|
+
* user-provided and already-transformed DocumentNodes.
|
|
159
|
+
*
|
|
160
|
+
*/
|
|
161
|
+
"fragmentRegistry.transform": number;
|
|
162
|
+
/**
|
|
163
|
+
* A cache inside of [`FragmentRegistry`](https://github.com/apollographql/apollo-client/blob/main/src/cache/inmemory/fragmentRegistry.ts).
|
|
164
|
+
*
|
|
165
|
+
* This function is called with fragment names in the form of a string.
|
|
166
|
+
*
|
|
167
|
+
* @defaultValue
|
|
168
|
+
* Defaults to `1000`.
|
|
169
|
+
*
|
|
170
|
+
* @remarks
|
|
171
|
+
* The size of this case should be chosen with the number of fragments in
|
|
172
|
+
* your application in mind.
|
|
173
|
+
*
|
|
174
|
+
* Note:
|
|
175
|
+
* This function is a dependency of `fragmentRegistry.transform`, so having too small of a cache size here
|
|
176
|
+
* might involuntarily invalidate values in the `transform` cache.
|
|
177
|
+
*
|
|
178
|
+
* @privateRemarks
|
|
179
|
+
* Cache size for the `lookup` method of FragmentRegistry.
|
|
180
|
+
*/
|
|
181
|
+
"fragmentRegistry.lookup": number;
|
|
182
|
+
/**
|
|
183
|
+
* Cache size for the `findFragmentSpreads` method of [`FragmentRegistry`](https://github.com/apollographql/apollo-client/blob/main/src/cache/inmemory/fragmentRegistry.ts).
|
|
184
|
+
*
|
|
185
|
+
* This function is called with transformed `DocumentNode`s, as well as recursively
|
|
186
|
+
* with every fragment spread referenced within that, or a fragment referenced by a
|
|
187
|
+
* fragment spread.
|
|
188
|
+
*
|
|
189
|
+
* @defaultValue
|
|
190
|
+
* Defaults to `4000`.
|
|
191
|
+
*
|
|
192
|
+
* @remarks
|
|
193
|
+
*
|
|
194
|
+
* Note: This function is a dependency of `fragmentRegistry.transform`, so having too small of cache size here
|
|
195
|
+
* might involuntarily invalidate values in the `transform` cache.
|
|
196
|
+
*/
|
|
197
|
+
"fragmentRegistry.findFragmentSpreads": number;
|
|
198
|
+
/**
|
|
199
|
+
* Cache size for the `getFragmentDoc` method of [`ApolloCache`](https://github.com/apollographql/apollo-client/blob/main/src/cache/core/cache.ts).
|
|
200
|
+
*
|
|
201
|
+
* This function is called with user-provided fragment definitions.
|
|
202
|
+
*
|
|
203
|
+
* @defaultValue
|
|
204
|
+
* Defaults to `1000`.
|
|
205
|
+
*
|
|
206
|
+
* @remarks
|
|
207
|
+
* This function is called from `readFragment` with user-provided fragment definitions.
|
|
208
|
+
*/
|
|
209
|
+
"cache.fragmentQueryDocuments": number;
|
|
210
|
+
/**
|
|
211
|
+
* Cache used in [`removeTypenameFromVariables`](https://github.com/apollographql/apollo-client/blob/main/src/link/remove-typename/removeTypenameFromVariables.ts).
|
|
212
|
+
*
|
|
213
|
+
* This function is called transformed `DocumentNode`s.
|
|
214
|
+
*
|
|
215
|
+
* @defaultValue
|
|
216
|
+
* Defaults to `2000`.
|
|
217
|
+
*
|
|
218
|
+
* @privateRemarks
|
|
219
|
+
* Cache size for the `getVariableDefinitions` function of `removeTypenameFromVariables`.
|
|
220
|
+
*/
|
|
221
|
+
"removeTypenameFromVariables.getVariableDefinitions": number;
|
|
222
|
+
/**
|
|
223
|
+
* Cache size for the `maybeBroadcastWatch` method on [`InMemoryCache`](https://github.com/apollographql/apollo-client/blob/main/src/cache/inmemory/inMemoryCache.ts).
|
|
224
|
+
*
|
|
225
|
+
* Note: `maybeBroadcastWatch` will be set to the `resultCacheMaxSize` option and
|
|
226
|
+
* will fall back to this configuration value if the option is not set.
|
|
227
|
+
*
|
|
228
|
+
* @defaultValue
|
|
229
|
+
* Defaults to `5000`.
|
|
230
|
+
*
|
|
231
|
+
* @remarks
|
|
232
|
+
* This method is used for dependency tracking in the `InMemoryCache` and
|
|
233
|
+
* prevents from unnecessary re-renders.
|
|
234
|
+
* It is recommended to keep this value significantly higher than the number of
|
|
235
|
+
* possible subscribers you will have active at the same time in your application
|
|
236
|
+
* at any time.
|
|
237
|
+
*/
|
|
238
|
+
"inMemoryCache.maybeBroadcastWatch": number;
|
|
239
|
+
/**
|
|
240
|
+
* Cache size for the `executeSelectionSet` method on [`StoreReader`](https://github.com/apollographql/apollo-client/blob/main/src/cache/inmemory/readFromStore.ts).
|
|
241
|
+
*
|
|
242
|
+
* Note:
|
|
243
|
+
* `executeSelectionSet` will be set to the `resultCacheMaxSize` option and
|
|
244
|
+
* will fall back to this configuration value if the option is not set.
|
|
245
|
+
*
|
|
246
|
+
* @defaultValue
|
|
247
|
+
* Defaults to `10000`.
|
|
248
|
+
*
|
|
249
|
+
* @remarks
|
|
250
|
+
* Every object that is read from the cache will be cached here, so it is
|
|
251
|
+
* recommended to set this to a high value.
|
|
252
|
+
*/
|
|
253
|
+
"inMemoryCache.executeSelectionSet": number;
|
|
254
|
+
/**
|
|
255
|
+
* Cache size for the `executeSubSelectedArray` method on [`StoreReader`](https://github.com/apollographql/apollo-client/blob/main/src/cache/inmemory/readFromStore.ts).
|
|
256
|
+
*
|
|
257
|
+
* Note:
|
|
258
|
+
* `executeSubSelectedArray` will be set to the `resultCacheMaxSize` option and
|
|
259
|
+
* will fall back to this configuration value if the option is not set.
|
|
260
|
+
*
|
|
261
|
+
* @defaultValue
|
|
262
|
+
* Defaults to `5000`.
|
|
263
|
+
*
|
|
264
|
+
* @remarks
|
|
265
|
+
* Every array that is read from the cache will be cached here, so it is
|
|
266
|
+
* recommended to set this to a high value.
|
|
267
|
+
*/
|
|
268
|
+
"inMemoryCache.executeSubSelectedArray": number;
|
|
269
|
+
}
|
|
270
|
+
declare const cacheSizeSymbol: unique symbol;
|
|
271
|
+
/**
|
|
272
|
+
*
|
|
273
|
+
* The global cache size configuration for Apollo Client.
|
|
274
|
+
*
|
|
275
|
+
* @remarks
|
|
276
|
+
*
|
|
277
|
+
* You can directly modify this object, but any modification will
|
|
278
|
+
* only have an effect on caches that are created after the modification.
|
|
279
|
+
*
|
|
280
|
+
* So for global caches, such as `parser`, `canonicalStringify` and `print`,
|
|
281
|
+
* you might need to call `.reset` on them, which will essentially re-create them.
|
|
282
|
+
*
|
|
283
|
+
* Alternatively, you can set `globalThis[Symbol.for("apollo.cacheSize")]` before
|
|
284
|
+
* you load the Apollo Client package:
|
|
285
|
+
*
|
|
286
|
+
* @example
|
|
287
|
+
* ```ts
|
|
288
|
+
* globalThis[Symbol.for("apollo.cacheSize")] = {
|
|
289
|
+
* parser: 100
|
|
290
|
+
* } satisfies Partial<CacheSizes> // the `satisfies` is optional if using TypeScript
|
|
291
|
+
* ```
|
|
292
|
+
*/
|
|
293
|
+
export declare const cacheSizes: Partial<CacheSizes>;
|
|
294
|
+
export declare const enum defaultCacheSizes {
|
|
295
|
+
parser = 1000,
|
|
296
|
+
canonicalStringify = 1000,
|
|
297
|
+
print = 2000,
|
|
298
|
+
"documentTransform.cache" = 2000,
|
|
299
|
+
"queryManager.getDocumentInfo" = 2000,
|
|
300
|
+
"PersistedQueryLink.persistedQueryHashes" = 2000,
|
|
301
|
+
"fragmentRegistry.transform" = 2000,
|
|
302
|
+
"fragmentRegistry.lookup" = 1000,
|
|
303
|
+
"fragmentRegistry.findFragmentSpreads" = 4000,
|
|
304
|
+
"cache.fragmentQueryDocuments" = 1000,
|
|
305
|
+
"removeTypenameFromVariables.getVariableDefinitions" = 2000,
|
|
306
|
+
"inMemoryCache.maybeBroadcastWatch" = 5000,
|
|
307
|
+
"inMemoryCache.executeSelectionSet" = 10000,
|
|
308
|
+
"inMemoryCache.executeSubSelectedArray" = 5000
|
|
309
|
+
}
|
|
310
|
+
export {};
|
|
311
|
+
//# sourceMappingURL=sizes.d.ts.map
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { __assign } from "tslib";
|
|
2
|
+
import { global } from "../globals/index.js";
|
|
3
|
+
var cacheSizeSymbol = Symbol.for("apollo.cacheSize");
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* The global cache size configuration for Apollo Client.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
*
|
|
10
|
+
* You can directly modify this object, but any modification will
|
|
11
|
+
* only have an effect on caches that are created after the modification.
|
|
12
|
+
*
|
|
13
|
+
* So for global caches, such as `parser`, `canonicalStringify` and `print`,
|
|
14
|
+
* you might need to call `.reset` on them, which will essentially re-create them.
|
|
15
|
+
*
|
|
16
|
+
* Alternatively, you can set `globalThis[Symbol.for("apollo.cacheSize")]` before
|
|
17
|
+
* you load the Apollo Client package:
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* globalThis[Symbol.for("apollo.cacheSize")] = {
|
|
22
|
+
* parser: 100
|
|
23
|
+
* } satisfies Partial<CacheSizes> // the `satisfies` is optional if using TypeScript
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
export var cacheSizes = __assign({}, global[cacheSizeSymbol]);
|
|
27
|
+
//# sourceMappingURL=sizes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sizes.js","sourceRoot":"","sources":["../../../src/utilities/caching/sizes.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAsR7C,IAAM,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC,kBAAkB,CAAC,CAAC;AACvD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,CAAC,IAAM,UAAU,gBAA6B,MAAM,CAAC,eAAe,CAAC,CAAE,CAAC","sourcesContent":["import { global } from \"../globals/index.js\";\n\ndeclare global {\n interface Window {\n [cacheSizeSymbol]?: Partial<CacheSizes>;\n }\n}\n\n/**\n * The cache sizes used by various Apollo Client caches.\n *\n * @remarks\n * All configurable caches hold memoized values. If an item is\n * cache-collected, it incurs only a small performance impact and\n * doesn't cause data loss. A smaller cache size might save you memory.\n *\n * You should choose cache sizes appropriate for storing a reasonable\n * number of values rather than every value. To prevent too much recalculation,\n * choose cache sizes that are at least large enough to hold memoized values for\n * all hooks/queries on the screen at any given time.\n */\n/*\n * We assume a \"base value\" of 1000 here, which is already very generous.\n * In most applications, it will be very unlikely that 1000 different queries\n * are on screen at the same time.\n */\nexport interface CacheSizes {\n /**\n * Cache size for the [`print`](https://github.com/apollographql/apollo-client/blob/main/src/utilities/graphql/print.ts) function.\n *\n * It is called with transformed `DocumentNode`s.\n *\n * @defaultValue\n * Defaults to `2000`.\n *\n * @remarks\n * This method is called to transform a GraphQL query AST parsed by `gql`\n * back into a GraphQL string.\n *\n * @privateRemarks\n * This method is called from the `QueryManager` and various `ApolloLink`s,\n * always with the \"serverQuery\", so the server-facing part of a transformed\n * `DocumentNode`.\n */\n print: number;\n /**\n * Cache size for the [`parser`](https://github.com/apollographql/apollo-client/blob/main/src/react/parser/index.ts) function.\n *\n * It is called with user-provided `DocumentNode`s.\n *\n * @defaultValue\n * Defaults to `1000`.\n *\n * @remarks\n * This method is called by HOCs and hooks.\n *\n * @privateRemarks\n * This function is used directly in HOCs, and nowadays mainly accessed by\n * calling `verifyDocumentType` from various hooks.\n * It is called with a user-provided DocumentNode.\n */\n parser: number;\n /**\n * Cache size for the cache of [`DocumentTransform`](https://github.com/apollographql/apollo-client/blob/main/src/utilities/graphql/DocumentTransform.ts)\n * instances with the `cache` option set to `true`.\n *\n * Can be called with user-defined or already-transformed `DocumentNode`s.\n *\n * @defaultValue\n * Defaults to `2000`.\n *\n * @remarks\n * The cache size here should be chosen with other `DocumentTransform`s in mind.\n * For example, if there was a `DocumentTransform` that would take `x` `DocumentNode`s,\n * and returned a differently-transformed `DocumentNode` depending if the app is\n * online or offline, then we assume that the cache returns `2*x` documents.\n * If that were concatenated with another `DocumentTransform` that would\n * also duplicate the cache size, you'd need to account for `4*x` documents\n * returned by the second transform.\n *\n * Due to an implementation detail of Apollo Client, if you use custom document\n * transforms you should always add `n` (the \"base\" number of user-provided\n * Documents) to the resulting cache size.\n *\n * If we assume that the user-provided transforms receive `n` documents and\n * return `n` documents, the cache size should be `2*n`.\n *\n * If we assume that the chain of user-provided transforms receive `n` documents and\n * return `4*n` documents, the cache size should be `5*n`.\n *\n * This size should also then be used in every other cache that mentions that\n * it operates on a \"transformed\" `DocumentNode`.\n *\n * @privateRemarks\n * Cache size for the `performWork` method of each [`DocumentTransform`](https://github.com/apollographql/apollo-client/blob/main/src/utilities/graphql/DocumentTransform.ts).\n *\n * No user-provided DocumentNode will actually be \"the last one\", as we run the\n * `defaultDocumentTransform` before *and* after the user-provided transforms.\n * For that reason, we need the extra `n` here - `n` for \"before transformation\"\n * plus the actual maximum cache size of the user-provided transform chain.\n *\n * This method is called from `transformDocument`, which is called from\n * `QueryManager` with a user-provided DocumentNode.\n * It is also called with already-transformed DocumentNodes, assuming the\n * user provided additional transforms.\n *\n */\n \"documentTransform.cache\": number;\n /**\n * A cache inside of [`QueryManager`](https://github.com/apollographql/apollo-client/blob/main/src/core/QueryManager.ts).\n *\n * It is called with transformed `DocumentNode`s.\n *\n * @defaultValue\n * Defaults to `2000`.\n *\n * @privateRemarks\n * Cache size for the `transformCache` used in the `getDocumentInfo` method of `QueryManager`.\n * Called throughout the `QueryManager` with transformed DocumentNodes.\n */\n \"queryManager.getDocumentInfo\": number;\n /**\n * A cache inside of [`PersistedQueryLink`](https://github.com/apollographql/apollo-client/blob/main/src/link/persisted-queries/index.ts).\n *\n * It is called with transformed `DocumentNode`s.\n *\n * @defaultValue\n * Defaults to `2000`.\n *\n * @remarks\n * This cache is used to cache the hashes of persisted queries.\n *\n * @privateRemarks\n * Cache size for the `hashesByQuery` cache in the `PersistedQueryLink`.\n */\n \"PersistedQueryLink.persistedQueryHashes\": number;\n /**\n * Cache used by [`canonicalStringify`](https://github.com/apollographql/apollo-client/blob/main/src/utilities/common/canonicalStringify.ts).\n *\n * @defaultValue\n * Defaults to `1000`.\n *\n * @remarks\n * This cache contains the sorted keys of objects that are stringified by\n * `canonicalStringify`.\n * It uses the stringified unsorted keys of objects as keys.\n * The cache will not grow beyond the size of different object **shapes**\n * encountered in an application, no matter how much actual data gets stringified.\n *\n * @privateRemarks\n * Cache size for the `sortingMap` in `canonicalStringify`.\n */\n canonicalStringify: number;\n /**\n * A cache inside of [`FragmentRegistry`](https://github.com/apollographql/apollo-client/blob/main/src/cache/inmemory/fragmentRegistry.ts).\n *\n * Can be called with user-defined or already-transformed `DocumentNode`s.\n *\n * @defaultValue\n * Defaults to `2000`.\n *\n * @privateRemarks\n *\n * Cache size for the `transform` method of FragmentRegistry.\n * This function is called as part of the `defaultDocumentTransform` which will be called with\n * user-provided and already-transformed DocumentNodes.\n *\n */\n \"fragmentRegistry.transform\": number;\n /**\n * A cache inside of [`FragmentRegistry`](https://github.com/apollographql/apollo-client/blob/main/src/cache/inmemory/fragmentRegistry.ts).\n *\n * This function is called with fragment names in the form of a string.\n *\n * @defaultValue\n * Defaults to `1000`.\n *\n * @remarks\n * The size of this case should be chosen with the number of fragments in\n * your application in mind.\n *\n * Note:\n * This function is a dependency of `fragmentRegistry.transform`, so having too small of a cache size here\n * might involuntarily invalidate values in the `transform` cache.\n *\n * @privateRemarks\n * Cache size for the `lookup` method of FragmentRegistry.\n */\n \"fragmentRegistry.lookup\": number;\n /**\n * Cache size for the `findFragmentSpreads` method of [`FragmentRegistry`](https://github.com/apollographql/apollo-client/blob/main/src/cache/inmemory/fragmentRegistry.ts).\n *\n * This function is called with transformed `DocumentNode`s, as well as recursively\n * with every fragment spread referenced within that, or a fragment referenced by a\n * fragment spread.\n *\n * @defaultValue\n * Defaults to `4000`.\n *\n * @remarks\n *\n * Note: This function is a dependency of `fragmentRegistry.transform`, so having too small of cache size here\n * might involuntarily invalidate values in the `transform` cache.\n */\n \"fragmentRegistry.findFragmentSpreads\": number;\n /**\n * Cache size for the `getFragmentDoc` method of [`ApolloCache`](https://github.com/apollographql/apollo-client/blob/main/src/cache/core/cache.ts).\n *\n * This function is called with user-provided fragment definitions.\n *\n * @defaultValue\n * Defaults to `1000`.\n *\n * @remarks\n * This function is called from `readFragment` with user-provided fragment definitions.\n */\n \"cache.fragmentQueryDocuments\": number;\n /**\n * Cache used in [`removeTypenameFromVariables`](https://github.com/apollographql/apollo-client/blob/main/src/link/remove-typename/removeTypenameFromVariables.ts).\n *\n * This function is called transformed `DocumentNode`s.\n *\n * @defaultValue\n * Defaults to `2000`.\n *\n * @privateRemarks\n * Cache size for the `getVariableDefinitions` function of `removeTypenameFromVariables`.\n */\n \"removeTypenameFromVariables.getVariableDefinitions\": number;\n /**\n * Cache size for the `maybeBroadcastWatch` method on [`InMemoryCache`](https://github.com/apollographql/apollo-client/blob/main/src/cache/inmemory/inMemoryCache.ts).\n *\n * Note: `maybeBroadcastWatch` will be set to the `resultCacheMaxSize` option and\n * will fall back to this configuration value if the option is not set.\n *\n * @defaultValue\n * Defaults to `5000`.\n *\n * @remarks\n * This method is used for dependency tracking in the `InMemoryCache` and\n * prevents from unnecessary re-renders.\n * It is recommended to keep this value significantly higher than the number of\n * possible subscribers you will have active at the same time in your application\n * at any time.\n */\n \"inMemoryCache.maybeBroadcastWatch\": number;\n /**\n * Cache size for the `executeSelectionSet` method on [`StoreReader`](https://github.com/apollographql/apollo-client/blob/main/src/cache/inmemory/readFromStore.ts).\n *\n * Note:\n * `executeSelectionSet` will be set to the `resultCacheMaxSize` option and\n * will fall back to this configuration value if the option is not set.\n *\n * @defaultValue\n * Defaults to `10000`.\n *\n * @remarks\n * Every object that is read from the cache will be cached here, so it is\n * recommended to set this to a high value.\n */\n \"inMemoryCache.executeSelectionSet\": number;\n /**\n * Cache size for the `executeSubSelectedArray` method on [`StoreReader`](https://github.com/apollographql/apollo-client/blob/main/src/cache/inmemory/readFromStore.ts).\n *\n * Note:\n * `executeSubSelectedArray` will be set to the `resultCacheMaxSize` option and\n * will fall back to this configuration value if the option is not set.\n *\n * @defaultValue\n * Defaults to `5000`.\n *\n * @remarks\n * Every array that is read from the cache will be cached here, so it is\n * recommended to set this to a high value.\n */\n \"inMemoryCache.executeSubSelectedArray\": number;\n}\n\nconst cacheSizeSymbol = Symbol.for(\"apollo.cacheSize\");\n/**\n *\n * The global cache size configuration for Apollo Client.\n *\n * @remarks\n *\n * You can directly modify this object, but any modification will\n * only have an effect on caches that are created after the modification.\n *\n * So for global caches, such as `parser`, `canonicalStringify` and `print`,\n * you might need to call `.reset` on them, which will essentially re-create them.\n *\n * Alternatively, you can set `globalThis[Symbol.for(\"apollo.cacheSize\")]` before\n * you load the Apollo Client package:\n *\n * @example\n * ```ts\n * globalThis[Symbol.for(\"apollo.cacheSize\")] = {\n * parser: 100\n * } satisfies Partial<CacheSizes> // the `satisfies` is optional if using TypeScript\n * ```\n */\nexport const cacheSizes: Partial<CacheSizes> = { ...global[cacheSizeSymbol] };\n\nexport const enum defaultCacheSizes {\n parser = 1000,\n canonicalStringify = 1000,\n print = 2000,\n \"documentTransform.cache\" = 2000,\n \"queryManager.getDocumentInfo\" = 2000,\n \"PersistedQueryLink.persistedQueryHashes\" = 2000,\n \"fragmentRegistry.transform\" = 2000,\n \"fragmentRegistry.lookup\" = 1000,\n \"fragmentRegistry.findFragmentSpreads\" = 4000,\n \"cache.fragmentQueryDocuments\" = 1000,\n \"removeTypenameFromVariables.getVariableDefinitions\" = 2000,\n \"inMemoryCache.maybeBroadcastWatch\" = 5000,\n \"inMemoryCache.executeSelectionSet\" = 10000,\n \"inMemoryCache.executeSubSelectedArray\" = 5000,\n}\n"]}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { maybe } from "../globals/index.js";
|
|
2
2
|
export var canUseWeakMap = typeof WeakMap === "function" &&
|
|
3
|
-
maybe(function () { return navigator.product
|
|
3
|
+
!maybe(function () { return navigator.product == "ReactNative" && !global.HermesInternal; });
|
|
4
4
|
export var canUseWeakSet = typeof WeakSet === "function";
|
|
5
5
|
export var canUseSymbol = typeof Symbol === "function" && typeof Symbol.for === "function";
|
|
6
6
|
export var canUseAsyncIteratorSymbol = canUseSymbol && Symbol.asyncIterator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canUse.js","sourceRoot":"","sources":["../../../src/utilities/common/canUse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,MAAM,CAAC,IAAM,aAAa,GACxB,OAAO,OAAO,KAAK,UAAU;IAC7B,KAAK,
|
|
1
|
+
{"version":3,"file":"canUse.js","sourceRoot":"","sources":["../../../src/utilities/common/canUse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AAE5C,MAAM,CAAC,IAAM,aAAa,GACxB,OAAO,OAAO,KAAK,UAAU;IAC7B,CAAC,KAAK,CACJ,cAAM,OAAA,SAAS,CAAC,OAAO,IAAI,aAAa,IAAI,CAAE,MAAc,CAAC,cAAc,EAArE,CAAqE,CAC5E,CAAC;AAEJ,MAAM,CAAC,IAAM,aAAa,GAAG,OAAO,OAAO,KAAK,UAAU,CAAC;AAE3D,MAAM,CAAC,IAAM,YAAY,GACvB,OAAO,MAAM,KAAK,UAAU,IAAI,OAAO,MAAM,CAAC,GAAG,KAAK,UAAU,CAAC;AAEnE,MAAM,CAAC,IAAM,yBAAyB,GAAG,YAAY,IAAI,MAAM,CAAC,aAAa,CAAC;AAE9E,MAAM,CAAC,IAAM,SAAS,GACpB,OAAO,KAAK,CAAC,cAAM,OAAA,MAAM,CAAC,QAAQ,CAAC,aAAa,EAA7B,CAA6B,CAAC,KAAK,UAAU,CAAC;AAEnE,IAAM,UAAU;AACd,8EAA8E;AAC9E,oEAAoE;AACpE,EAAE;AACF,0EAA0E;AAC1E,6EAA6E;AAC7E,6EAA6E;AAC7E,2EAA2E;AAC3E,+DAA+D;AAC/D,KAAK,CAAC,cAAM,OAAA,SAAS,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAzC,CAAyC,CAAC,IAAI,KAAK,CAAC;AAElE,sEAAsE;AACtE,+EAA+E;AAC/E,wEAAwE;AACxE,0EAA0E;AAC1E,gFAAgF;AAChF,iEAAiE;AACjE,MAAM,CAAC,IAAM,kBAAkB,GAAG,SAAS,IAAI,CAAC,UAAU,CAAC","sourcesContent":["import { maybe } from \"../globals/index.js\";\n\nexport const canUseWeakMap =\n typeof WeakMap === \"function\" &&\n !maybe(\n () => navigator.product == \"ReactNative\" && !(global as any).HermesInternal\n );\n\nexport const canUseWeakSet = typeof WeakSet === \"function\";\n\nexport const canUseSymbol =\n typeof Symbol === \"function\" && typeof Symbol.for === \"function\";\n\nexport const canUseAsyncIteratorSymbol = canUseSymbol && Symbol.asyncIterator;\n\nexport const canUseDOM =\n typeof maybe(() => window.document.createElement) === \"function\";\n\nconst usingJSDOM: boolean =\n // Following advice found in this comment from @domenic (maintainer of jsdom):\n // https://github.com/jsdom/jsdom/issues/1537#issuecomment-229405327\n //\n // Since we control the version of Jest and jsdom used when running Apollo\n // Client tests, and that version is recent enought to include \" jsdom/x.y.z\"\n // at the end of the user agent string, I believe this case is all we need to\n // check. Testing for \"Node.js\" was recommended for backwards compatibility\n // with older version of jsdom, but we don't have that problem.\n maybe(() => navigator.userAgent.indexOf(\"jsdom\") >= 0) || false;\n\n// Our tests should all continue to pass if we remove this !usingJSDOM\n// condition, thereby allowing useLayoutEffect when using jsdom. Unfortunately,\n// if we allow useLayoutEffect, then useSyncExternalStore generates many\n// warnings about useLayoutEffect doing nothing on the server. While these\n// warnings are harmless, this !usingJSDOM condition seems to be the best way to\n// prevent them (i.e. skipping useLayoutEffect when using jsdom).\nexport const canUseLayoutEffect = canUseDOM && !usingJSDOM;\n"]}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { AutoCleanedStrongCache, cacheSizes, } from "../../utilities/caching/index.js";
|
|
2
|
+
import { registerGlobalCache } from "../caching/getMemoryInternals.js";
|
|
1
3
|
/**
|
|
2
4
|
* Like JSON.stringify, but with object keys always sorted in the same order.
|
|
3
5
|
*
|
|
@@ -22,12 +24,16 @@ export var canonicalStringify = Object.assign(function canonicalStringify(value)
|
|
|
22
24
|
// Clearing the sortingMap will reclaim all cached memory, without
|
|
23
25
|
// affecting the logical results of canonicalStringify, but potentially
|
|
24
26
|
// sacrificing performance until the cache is refilled.
|
|
25
|
-
sortingMap.
|
|
27
|
+
sortingMap = new AutoCleanedStrongCache(cacheSizes.canonicalStringify || 1000 /* defaultCacheSizes.canonicalStringify */);
|
|
26
28
|
},
|
|
27
29
|
});
|
|
30
|
+
if (globalThis.__DEV__ !== false) {
|
|
31
|
+
registerGlobalCache("canonicalStringify", function () { return sortingMap.size; });
|
|
32
|
+
}
|
|
28
33
|
// Values are JSON-serialized arrays of object keys (in any order), and values
|
|
29
34
|
// are sorted arrays of the same keys.
|
|
30
|
-
var sortingMap
|
|
35
|
+
var sortingMap;
|
|
36
|
+
canonicalStringify.reset();
|
|
31
37
|
// The JSON.stringify function takes an optional second argument called a
|
|
32
38
|
// replacer function. This function is called for each key-value pair in the
|
|
33
39
|
// object being stringified, and its return value is used instead of the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canonicalStringify.js","sourceRoot":"","sources":["../../../src/utilities/common/canonicalStringify.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;KAgBK;AACL,MAAM,CAAC,IAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAC7C,SAAS,kBAAkB,CAAC,KAAU;IACpC,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,oBAAoB,CAAC,CAAC;AACrD,CAAC,EACD;IACE,KAAK;QACH,kEAAkE;QAClE,uEAAuE;QACvE,uDAAuD;QACvD,UAAU,CAAC,
|
|
1
|
+
{"version":3,"file":"canonicalStringify.js","sourceRoot":"","sources":["../../../src/utilities/common/canonicalStringify.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,UAAU,GAEX,MAAM,kCAAkC,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kCAAkC,CAAC;AAEvE;;;;;;;;;;;;;;;;KAgBK;AACL,MAAM,CAAC,IAAM,kBAAkB,GAAG,MAAM,CAAC,MAAM,CAC7C,SAAS,kBAAkB,CAAC,KAAU;IACpC,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,oBAAoB,CAAC,CAAC;AACrD,CAAC,EACD;IACE,KAAK;QACH,kEAAkE;QAClE,uEAAuE;QACvE,uDAAuD;QACvD,UAAU,GAAG,IA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,IAAI,CAAC;gBAC/C,UAAU,CAAC,GAAG,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;gBACxC,UAAU,CAAC,GAAG,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;YACxC,CAAC;YACD,IAAM,cAAY,GAAG,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;YAC1C,oEAAoE;YACpE,kCAAkC;YAClC,UAAU,CAAC,OAAO,CAAC,UAAC,GAAG;gBACrB,cAAY,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC;YACjC,CAAC,CAAC,CAAC;YACH,OAAO,cAAY,CAAC;QACtB,CAAC;IACH,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,+EAA+E;AAC/E,sEAAsE;AACtE,8EAA8E;AAC9E,0CAA0C;AAC1C,SAAS,eAAe,CACtB,GAAW,EACX,CAAS,EACT,IAAuB;IAEvB,OAAO,CAAC,KAAK,CAAC,IAAI,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,GAAG,CAAC;AACvC,CAAC","sourcesContent":["import {\n AutoCleanedStrongCache,\n cacheSizes,\n defaultCacheSizes,\n} from \"../../utilities/caching/index.js\";\nimport { registerGlobalCache } from \"../caching/getMemoryInternals.js\";\n\n/**\n * Like JSON.stringify, but with object keys always sorted in the same order.\n *\n * To achieve performant sorting, this function uses a Map from JSON-serialized\n * arrays of keys (in any order) to sorted arrays of the same keys, with a\n * single sorted array reference shared by all permutations of the keys.\n *\n * As a drawback, this function will add a little bit more memory for every\n * object encountered that has different (more, less, a different order of) keys\n * than in the past.\n *\n * In a typical application, this extra memory usage should not play a\n * significant role, as `canonicalStringify` will be called for only a limited\n * number of object shapes, and the cache will not grow beyond a certain point.\n * But in some edge cases, this could be a problem, so we provide\n * canonicalStringify.reset() as a way of clearing the cache.\n * */\nexport const canonicalStringify = Object.assign(\n function canonicalStringify(value: any): string {\n return JSON.stringify(value, stableObjectReplacer);\n },\n {\n reset() {\n // Clearing the sortingMap will reclaim all cached memory, without\n // affecting the logical results of canonicalStringify, but potentially\n // sacrificing performance until the cache is refilled.\n sortingMap = new AutoCleanedStrongCache<string, readonly string[]>(\n cacheSizes.canonicalStringify || defaultCacheSizes.canonicalStringify\n );\n },\n }\n);\n\nif (__DEV__) {\n registerGlobalCache(\"canonicalStringify\", () => sortingMap.size);\n}\n\n// Values are JSON-serialized arrays of object keys (in any order), and values\n// are sorted arrays of the same keys.\nlet sortingMap!: AutoCleanedStrongCache<string, readonly string[]>;\ncanonicalStringify.reset();\n\n// The JSON.stringify function takes an optional second argument called a\n// replacer function. This function is called for each key-value pair in the\n// object being stringified, and its return value is used instead of the\n// original value. If the replacer function returns a new value, that value is\n// stringified as JSON instead of the original value of the property.\n// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#the_replacer_parameter\nfunction stableObjectReplacer(key: string, value: any) {\n if (value && typeof value === \"object\") {\n const proto = Object.getPrototypeOf(value);\n // We don't want to mess with objects that are not \"plain\" objects, which\n // means their prototype is either Object.prototype or null. This check also\n // prevents needlessly rearranging the indices of arrays.\n if (proto === Object.prototype || proto === null) {\n const keys = Object.keys(value);\n // If keys is already sorted, let JSON.stringify serialize the original\n // value instead of creating a new object with keys in the same order.\n if (keys.every(everyKeyInOrder)) return value;\n const unsortedKey = JSON.stringify(keys);\n let sortedKeys = sortingMap.get(unsortedKey);\n if (!sortedKeys) {\n keys.sort();\n const sortedKey = JSON.stringify(keys);\n // Checking for sortedKey in the sortingMap allows us to share the same\n // sorted array reference for all permutations of the same set of keys.\n sortedKeys = sortingMap.get(sortedKey) || keys;\n sortingMap.set(unsortedKey, sortedKeys);\n sortingMap.set(sortedKey, sortedKeys);\n }\n const sortedObject = Object.create(proto);\n // Reassigning the keys in sorted order will cause JSON.stringify to\n // serialize them in sorted order.\n sortedKeys.forEach((key) => {\n sortedObject[key] = value[key];\n });\n return sortedObject;\n }\n }\n return value;\n}\n\n// Since everything that happens in stableObjectReplacer benefits from being as\n// efficient as possible, we use a static function as the callback for\n// keys.every in order to test if the provided keys are already sorted without\n// allocating extra memory for a callback.\nfunction everyKeyInOrder(\n key: string,\n i: number,\n keys: readonly string[]\n): boolean {\n return i === 0 || keys[i - 1] <= key;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"globals.cjs","sources":["../../version.js","maybe.js","global.js","../common/makeUniqueId.js","../common/stringifyForDisplay.js","invariantWrappers.js","index.js"],"sourcesContent":["export var version = \"3.9.0-
|
|
1
|
+
{"version":3,"file":"globals.cjs","sources":["../../version.js","maybe.js","global.js","../common/makeUniqueId.js","../common/stringifyForDisplay.js","invariantWrappers.js","index.js"],"sourcesContent":["export var version = \"3.9.0-beta.1\";\n//# sourceMappingURL=version.js.map","export function maybe(thunk) {\n try {\n return thunk();\n }\n catch (_a) { }\n}\n//# sourceMappingURL=maybe.js.map","import { maybe } from \"./maybe.js\";\nexport default (maybe(function () { return globalThis; }) ||\n maybe(function () { return window; }) ||\n maybe(function () { return self; }) ||\n maybe(function () { return global; }) || // We don't expect the Function constructor ever to be invoked at runtime, as\n// long as at least one of globalThis, window, self, or global is defined, so\n// we are under no obligation to make it easy for static analysis tools to\n// detect syntactic usage of the Function constructor. If you think you can\n// improve your static analysis to detect this obfuscation, think again. This\n// is an arms race you cannot win, at least not in JavaScript.\nmaybe(function () {\n return maybe.constructor(\"return this\")();\n}));\n//# sourceMappingURL=global.js.map","var prefixCounts = new Map();\n// These IDs won't be globally unique, but they will be unique within this\n// process, thanks to the counter, and unguessable thanks to the random suffix.\nexport function makeUniqueId(prefix) {\n var count = prefixCounts.get(prefix) || 1;\n prefixCounts.set(prefix, count + 1);\n return \"\".concat(prefix, \":\").concat(count, \":\").concat(Math.random().toString(36).slice(2));\n}\n//# sourceMappingURL=makeUniqueId.js.map","import { makeUniqueId } from \"./makeUniqueId.js\";\nexport function stringifyForDisplay(value, space) {\n if (space === void 0) { space = 0; }\n var undefId = makeUniqueId(\"stringifyForDisplay\");\n return JSON.stringify(value, function (key, value) {\n return value === void 0 ? undefId : value;\n }, space)\n .split(JSON.stringify(undefId))\n .join(\"<undefined>\");\n}\n//# sourceMappingURL=stringifyForDisplay.js.map","import { invariant as originalInvariant, InvariantError } from \"ts-invariant\";\nimport { version } from \"../../version.js\";\nimport global from \"./global.js\";\nimport { stringifyForDisplay } from \"../common/stringifyForDisplay.js\";\nfunction wrap(fn) {\n return function (message) {\n var args = [];\n for (var _i = 1; _i < arguments.length; _i++) {\n args[_i - 1] = arguments[_i];\n }\n if (typeof message === \"number\") {\n var arg0 = message;\n message = getHandledErrorMsg(arg0);\n if (!message) {\n message = getFallbackErrorMsg(arg0, args);\n args = [];\n }\n }\n fn.apply(void 0, [message].concat(args));\n };\n}\nvar invariant = Object.assign(function invariant(condition, message) {\n var args = [];\n for (var _i = 2; _i < arguments.length; _i++) {\n args[_i - 2] = arguments[_i];\n }\n if (!condition) {\n originalInvariant(condition, getHandledErrorMsg(message, args) || getFallbackErrorMsg(message, args));\n }\n}, {\n debug: wrap(originalInvariant.debug),\n log: wrap(originalInvariant.log),\n warn: wrap(originalInvariant.warn),\n error: wrap(originalInvariant.error),\n});\n/**\n * Returns an InvariantError.\n *\n * `message` can only be a string, a concatenation of strings, or a ternary statement\n * that results in a string. This will be enforced on build, where the message will\n * be replaced with a message number.\n * String substitutions with %s are supported and will also return\n * pretty-stringified objects.\n * Excess `optionalParams` will be swallowed.\n */\nfunction newInvariantError(message) {\n var optionalParams = [];\n for (var _i = 1; _i < arguments.length; _i++) {\n optionalParams[_i - 1] = arguments[_i];\n }\n return new InvariantError(getHandledErrorMsg(message, optionalParams) ||\n getFallbackErrorMsg(message, optionalParams));\n}\nvar ApolloErrorMessageHandler = Symbol.for(\"ApolloErrorMessageHandler_\" + version);\nfunction stringify(arg) {\n return typeof arg == \"string\" ? arg : (stringifyForDisplay(arg, 2).slice(0, 1000));\n}\nfunction getHandledErrorMsg(message, messageArgs) {\n if (messageArgs === void 0) { messageArgs = []; }\n if (!message)\n return;\n return (global[ApolloErrorMessageHandler] &&\n global[ApolloErrorMessageHandler](message, messageArgs.map(stringify)));\n}\nfunction getFallbackErrorMsg(message, messageArgs) {\n if (messageArgs === void 0) { messageArgs = []; }\n if (!message)\n return;\n return \"An error occurred! For more details, see the full error text at https://go.apollo.dev/c/err#\".concat(encodeURIComponent(JSON.stringify({\n version: version,\n message: message,\n args: messageArgs.map(stringify),\n })));\n}\nexport { invariant, InvariantError, newInvariantError, ApolloErrorMessageHandler, };\n//# sourceMappingURL=invariantWrappers.js.map","import { invariant, newInvariantError, InvariantError, } from \"./invariantWrappers.js\";\nexport { maybe } from \"./maybe.js\";\nexport { default as global } from \"./global.js\";\nexport { invariant, newInvariantError, InvariantError };\n/**\n * @deprecated we do not use this internally anymore,\n * it is just exported for backwards compatibility\n */\n// this file is extempt from automatic `__DEV__` replacement\n// so we have to write it out here\n// @ts-ignore\nexport var DEV = globalThis.__DEV__ !== false;\nexport { DEV as __DEV__ };\n//# sourceMappingURL=index.js.map"],"names":["originalInvariant","InvariantError","global"],"mappings":";;;;;;AAAO,IAAI,OAAO,GAAG,cAAc;;ACA5B,SAAS,KAAK,CAAC,KAAK,EAAE;AAC7B,IAAI,IAAI;AACR,QAAQ,OAAO,KAAK,EAAE,CAAC;AACvB,KAAK;AACL,IAAI,OAAO,EAAE,EAAE,GAAG;AAClB;;ACJA,eAAe,CAAC,KAAK,CAAC,YAAY,EAAE,OAAO,UAAU,CAAC,EAAE,CAAC;AACzD,IAAI,KAAK,CAAC,YAAY,EAAE,OAAO,MAAM,CAAC,EAAE,CAAC;AACzC,IAAI,KAAK,CAAC,YAAY,EAAE,OAAO,IAAI,CAAC,EAAE,CAAC;AACvC,IAAI,KAAK,CAAC,YAAY,EAAE,OAAO,MAAM,CAAC,EAAE,CAAC;AAMzC,KAAK,CAAC,YAAY;AAClB,IAAI,OAAO,KAAK,CAAC,WAAW,CAAC,aAAa,CAAC,EAAE,CAAC;A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nD,IAAI,IAAI,WAAW,KAAK,KAAK,CAAC,EAAE,EAAE,WAAW,GAAG,EAAE,CAAC,EAAE;AACrD,IAAI,IAAI,CAAC,OAAO;AAChB,QAAQ,OAAO;AACf,IAAI,OAAO,8FAA8F,CAAC,MAAM,CAAC,kBAAkB,CAAC,IAAI,CAAC,SAAS,CAAC;AACnJ,QAAQ,OAAO,EAAE,OAAO;AACxB,QAAQ,OAAO,EAAE,OAAO;AACxB,QAAQ,IAAI,EAAE,WAAW,CAAC,GAAG,CAAC,SAAS,CAAC;AACxC,KAAK,CAAC,CAAC,CAAC,CAAC;AACT;;AC9DU,IAAC,GAAG,GAAG,UAAU,CAAC,OAAO,KAAK;;;;;;;;;;"}
|
|
@@ -11,7 +11,10 @@ export declare class DocumentTransform {
|
|
|
11
11
|
private readonly resultCache;
|
|
12
12
|
private getCacheKey;
|
|
13
13
|
static identity(): DocumentTransform;
|
|
14
|
-
static split(predicate: (document: DocumentNode) => boolean, left: DocumentTransform, right?: DocumentTransform): DocumentTransform
|
|
14
|
+
static split(predicate: (document: DocumentNode) => boolean, left: DocumentTransform, right?: DocumentTransform): DocumentTransform & {
|
|
15
|
+
left: DocumentTransform;
|
|
16
|
+
right: DocumentTransform;
|
|
17
|
+
};
|
|
15
18
|
constructor(transform: TransformFn, options?: DocumentTransformOptions);
|
|
16
19
|
/**
|
|
17
20
|
* Resets the internal cache of this transform, if it has one.
|
|
@@ -20,6 +23,16 @@ export declare class DocumentTransform {
|
|
|
20
23
|
private performWork;
|
|
21
24
|
transformDocument(document: DocumentNode): DocumentNode;
|
|
22
25
|
concat(otherTransform: DocumentTransform): DocumentTransform;
|
|
26
|
+
/**
|
|
27
|
+
* @internal
|
|
28
|
+
* Used to iterate through all transforms that are concatenations or `split` links.
|
|
29
|
+
*/
|
|
30
|
+
readonly left?: DocumentTransform;
|
|
31
|
+
/**
|
|
32
|
+
* @internal
|
|
33
|
+
* Used to iterate through all transforms that are concatenations or `split` links.
|
|
34
|
+
*/
|
|
35
|
+
readonly right?: DocumentTransform;
|
|
23
36
|
}
|
|
24
37
|
export {};
|
|
25
38
|
//# sourceMappingURL=DocumentTransform.d.ts.map
|
|
@@ -4,6 +4,7 @@ import { checkDocument } from "./getFromAST.js";
|
|
|
4
4
|
import { invariant } from "../globals/index.js";
|
|
5
5
|
import { WeakCache } from "@wry/caches";
|
|
6
6
|
import { wrap } from "optimism";
|
|
7
|
+
import { cacheSizes } from "../caching/index.js";
|
|
7
8
|
function identity(document) {
|
|
8
9
|
return document;
|
|
9
10
|
}
|
|
@@ -35,12 +36,12 @@ var DocumentTransform = /** @class */ (function () {
|
|
|
35
36
|
};
|
|
36
37
|
DocumentTransform.split = function (predicate, left, right) {
|
|
37
38
|
if (right === void 0) { right = DocumentTransform.identity(); }
|
|
38
|
-
return new DocumentTransform(function (document) {
|
|
39
|
+
return Object.assign(new DocumentTransform(function (document) {
|
|
39
40
|
var documentTransform = predicate(document) ? left : right;
|
|
40
41
|
return documentTransform.transformDocument(document);
|
|
41
42
|
},
|
|
42
43
|
// Reasonably assume both `left` and `right` transforms handle their own caching
|
|
43
|
-
{ cache: false });
|
|
44
|
+
{ cache: false }), { left: left, right: right });
|
|
44
45
|
};
|
|
45
46
|
/**
|
|
46
47
|
* Resets the internal cache of this transform, if it has one.
|
|
@@ -57,7 +58,7 @@ var DocumentTransform = /** @class */ (function () {
|
|
|
57
58
|
return stableCacheKeys_1.lookupArray(cacheKeys);
|
|
58
59
|
}
|
|
59
60
|
},
|
|
60
|
-
max:
|
|
61
|
+
max: cacheSizes["documentTransform.cache"],
|
|
61
62
|
cache: (WeakCache),
|
|
62
63
|
});
|
|
63
64
|
}
|
|
@@ -78,11 +79,14 @@ var DocumentTransform = /** @class */ (function () {
|
|
|
78
79
|
};
|
|
79
80
|
DocumentTransform.prototype.concat = function (otherTransform) {
|
|
80
81
|
var _this = this;
|
|
81
|
-
return new DocumentTransform(function (document) {
|
|
82
|
+
return Object.assign(new DocumentTransform(function (document) {
|
|
82
83
|
return otherTransform.transformDocument(_this.transformDocument(document));
|
|
83
84
|
},
|
|
84
85
|
// Reasonably assume both transforms handle their own caching
|
|
85
|
-
{ cache: false })
|
|
86
|
+
{ cache: false }), {
|
|
87
|
+
left: this,
|
|
88
|
+
right: otherTransform,
|
|
89
|
+
});
|
|
86
90
|
};
|
|
87
91
|
return DocumentTransform;
|
|
88
92
|
}());
|