@apollo/client 3.9.0-alpha.4 → 3.9.0-beta.0
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/README.md +8 -0
- package/.changeset/beige-geese-wink.md +5 -0
- package/.changeset/breezy-spiders-tap.md +38 -0
- package/.changeset/clean-items-smash.md +5 -0
- package/.changeset/cold-llamas-turn.md +8 -0
- package/.changeset/config.json +14 -0
- package/.changeset/dirty-kids-crash.md +5 -0
- package/.changeset/dirty-tigers-matter.md +13 -0
- package/.changeset/forty-cups-shop.md +5 -0
- package/.changeset/friendly-clouds-laugh.md +7 -0
- package/.changeset/hot-ducks-burn.md +5 -0
- package/.changeset/mighty-coats-check.md +47 -0
- package/.changeset/polite-avocados-warn.md +5 -0
- package/.changeset/pre.json +37 -0
- package/.changeset/quick-hats-marry.md +5 -0
- package/.changeset/rare-snakes-melt.md +24 -0
- package/.changeset/shaggy-ears-scream.md +5 -0
- package/.changeset/shaggy-sheep-pull.md +5 -0
- package/.changeset/sixty-boxes-rest.md +8 -0
- package/.changeset/sour-sheep-walk.md +7 -0
- package/.changeset/strong-terms-perform.md +46 -0
- package/.changeset/swift-zoos-collect.md +19 -0
- package/.changeset/thick-mice-collect.md +5 -0
- package/.changeset/thick-tips-cry.md +9 -0
- package/.changeset/thirty-ties-arrive.md +26 -0
- package/.changeset/tough-timers-begin.md +8 -0
- package/.changeset/unlucky-rats-decide.md +5 -0
- package/.changeset/violet-lions-draw.md +5 -0
- package/.changeset/wet-forks-rhyme.md +5 -0
- package/.changeset/wild-dolphins-jog.md +5 -0
- package/.changeset/yellow-flies-repeat.md +5 -0
- package/CHANGELOG.md +3649 -0
- package/apollo-client.cjs +775 -451
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +210 -156
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +210 -156
- package/cache/core/cache.d.ts +19 -0
- package/cache/core/cache.js +28 -7
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +8 -1
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/core/types/DataProxy.d.ts +104 -0
- package/cache/core/types/DataProxy.js.map +1 -1
- package/cache/core/types/common.d.ts +5 -1
- package/cache/core/types/common.js +4 -1
- package/cache/core/types/common.js.map +1 -1
- package/cache/inmemory/entityStore.d.ts +10 -1
- package/cache/inmemory/entityStore.js +190 -29
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/fixPolyfills.js +9 -0
- package/cache/inmemory/fixPolyfills.js.map +1 -1
- package/cache/inmemory/fixPolyfills.native.js +12 -0
- package/cache/inmemory/fixPolyfills.native.js.map +1 -1
- package/cache/inmemory/fragmentRegistry.d.ts +1 -0
- package/cache/inmemory/fragmentRegistry.js +39 -14
- package/cache/inmemory/fragmentRegistry.js.map +1 -1
- package/cache/inmemory/helpers.js +20 -11
- package/cache/inmemory/helpers.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +9 -0
- package/cache/inmemory/inMemoryCache.js +172 -10
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.js +72 -4
- package/cache/inmemory/key-extractor.js.map +1 -1
- package/cache/inmemory/object-canon.js +87 -3
- package/cache/inmemory/object-canon.js.map +1 -1
- package/cache/inmemory/policies.js +190 -43
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/reactiveVars.js +20 -2
- package/cache/inmemory/reactiveVars.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +4 -0
- package/cache/inmemory/readFromStore.js +65 -12
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +46 -0
- package/cache/inmemory/types.js.map +1 -1
- package/cache/inmemory/writeToStore.js +152 -25
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/config/jest/setup.js +2 -0
- package/config/jest/setup.js.map +1 -1
- package/core/ApolloClient.d.ts +273 -3
- package/core/ApolloClient.js +239 -7
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.d.ts +4 -6
- package/core/LocalState.js +56 -18
- package/core/LocalState.js.map +1 -1
- package/core/ObservableQuery.d.ts +27 -0
- package/core/ObservableQuery.js +246 -31
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +4 -3
- package/core/QueryInfo.js +122 -13
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +9 -2
- package/core/QueryManager.js +259 -53
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +222 -122
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +222 -122
- package/core/equalByQuery.js +20 -1
- package/core/equalByQuery.js.map +1 -1
- package/core/index.d.ts +1 -1
- package/core/index.js +19 -0
- package/core/index.js.map +1 -1
- package/core/networkStatus.d.ts +39 -0
- package/core/networkStatus.js +39 -0
- package/core/networkStatus.js.map +1 -1
- package/core/types.d.ts +9 -0
- package/core/types.js.map +1 -1
- package/core/watchQueryOptions.d.ts +245 -2
- package/core/watchQueryOptions.js.map +1 -1
- package/dev/dev.cjs +10 -119
- package/dev/dev.cjs.map +1 -1
- package/dev/dev.cjs.native.js +10 -119
- package/dev/loadErrorMessageHandler.js.map +1 -1
- package/errors/errors.cjs +1 -1
- package/errors/errors.cjs.map +1 -1
- package/errors/errors.cjs.native.js +1 -1
- package/errors/index.js +14 -1
- package/errors/index.js.map +1 -1
- package/invariantErrorCodes.js +6 -8
- package/link/batch/batch.cjs +2 -2
- package/link/batch/batch.cjs.map +1 -1
- package/link/batch/batch.cjs.native.js +2 -2
- package/link/batch/batchLink.d.ts +21 -0
- package/link/batch/batchLink.js +2 -1
- package/link/batch/batchLink.js.map +1 -1
- package/link/batch/batching.js +24 -1
- package/link/batch/batching.js.map +1 -1
- package/link/batch-http/batch-http.cjs +3 -2
- package/link/batch-http/batch-http.cjs.map +1 -1
- package/link/batch-http/batch-http.cjs.native.js +3 -2
- package/link/batch-http/batchHttpLink.d.ts +4 -0
- package/link/batch-http/batchHttpLink.js +53 -2
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/context/context.cjs.map +1 -1
- package/link/context/index.js +1 -0
- package/link/context/index.js.map +1 -1
- package/link/core/ApolloLink.d.ts +15 -0
- package/link/core/ApolloLink.js +20 -9
- package/link/core/ApolloLink.js.map +1 -1
- package/link/core/core.cjs +13 -9
- package/link/core/core.cjs.map +1 -1
- package/link/core/core.cjs.native.js +13 -9
- package/link/error/error.cjs +1 -1
- package/link/error/error.cjs.map +1 -1
- package/link/error/error.cjs.native.js +1 -1
- package/link/error/index.d.ts +3 -0
- package/link/error/index.js +4 -1
- package/link/error/index.js.map +1 -1
- package/link/http/HttpLink.d.ts +0 -2
- package/link/http/HttpLink.js +1 -1
- package/link/http/HttpLink.js.map +1 -1
- package/link/http/checkFetcher.js.map +1 -1
- package/link/http/createHttpLink.js +23 -1
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/createSignalIfSupported.d.ts +5 -0
- package/link/http/createSignalIfSupported.js +5 -0
- package/link/http/createSignalIfSupported.js.map +1 -1
- package/link/http/http.cjs +14 -12
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +14 -12
- package/link/http/index.js +2 -1
- package/link/http/index.js.map +1 -1
- package/link/http/iterators/async.d.ts +4 -0
- package/link/http/iterators/async.js +4 -0
- package/link/http/iterators/async.js.map +1 -1
- package/link/http/iterators/nodeStream.d.ts +4 -0
- package/link/http/iterators/nodeStream.js +4 -0
- package/link/http/iterators/nodeStream.js.map +1 -1
- package/link/http/iterators/promise.d.ts +4 -0
- package/link/http/iterators/promise.js +4 -0
- package/link/http/iterators/promise.js.map +1 -1
- package/link/http/iterators/reader.d.ts +4 -0
- package/link/http/iterators/reader.js +4 -0
- package/link/http/iterators/reader.js.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js +51 -10
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/http/responseIterator.d.ts +4 -0
- package/link/http/responseIterator.js +6 -0
- package/link/http/responseIterator.js.map +1 -1
- package/link/http/rewriteURIForGET.d.ts +1 -1
- package/link/http/rewriteURIForGET.js +10 -0
- package/link/http/rewriteURIForGET.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.d.ts +45 -0
- package/link/http/selectHttpOptionsAndBody.js +23 -0
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/http/selectURI.js.map +1 -1
- package/link/http/serializeFetchParameter.js.map +1 -1
- package/link/persisted-queries/index.d.ts +11 -1
- package/link/persisted-queries/index.js +62 -7
- package/link/persisted-queries/index.js.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs +30 -7
- package/link/persisted-queries/persisted-queries.cjs.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.native.js +30 -7
- package/link/remove-typename/remove-typename.cjs +30 -11
- package/link/remove-typename/remove-typename.cjs.map +1 -1
- package/link/remove-typename/remove-typename.cjs.native.js +30 -11
- package/link/remove-typename/removeTypenameFromVariables.d.ts +9 -1
- package/link/remove-typename/removeTypenameFromVariables.js +31 -12
- package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
- package/link/retry/delayFunction.d.ts +29 -0
- package/link/retry/delayFunction.js +6 -0
- package/link/retry/delayFunction.js.map +1 -1
- package/link/retry/retry.cjs +5 -5
- package/link/retry/retry.cjs.map +1 -1
- package/link/retry/retry.cjs.native.js +5 -5
- package/link/retry/retryFunction.d.ts +20 -0
- package/link/retry/retryLink.d.ts +6 -0
- package/link/retry/retryLink.js +31 -6
- package/link/retry/retryLink.js.map +1 -1
- package/link/schema/index.d.ts +13 -0
- package/link/schema/index.js +3 -3
- package/link/schema/index.js.map +1 -1
- package/link/schema/schema.cjs +3 -3
- package/link/schema/schema.cjs.map +1 -1
- package/link/schema/schema.cjs.native.js +3 -3
- package/link/subscriptions/index.js +35 -2
- package/link/subscriptions/index.js.map +1 -1
- package/link/subscriptions/subscriptions.cjs +3 -2
- package/link/subscriptions/subscriptions.cjs.map +1 -1
- package/link/subscriptions/subscriptions.cjs.native.js +3 -2
- package/link/utils/createOperation.js.map +1 -1
- package/link/utils/filterOperationVariables.js +4 -0
- package/link/utils/filterOperationVariables.js.map +1 -1
- package/link/utils/toPromise.js.map +1 -1
- package/link/utils/transformOperation.js +3 -2
- package/link/utils/transformOperation.js.map +1 -1
- package/link/utils/utils.cjs +2 -2
- package/link/utils/utils.cjs.map +1 -1
- package/link/utils/utils.cjs.native.js +2 -2
- package/link/utils/validateOperation.js.map +1 -1
- package/link/ws/index.d.ts +12 -0
- package/link/ws/index.js +1 -1
- package/link/ws/index.js.map +1 -1
- package/link/ws/ws.cjs +1 -1
- package/link/ws/ws.cjs.map +1 -1
- package/link/ws/ws.cjs.native.js +1 -1
- package/package.json +53 -41
- package/react/cache/QueryReference.d.ts +27 -13
- package/react/cache/QueryReference.js +122 -42
- package/react/cache/QueryReference.js.map +1 -1
- package/react/cache/SuspenseCache.d.ts +10 -0
- package/react/cache/SuspenseCache.js +1 -2
- package/react/cache/SuspenseCache.js.map +1 -1
- package/react/cache/getSuspenseCache.js.map +1 -1
- package/react/cache/types.d.ts +3 -0
- package/react/cache/types.js.map +1 -1
- package/react/context/ApolloContext.d.ts +5 -0
- package/react/context/ApolloContext.js +10 -3
- package/react/context/ApolloContext.js.map +1 -1
- package/react/context/context.cjs +1 -3
- package/react/context/context.cjs.map +1 -1
- package/react/context/context.cjs.native.js +1 -3
- package/react/hoc/graphql.js.map +1 -1
- package/react/hoc/hoc-utils.js +3 -1
- package/react/hoc/hoc-utils.js.map +1 -1
- package/react/hoc/hoc.cjs +9 -17
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/hoc.cjs.native.js +9 -17
- package/react/hoc/mutation-hoc.js +9 -4
- package/react/hoc/mutation-hoc.js.map +1 -1
- package/react/hoc/query-hoc.js +10 -4
- package/react/hoc/query-hoc.js.map +1 -1
- package/react/hoc/subscription-hoc.js +10 -4
- package/react/hoc/subscription-hoc.js.map +1 -1
- package/react/hoc/withApollo.js +3 -4
- package/react/hoc/withApollo.js.map +1 -1
- package/react/hooks/hooks.cjs +230 -98
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +230 -98
- package/react/hooks/index.d.ts +4 -0
- package/react/hooks/index.js +2 -0
- package/react/hooks/index.js.map +1 -1
- package/react/hooks/internal/__use.js +5 -0
- package/react/hooks/internal/__use.js.map +1 -1
- package/react/hooks/internal/index.d.ts +1 -0
- package/react/hooks/internal/index.js +2 -0
- package/react/hooks/internal/index.js.map +1 -1
- package/react/hooks/internal/useDeepMemo.js.map +1 -1
- package/react/hooks/internal/useIsomorphicLayoutEffect.js +6 -3
- package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -1
- package/react/hooks/internal/useRenderGuard.d.ts +2 -0
- package/react/hooks/internal/useRenderGuard.js +17 -0
- package/react/hooks/internal/useRenderGuard.js.map +1 -0
- package/react/hooks/useBackgroundQuery.d.ts +12 -9
- package/react/hooks/useBackgroundQuery.js +14 -11
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useFragment.js +4 -3
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.js +13 -4
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +30 -0
- package/react/hooks/useLoadableQuery.js +61 -0
- package/react/hooks/useLoadableQuery.js.map +1 -0
- package/react/hooks/useMutation.js +8 -3
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +11 -0
- package/react/hooks/useQuery.js +138 -6
- package/react/hooks/useQuery.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/useReactiveVar.js +5 -0
- package/react/hooks/useReactiveVar.js.map +1 -1
- package/react/hooks/useReadQuery.d.ts +19 -0
- package/react/hooks/useReadQuery.js +9 -9
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSubscription.js +5 -0
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseQuery.js +22 -22
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +53 -1
- package/react/hooks/useSyncExternalStore.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/parser/index.d.ts +3 -0
- package/react/parser/index.js +16 -6
- package/react/parser/index.js.map +1 -1
- package/react/parser/parser.cjs +19 -5
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +19 -5
- 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 +248 -1
- package/react/react.cjs.map +1 -1
- package/react/react.cjs.native.js +248 -1
- package/react/ssr/RenderPromises.js +21 -1
- package/react/ssr/RenderPromises.js.map +1 -1
- package/react/ssr/getDataFromTree.js +18 -3
- package/react/ssr/getDataFromTree.js.map +1 -1
- package/react/ssr/ssr.cjs +6 -4
- package/react/ssr/ssr.cjs.map +1 -1
- package/react/ssr/ssr.cjs.native.js +6 -4
- package/react/types/types.d.ts +129 -1
- package/react/types/types.js.map +1 -1
- package/testing/core/core.cjs +14 -11
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +14 -11
- package/testing/core/itAsync.d.ts +1 -1
- package/testing/core/itAsync.js.map +1 -1
- package/testing/core/mocking/mockFetch.d.ts +2 -2
- package/testing/core/mocking/mockFetch.js +8 -4
- package/testing/core/mocking/mockFetch.js.map +1 -1
- package/testing/core/mocking/mockLink.d.ts +1 -1
- package/testing/core/mocking/mockLink.js +17 -7
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/core/mocking/mockQueryManager.js +2 -0
- package/testing/core/mocking/mockQueryManager.js.map +1 -1
- package/testing/core/mocking/mockSubscriptionLink.d.ts +1 -1
- package/testing/core/mocking/mockSubscriptionLink.js +1 -1
- package/testing/core/mocking/mockSubscriptionLink.js.map +1 -1
- package/testing/core/mocking/mockWatchQuery.js +1 -1
- package/testing/core/mocking/mockWatchQuery.js.map +1 -1
- package/testing/core/observableToPromise.d.ts +17 -3
- package/testing/core/observableToPromise.js +5 -0
- package/testing/core/observableToPromise.js.map +1 -1
- package/testing/core/subscribeAndCount.js +3 -0
- package/testing/core/subscribeAndCount.js.map +1 -1
- package/testing/core/wait.js +2 -2
- package/testing/core/wait.js.map +1 -1
- package/testing/core/withConsoleSpy.d.ts +3 -0
- package/testing/core/withConsoleSpy.js +7 -1
- package/testing/core/withConsoleSpy.js.map +1 -1
- package/testing/core/wrap.js +2 -0
- package/testing/core/wrap.js.map +1 -1
- package/testing/internal/ObservableStream.js +14 -14
- package/testing/internal/ObservableStream.js.map +1 -1
- package/testing/internal/disposables/disableActWarnings.d.ts +10 -0
- package/testing/internal/disposables/disableActWarnings.js +15 -0
- package/testing/internal/disposables/disableActWarnings.js.map +1 -0
- package/testing/internal/disposables/index.d.ts +1 -0
- package/testing/internal/disposables/index.js +1 -0
- package/testing/internal/disposables/index.js.map +1 -1
- package/testing/internal/disposables/spyOnConsole.d.ts +1 -0
- package/testing/internal/disposables/spyOnConsole.js +2 -0
- package/testing/internal/disposables/spyOnConsole.js.map +1 -1
- package/testing/internal/disposables/withCleanup.d.ts +1 -0
- package/testing/internal/disposables/withCleanup.js +3 -0
- package/testing/internal/disposables/withCleanup.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/profile/Render.d.ts +32 -1
- package/testing/internal/profile/Render.js +14 -2
- package/testing/internal/profile/Render.js.map +1 -1
- package/testing/internal/profile/context.d.ts +10 -0
- package/testing/internal/profile/context.js +14 -0
- package/testing/internal/profile/context.js.map +1 -0
- package/testing/internal/profile/index.d.ts +2 -2
- package/testing/internal/profile/index.js +1 -1
- package/testing/internal/profile/index.js.map +1 -1
- package/testing/internal/profile/profile.d.ts +67 -13
- package/testing/internal/profile/profile.js +153 -79
- package/testing/internal/profile/profile.js.map +1 -1
- package/testing/internal/profile/traces.d.ts +4 -0
- package/testing/internal/profile/traces.js +9 -5
- package/testing/internal/profile/traces.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 +46 -0
- package/testing/internal/scenarios/index.js.map +1 -0
- package/testing/matchers/ProfiledComponent.js +29 -26
- package/testing/matchers/ProfiledComponent.js.map +1 -1
- package/testing/matchers/index.js +4 -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/toBeGarbageCollected.d.ts +8 -0
- package/testing/matchers/toBeGarbageCollected.js +48 -0
- package/testing/matchers/toBeGarbageCollected.js.map +1 -0
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.js.map +1 -1
- package/testing/matchers/toMatchDocument.js.map +1 -1
- package/testing/react/MockedProvider.d.ts +5 -1
- package/testing/react/MockedProvider.js +6 -2
- package/testing/react/MockedProvider.js.map +1 -1
- package/testing/testing.cjs +4 -2
- package/testing/testing.cjs.map +1 -1
- package/testing/testing.cjs.native.js +4 -2
- 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 +261 -0
- package/utilities/caching/sizes.js +27 -0
- package/utilities/caching/sizes.js.map +1 -0
- package/utilities/common/arrays.js +1 -0
- package/utilities/common/arrays.js.map +1 -1
- package/utilities/common/canUse.js +17 -2
- package/utilities/common/canUse.js.map +1 -1
- package/utilities/common/canonicalStringify.d.ts +17 -0
- package/utilities/common/canonicalStringify.js +49 -2
- package/utilities/common/canonicalStringify.js.map +1 -1
- package/utilities/common/cloneDeep.d.ts +3 -0
- package/utilities/common/cloneDeep.js +5 -0
- package/utilities/common/cloneDeep.js.map +1 -1
- package/utilities/common/compact.d.ts +4 -0
- package/utilities/common/compact.js +4 -0
- package/utilities/common/compact.js.map +1 -1
- package/utilities/common/errorHandling.js +1 -3
- package/utilities/common/errorHandling.js.map +1 -1
- package/utilities/common/incrementalResult.js +3 -0
- package/utilities/common/incrementalResult.js.map +1 -1
- package/utilities/common/makeUniqueId.js +2 -0
- package/utilities/common/makeUniqueId.js.map +1 -1
- package/utilities/common/maybeDeepFreeze.js +3 -0
- package/utilities/common/maybeDeepFreeze.js.map +1 -1
- package/utilities/common/mergeDeep.js +12 -1
- package/utilities/common/mergeDeep.js.map +1 -1
- package/utilities/common/mergeOptions.d.ts +1 -1
- package/utilities/common/mergeOptions.js.map +1 -1
- package/utilities/common/omitDeep.js.map +1 -1
- package/utilities/globals/global.js +7 -1
- package/utilities/globals/global.js.map +1 -1
- package/utilities/globals/globals.cjs +4 -5
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +4 -5
- package/utilities/globals/index.d.ts +4 -0
- package/utilities/globals/index.js +7 -0
- package/utilities/globals/index.js.map +1 -1
- package/utilities/globals/invariantWrappers.d.ts +40 -0
- package/utilities/globals/invariantWrappers.js +11 -3
- package/utilities/globals/invariantWrappers.js.map +1 -1
- package/utilities/globals/maybe.js.map +1 -1
- package/utilities/graphql/DocumentTransform.d.ts +20 -6
- package/utilities/graphql/DocumentTransform.js +54 -29
- package/utilities/graphql/DocumentTransform.js.map +1 -1
- package/utilities/graphql/directives.js +3 -0
- package/utilities/graphql/directives.js.map +1 -1
- package/utilities/graphql/fragments.d.ts +25 -0
- package/utilities/graphql/fragments.js +36 -0
- package/utilities/graphql/fragments.js.map +1 -1
- package/utilities/graphql/getFromAST.d.ts +5 -0
- package/utilities/graphql/getFromAST.js +9 -0
- package/utilities/graphql/getFromAST.js.map +1 -1
- package/utilities/graphql/print.js +8 -5
- package/utilities/graphql/print.js.map +1 -1
- package/utilities/graphql/storeUtils.d.ts +14 -0
- package/utilities/graphql/storeUtils.js +8 -2
- package/utilities/graphql/storeUtils.js.map +1 -1
- package/utilities/graphql/transform.js +106 -7
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/index.d.ts +4 -0
- package/utilities/index.js +1 -0
- package/utilities/index.js.map +1 -1
- package/utilities/observables/Concast.d.ts +1 -1
- package/utilities/observables/Concast.js +85 -2
- package/utilities/observables/Concast.js.map +1 -1
- package/utilities/observables/Observable.js +6 -0
- package/utilities/observables/Observable.js.map +1 -1
- package/utilities/observables/asyncMap.js +12 -3
- package/utilities/observables/asyncMap.js.map +1 -1
- package/utilities/observables/iteration.js +3 -0
- package/utilities/observables/iteration.js.map +1 -1
- package/utilities/observables/subclassing.js +14 -0
- package/utilities/observables/subclassing.js.map +1 -1
- package/utilities/policies/pagination.js +47 -3
- package/utilities/policies/pagination.js.map +1 -1
- package/utilities/promises/decoration.js +1 -0
- package/utilities/promises/decoration.js.map +1 -1
- package/utilities/subscriptions/relay/index.js.map +1 -1
- package/utilities/subscriptions/relay/relay.cjs +9 -8
- package/utilities/subscriptions/relay/relay.cjs.map +1 -1
- package/utilities/subscriptions/relay/relay.cjs.native.js +9 -8
- package/utilities/subscriptions/urql/index.js.map +1 -1
- package/utilities/subscriptions/urql/urql.cjs +9 -8
- package/utilities/subscriptions/urql/urql.cjs.map +1 -1
- package/utilities/subscriptions/urql/urql.cjs.native.js +9 -8
- package/utilities/types/DeepOmit.js.map +1 -1
- package/utilities/types/DeepPartial.d.ts +1 -1
- package/utilities/types/DeepPartial.js +4 -0
- package/utilities/types/DeepPartial.js.map +1 -1
- package/utilities/types/IsStrictlyAny.js.map +1 -1
- package/utilities/types/OnlyRequiredProperties.d.ts +7 -0
- package/utilities/types/OnlyRequiredProperties.js +2 -0
- package/utilities/types/OnlyRequiredProperties.js.map +1 -0
- package/utilities/types/TODO.d.ts +3 -0
- package/utilities/types/TODO.js +2 -0
- package/utilities/types/TODO.js.map +1 -0
- package/utilities/utilities.cjs +114 -58
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +114 -58
- package/version.js +1 -1
- package/cache/core/cache.d.ts.map +0 -1
- package/cache/core/types/Cache.d.ts.map +0 -1
- package/cache/core/types/DataProxy.d.ts.map +0 -1
- package/cache/core/types/common.d.ts.map +0 -1
- package/cache/index.d.ts.map +0 -1
- package/cache/inmemory/entityStore.d.ts.map +0 -1
- package/cache/inmemory/fixPolyfills.d.ts.map +0 -1
- package/cache/inmemory/fixPolyfills.native.d.ts.map +0 -1
- package/cache/inmemory/fragmentRegistry.d.ts.map +0 -1
- package/cache/inmemory/helpers.d.ts.map +0 -1
- package/cache/inmemory/inMemoryCache.d.ts.map +0 -1
- package/cache/inmemory/key-extractor.d.ts.map +0 -1
- package/cache/inmemory/object-canon.d.ts.map +0 -1
- package/cache/inmemory/policies.d.ts.map +0 -1
- package/cache/inmemory/reactiveVars.d.ts.map +0 -1
- package/cache/inmemory/readFromStore.d.ts.map +0 -1
- package/cache/inmemory/types.d.ts.map +0 -1
- package/cache/inmemory/writeToStore.d.ts.map +0 -1
- package/config/jest/setup.d.ts.map +0 -1
- package/core/ApolloClient.d.ts.map +0 -1
- package/core/LocalState.d.ts.map +0 -1
- package/core/ObservableQuery.d.ts.map +0 -1
- package/core/QueryInfo.d.ts.map +0 -1
- package/core/QueryManager.d.ts.map +0 -1
- package/core/equalByQuery.d.ts.map +0 -1
- package/core/index.d.ts.map +0 -1
- package/core/networkStatus.d.ts.map +0 -1
- package/core/types.d.ts.map +0 -1
- package/core/watchQueryOptions.d.ts.map +0 -1
- package/dev/index.d.ts.map +0 -1
- package/dev/loadDevMessages.d.ts.map +0 -1
- package/dev/loadErrorMessageHandler.d.ts.map +0 -1
- package/dev/loadErrorMessages.d.ts.map +0 -1
- package/errors/index.d.ts.map +0 -1
- package/index.d.ts.map +0 -1
- package/invariantErrorCodes.d.ts.map +0 -1
- package/link/batch/batchLink.d.ts.map +0 -1
- package/link/batch/batching.d.ts.map +0 -1
- package/link/batch/index.d.ts.map +0 -1
- package/link/batch-http/batchHttpLink.d.ts.map +0 -1
- package/link/batch-http/index.d.ts.map +0 -1
- package/link/context/index.d.ts.map +0 -1
- package/link/core/ApolloLink.d.ts.map +0 -1
- package/link/core/concat.d.ts.map +0 -1
- package/link/core/empty.d.ts.map +0 -1
- package/link/core/execute.d.ts.map +0 -1
- package/link/core/from.d.ts.map +0 -1
- package/link/core/index.d.ts.map +0 -1
- package/link/core/split.d.ts.map +0 -1
- package/link/core/types.d.ts.map +0 -1
- package/link/error/index.d.ts.map +0 -1
- package/link/http/HttpLink.d.ts.map +0 -1
- package/link/http/checkFetcher.d.ts.map +0 -1
- package/link/http/createHttpLink.d.ts.map +0 -1
- package/link/http/createSignalIfSupported.d.ts.map +0 -1
- package/link/http/index.d.ts.map +0 -1
- package/link/http/iterators/async.d.ts.map +0 -1
- package/link/http/iterators/nodeStream.d.ts.map +0 -1
- package/link/http/iterators/promise.d.ts.map +0 -1
- package/link/http/iterators/reader.d.ts.map +0 -1
- package/link/http/parseAndCheckHttpResponse.d.ts.map +0 -1
- package/link/http/responseIterator.d.ts.map +0 -1
- package/link/http/rewriteURIForGET.d.ts.map +0 -1
- package/link/http/selectHttpOptionsAndBody.d.ts.map +0 -1
- package/link/http/selectURI.d.ts.map +0 -1
- package/link/http/serializeFetchParameter.d.ts.map +0 -1
- package/link/persisted-queries/index.d.ts.map +0 -1
- package/link/remove-typename/index.d.ts.map +0 -1
- package/link/remove-typename/removeTypenameFromVariables.d.ts.map +0 -1
- package/link/retry/delayFunction.d.ts.map +0 -1
- package/link/retry/index.d.ts.map +0 -1
- package/link/retry/retryFunction.d.ts.map +0 -1
- package/link/retry/retryLink.d.ts.map +0 -1
- package/link/schema/index.d.ts.map +0 -1
- package/link/subscriptions/index.d.ts.map +0 -1
- package/link/utils/createOperation.d.ts.map +0 -1
- package/link/utils/filterOperationVariables.d.ts.map +0 -1
- package/link/utils/fromError.d.ts.map +0 -1
- package/link/utils/fromPromise.d.ts.map +0 -1
- package/link/utils/index.d.ts.map +0 -1
- package/link/utils/throwServerError.d.ts.map +0 -1
- package/link/utils/toPromise.d.ts.map +0 -1
- package/link/utils/transformOperation.d.ts.map +0 -1
- package/link/utils/validateOperation.d.ts.map +0 -1
- package/link/ws/index.d.ts.map +0 -1
- package/react/cache/QueryReference.d.ts.map +0 -1
- package/react/cache/SuspenseCache.d.ts.map +0 -1
- package/react/cache/getSuspenseCache.d.ts.map +0 -1
- package/react/cache/index.d.ts.map +0 -1
- package/react/cache/types.d.ts.map +0 -1
- package/react/components/Mutation.d.ts.map +0 -1
- package/react/components/Query.d.ts.map +0 -1
- package/react/components/Subscription.d.ts.map +0 -1
- package/react/components/index.d.ts.map +0 -1
- package/react/components/types.d.ts.map +0 -1
- package/react/context/ApolloConsumer.d.ts.map +0 -1
- package/react/context/ApolloContext.d.ts.map +0 -1
- package/react/context/ApolloProvider.d.ts.map +0 -1
- package/react/context/index.d.ts.map +0 -1
- package/react/hoc/graphql.d.ts.map +0 -1
- package/react/hoc/hoc-utils.d.ts.map +0 -1
- package/react/hoc/index.d.ts.map +0 -1
- package/react/hoc/mutation-hoc.d.ts.map +0 -1
- package/react/hoc/query-hoc.d.ts.map +0 -1
- package/react/hoc/subscription-hoc.d.ts.map +0 -1
- package/react/hoc/types.d.ts.map +0 -1
- package/react/hoc/withApollo.d.ts.map +0 -1
- package/react/hooks/constants.d.ts.map +0 -1
- package/react/hooks/index.d.ts.map +0 -1
- package/react/hooks/internal/__use.d.ts.map +0 -1
- package/react/hooks/internal/index.d.ts.map +0 -1
- package/react/hooks/internal/useDeepMemo.d.ts.map +0 -1
- package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts.map +0 -1
- package/react/hooks/useApolloClient.d.ts.map +0 -1
- package/react/hooks/useBackgroundQuery.d.ts.map +0 -1
- package/react/hooks/useFragment.d.ts.map +0 -1
- package/react/hooks/useLazyQuery.d.ts.map +0 -1
- package/react/hooks/useMutation.d.ts.map +0 -1
- package/react/hooks/useQuery.d.ts.map +0 -1
- package/react/hooks/useReactiveVar.d.ts.map +0 -1
- package/react/hooks/useReadQuery.d.ts.map +0 -1
- package/react/hooks/useSubscription.d.ts.map +0 -1
- package/react/hooks/useSuspenseQuery.d.ts.map +0 -1
- package/react/hooks/useSyncExternalStore.d.ts.map +0 -1
- package/react/index.d.ts.map +0 -1
- package/react/parser/index.d.ts.map +0 -1
- package/react/ssr/RenderPromises.d.ts.map +0 -1
- package/react/ssr/getDataFromTree.d.ts.map +0 -1
- package/react/ssr/index.d.ts.map +0 -1
- package/react/ssr/renderToStringWithData.d.ts.map +0 -1
- package/react/types/types.d.ts.map +0 -1
- package/testing/core/index.d.ts.map +0 -1
- package/testing/core/itAsync.d.ts.map +0 -1
- package/testing/core/mocking/mockClient.d.ts.map +0 -1
- package/testing/core/mocking/mockFetch.d.ts.map +0 -1
- package/testing/core/mocking/mockLink.d.ts.map +0 -1
- package/testing/core/mocking/mockQueryManager.d.ts.map +0 -1
- package/testing/core/mocking/mockSubscriptionLink.d.ts.map +0 -1
- package/testing/core/mocking/mockWatchQuery.d.ts.map +0 -1
- package/testing/core/observableToPromise.d.ts.map +0 -1
- package/testing/core/subscribeAndCount.d.ts.map +0 -1
- package/testing/core/wait.d.ts.map +0 -1
- package/testing/core/withConsoleSpy.d.ts.map +0 -1
- package/testing/core/wrap.d.ts.map +0 -1
- package/testing/index.d.ts.map +0 -1
- package/testing/internal/ObservableStream.d.ts.map +0 -1
- package/testing/internal/disposables/index.d.ts.map +0 -1
- package/testing/internal/disposables/spyOnConsole.d.ts.map +0 -1
- package/testing/internal/disposables/withCleanup.d.ts.map +0 -1
- package/testing/internal/index.d.ts.map +0 -1
- package/testing/internal/profile/Render.d.ts.map +0 -1
- package/testing/internal/profile/index.d.ts.map +0 -1
- package/testing/internal/profile/profile.d.ts.map +0 -1
- package/testing/internal/profile/traces.d.ts.map +0 -1
- package/testing/matchers/ProfiledComponent.d.ts.map +0 -1
- package/testing/matchers/index.d.ts.map +0 -1
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.d.ts.map +0 -1
- package/testing/matchers/toMatchDocument.d.ts.map +0 -1
- package/testing/react/MockedProvider.d.ts.map +0 -1
- package/utilities/common/arrays.d.ts.map +0 -1
- package/utilities/common/canUse.d.ts.map +0 -1
- package/utilities/common/canonicalStringify.d.ts.map +0 -1
- package/utilities/common/cloneDeep.d.ts.map +0 -1
- package/utilities/common/compact.d.ts.map +0 -1
- package/utilities/common/errorHandling.d.ts.map +0 -1
- package/utilities/common/filterInPlace.d.ts +0 -2
- package/utilities/common/filterInPlace.d.ts.map +0 -1
- package/utilities/common/filterInPlace.js +0 -11
- package/utilities/common/filterInPlace.js.map +0 -1
- package/utilities/common/incrementalResult.d.ts.map +0 -1
- package/utilities/common/makeUniqueId.d.ts.map +0 -1
- package/utilities/common/maybeDeepFreeze.d.ts.map +0 -1
- package/utilities/common/mergeDeep.d.ts.map +0 -1
- package/utilities/common/mergeOptions.d.ts.map +0 -1
- package/utilities/common/objects.d.ts.map +0 -1
- package/utilities/common/omitDeep.d.ts.map +0 -1
- package/utilities/common/stringifyForDisplay.d.ts.map +0 -1
- package/utilities/common/stripTypename.d.ts.map +0 -1
- package/utilities/globals/global.d.ts.map +0 -1
- package/utilities/globals/index.d.ts.map +0 -1
- package/utilities/globals/invariantWrappers.d.ts.map +0 -1
- package/utilities/globals/maybe.d.ts.map +0 -1
- package/utilities/graphql/DocumentTransform.d.ts.map +0 -1
- package/utilities/graphql/directives.d.ts.map +0 -1
- package/utilities/graphql/fragments.d.ts.map +0 -1
- package/utilities/graphql/getFromAST.d.ts.map +0 -1
- package/utilities/graphql/operations.d.ts.map +0 -1
- package/utilities/graphql/print.d.ts.map +0 -1
- package/utilities/graphql/storeUtils.d.ts.map +0 -1
- package/utilities/graphql/transform.d.ts.map +0 -1
- package/utilities/index.d.ts.map +0 -1
- package/utilities/observables/Concast.d.ts.map +0 -1
- package/utilities/observables/Observable.d.ts.map +0 -1
- package/utilities/observables/asyncMap.d.ts.map +0 -1
- package/utilities/observables/iteration.d.ts.map +0 -1
- package/utilities/observables/subclassing.d.ts.map +0 -1
- package/utilities/policies/pagination.d.ts.map +0 -1
- package/utilities/promises/decoration.d.ts.map +0 -1
- package/utilities/subscriptions/relay/index.d.ts.map +0 -1
- package/utilities/subscriptions/shared.d.ts.map +0 -1
- package/utilities/subscriptions/urql/index.d.ts.map +0 -1
- package/utilities/types/DeepOmit.d.ts.map +0 -1
- package/utilities/types/DeepPartial.d.ts.map +0 -1
- package/utilities/types/IsStrictlyAny.d.ts.map +0 -1
- package/utilities/types/Primitive.d.ts.map +0 -1
- package/version.d.ts.map +0 -1
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { WeakCache, StrongCache } from "@wry/caches";
|
|
2
|
+
/**
|
|
3
|
+
* @internal
|
|
4
|
+
* A version of WeakCache that will auto-schedule a cleanup of the cache when
|
|
5
|
+
* a new item is added.
|
|
6
|
+
* Throttled to once per 100ms.
|
|
7
|
+
*
|
|
8
|
+
* @privateRemarks
|
|
9
|
+
* Should be used throughout the rest of the codebase instead of WeakCache,
|
|
10
|
+
* with the notable exception of usage in `wrap` from `optimism` - that one
|
|
11
|
+
* already handles cleanup and should remain a `WeakCache`.
|
|
12
|
+
*/
|
|
13
|
+
export declare const AutoCleanedWeakCache: typeof WeakCache;
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
*/
|
|
17
|
+
export type AutoCleanedWeakCache<K extends object, V> = WeakCache<K, V>;
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
* A version of StrongCache that will auto-schedule a cleanup of the cache when
|
|
21
|
+
* a new item is added.
|
|
22
|
+
* Throttled to once per 100ms.
|
|
23
|
+
*
|
|
24
|
+
* @privateRemarks
|
|
25
|
+
* Should be used throughout the rest of the codebase instead of StrongCache,
|
|
26
|
+
* with the notable exception of usage in `wrap` from `optimism` - that one
|
|
27
|
+
* already handles cleanup and should remain a `StrongCache`.
|
|
28
|
+
*/
|
|
29
|
+
export declare const AutoCleanedStrongCache: typeof StrongCache;
|
|
30
|
+
/**
|
|
31
|
+
* @internal
|
|
32
|
+
*/
|
|
33
|
+
export type AutoCleanedStrongCache<K, V> = StrongCache<K, V>;
|
|
34
|
+
//# sourceMappingURL=caches.d.ts.map
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { WeakCache, StrongCache } from "@wry/caches";
|
|
2
|
+
var scheduledCleanup = new WeakSet();
|
|
3
|
+
function schedule(cache) {
|
|
4
|
+
if (!scheduledCleanup.has(cache)) {
|
|
5
|
+
scheduledCleanup.add(cache);
|
|
6
|
+
setTimeout(function () {
|
|
7
|
+
cache.clean();
|
|
8
|
+
scheduledCleanup.delete(cache);
|
|
9
|
+
}, 100);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
* A version of WeakCache that will auto-schedule a cleanup of the cache when
|
|
15
|
+
* a new item is added.
|
|
16
|
+
* Throttled to once per 100ms.
|
|
17
|
+
*
|
|
18
|
+
* @privateRemarks
|
|
19
|
+
* Should be used throughout the rest of the codebase instead of WeakCache,
|
|
20
|
+
* with the notable exception of usage in `wrap` from `optimism` - that one
|
|
21
|
+
* already handles cleanup and should remain a `WeakCache`.
|
|
22
|
+
*/
|
|
23
|
+
export var AutoCleanedWeakCache = function (max, dispose) {
|
|
24
|
+
/*
|
|
25
|
+
Some builds of `WeakCache` are function prototypes, some are classes.
|
|
26
|
+
This library still builds with an ES5 target, so we can't extend the
|
|
27
|
+
real classes.
|
|
28
|
+
Instead, we have to use this workaround until we switch to a newer build
|
|
29
|
+
target.
|
|
30
|
+
*/
|
|
31
|
+
var cache = new WeakCache(max, dispose);
|
|
32
|
+
cache.set = function (key, value) {
|
|
33
|
+
schedule(this);
|
|
34
|
+
return WeakCache.prototype.set.call(this, key, value);
|
|
35
|
+
};
|
|
36
|
+
return cache;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* @internal
|
|
40
|
+
* A version of StrongCache that will auto-schedule a cleanup of the cache when
|
|
41
|
+
* a new item is added.
|
|
42
|
+
* Throttled to once per 100ms.
|
|
43
|
+
*
|
|
44
|
+
* @privateRemarks
|
|
45
|
+
* Should be used throughout the rest of the codebase instead of StrongCache,
|
|
46
|
+
* with the notable exception of usage in `wrap` from `optimism` - that one
|
|
47
|
+
* already handles cleanup and should remain a `StrongCache`.
|
|
48
|
+
*/
|
|
49
|
+
export var AutoCleanedStrongCache = function (max, dispose) {
|
|
50
|
+
/*
|
|
51
|
+
Some builds of `StrongCache` are function prototypes, some are classes.
|
|
52
|
+
This library still builds with an ES5 target, so we can't extend the
|
|
53
|
+
real classes.
|
|
54
|
+
Instead, we have to use this workaround until we switch to a newer build
|
|
55
|
+
target.
|
|
56
|
+
*/
|
|
57
|
+
var cache = new StrongCache(max, dispose);
|
|
58
|
+
cache.set = function (key, value) {
|
|
59
|
+
schedule(this);
|
|
60
|
+
return StrongCache.prototype.set.call(this, key, value);
|
|
61
|
+
};
|
|
62
|
+
return cache;
|
|
63
|
+
};
|
|
64
|
+
//# sourceMappingURL=caches.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"caches.js","sourceRoot":"","sources":["../../../src/utilities/caching/caches.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAErD,IAAM,gBAAgB,GAAG,IAAI,OAAO,EAAyB,CAAC;AAC9D,SAAS,QAAQ,CAAC,KAA4B;IAC5C,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QACjC,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC5B,UAAU,CAAC;YACT,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,gBAAgB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACjC,CAAC,EAAE,GAAG,CAAC,CAAC;IACV,CAAC;AACH,CAAC;AACD;;;;;;;;;;GAUG;AACH,MAAM,CAAC,IAAM,oBAAoB,GAAG,UAClC,GAAwB,EACxB,OAAsD;IAEtD;;;;;;MAME;IACF,IAAM,KAAK,GAAG,IAAI,SAAS,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC1C,KAAK,CAAC,GAAG,GAAG,UAAU,GAAQ,EAAE,KAAU;QACxC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACf,OAAO,SAAS,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IACxD,CAAC,CAAC;IACF,OAAO,KAAK,CAAC;AACf,CAA4B,CAAC;AAM7B;;;;;;;;;;GAUG;AACH,MAAM,CAAC,IAAM,sBAAsB,GAAG,UACpC,GAAwB,EACxB,OAAsD;IAEtD;;;;;;MAME;IACF,IAAM,KAAK,GAAG,IAAI,WAAW,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAC5C,KAAK,CAAC,GAAG,GAAG,UAAU,GAAQ,EAAE,KAAU;QACxC,QAAQ,CAAC,IAAI,CAAC,CAAC;QACf,OAAO,WAAW,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,EAAE,GAAG,EAAE,KAAK,CAAC,CAAC;IAC1D,CAAC,CAAC;IACF,OAAO,KAAK,CAAC;AACf,CAA8B,CAAC","sourcesContent":["import type { CommonCache } from \"@wry/caches\";\nimport { WeakCache, StrongCache } from \"@wry/caches\";\n\nconst scheduledCleanup = new WeakSet<CommonCache<any, any>>();\nfunction schedule(cache: CommonCache<any, any>) {\n if (!scheduledCleanup.has(cache)) {\n scheduledCleanup.add(cache);\n setTimeout(() => {\n cache.clean();\n scheduledCleanup.delete(cache);\n }, 100);\n }\n}\n/**\n * @internal\n * A version of WeakCache that will auto-schedule a cleanup of the cache when\n * a new item is added.\n * Throttled to once per 100ms.\n *\n * @privateRemarks\n * Should be used throughout the rest of the codebase instead of WeakCache,\n * with the notable exception of usage in `wrap` from `optimism` - that one\n * already handles cleanup and should remain a `WeakCache`.\n */\nexport const AutoCleanedWeakCache = function (\n max?: number | undefined,\n dispose?: ((value: any, key: any) => void) | undefined\n) {\n /*\n Some builds of `WeakCache` are function prototypes, some are classes.\n This library still builds with an ES5 target, so we can't extend the\n real classes.\n Instead, we have to use this workaround until we switch to a newer build\n target.\n */\n const cache = new WeakCache(max, dispose);\n cache.set = function (key: any, value: any) {\n schedule(this);\n return WeakCache.prototype.set.call(this, key, value);\n };\n return cache;\n} as any as typeof WeakCache;\n/**\n * @internal\n */\nexport type AutoCleanedWeakCache<K extends object, V> = WeakCache<K, V>;\n\n/**\n * @internal\n * A version of StrongCache that will auto-schedule a cleanup of the cache when\n * a new item is added.\n * Throttled to once per 100ms.\n *\n * @privateRemarks\n * Should be used throughout the rest of the codebase instead of StrongCache,\n * with the notable exception of usage in `wrap` from `optimism` - that one\n * already handles cleanup and should remain a `StrongCache`.\n */\nexport const AutoCleanedStrongCache = function (\n max?: number | undefined,\n dispose?: ((value: any, key: any) => void) | undefined\n) {\n /*\n Some builds of `StrongCache` are function prototypes, some are classes.\n This library still builds with an ES5 target, so we can't extend the\n real classes.\n Instead, we have to use this workaround until we switch to a newer build\n target.\n */\n const cache = new StrongCache(max, dispose);\n cache.set = function (key: any, value: any) {\n schedule(this);\n return StrongCache.prototype.set.call(this, key, value);\n };\n return cache;\n} as any as typeof StrongCache;\n/**\n * @internal\n */\nexport type AutoCleanedStrongCache<K, V> = StrongCache<K, V>;\n"]}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
declare const globalCaches: {
|
|
2
|
+
print?: () => number;
|
|
3
|
+
parser?: () => number;
|
|
4
|
+
canonicalStringify?: () => number;
|
|
5
|
+
};
|
|
6
|
+
export declare function registerGlobalCache(name: keyof typeof globalCaches, getSize: () => number): void;
|
|
7
|
+
/**
|
|
8
|
+
* For internal purposes only - please call `ApolloClient.getMemoryInternals` instead
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export declare const getApolloClientMemoryInternals: (() => {
|
|
12
|
+
limits: {
|
|
13
|
+
[k: string]: number;
|
|
14
|
+
};
|
|
15
|
+
sizes: {
|
|
16
|
+
cache?: {
|
|
17
|
+
fragmentQueryDocuments: number | undefined;
|
|
18
|
+
} | undefined;
|
|
19
|
+
addTypenameDocumentTransform?: {
|
|
20
|
+
cache: number;
|
|
21
|
+
}[] | undefined;
|
|
22
|
+
inMemoryCache?: {
|
|
23
|
+
executeSelectionSet: number | undefined;
|
|
24
|
+
executeSubSelectedArray: number | undefined;
|
|
25
|
+
maybeBroadcastWatch: number | undefined;
|
|
26
|
+
} | undefined;
|
|
27
|
+
fragmentRegistry?: {
|
|
28
|
+
findFragmentSpreads: number | undefined;
|
|
29
|
+
lookup: number | undefined;
|
|
30
|
+
transform: number | undefined;
|
|
31
|
+
} | undefined;
|
|
32
|
+
print: number | undefined;
|
|
33
|
+
parser: number | undefined;
|
|
34
|
+
canonicalStringify: number | undefined;
|
|
35
|
+
links: unknown[];
|
|
36
|
+
queryManager: {
|
|
37
|
+
getDocumentInfo: number;
|
|
38
|
+
documentTransforms: {
|
|
39
|
+
cache: number;
|
|
40
|
+
}[];
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
}) | undefined;
|
|
44
|
+
/**
|
|
45
|
+
* For internal purposes only - please call `ApolloClient.getMemoryInternals` instead
|
|
46
|
+
* @internal
|
|
47
|
+
*/
|
|
48
|
+
export declare const getInMemoryCacheMemoryInternals: (() => {
|
|
49
|
+
addTypenameDocumentTransform: {
|
|
50
|
+
cache: number;
|
|
51
|
+
}[];
|
|
52
|
+
inMemoryCache: {
|
|
53
|
+
executeSelectionSet: number | undefined;
|
|
54
|
+
executeSubSelectedArray: number | undefined;
|
|
55
|
+
maybeBroadcastWatch: number | undefined;
|
|
56
|
+
};
|
|
57
|
+
fragmentRegistry: {
|
|
58
|
+
findFragmentSpreads: number | undefined;
|
|
59
|
+
lookup: number | undefined;
|
|
60
|
+
transform: number | undefined;
|
|
61
|
+
};
|
|
62
|
+
cache: {
|
|
63
|
+
fragmentQueryDocuments: number | undefined;
|
|
64
|
+
};
|
|
65
|
+
}) | undefined;
|
|
66
|
+
/**
|
|
67
|
+
* For internal purposes only - please call `ApolloClient.getMemoryInternals` instead
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
export declare const getApolloCacheMemoryInternals: (() => {
|
|
71
|
+
cache: {
|
|
72
|
+
fragmentQueryDocuments: number | undefined;
|
|
73
|
+
};
|
|
74
|
+
}) | undefined;
|
|
75
|
+
export {};
|
|
76
|
+
//# sourceMappingURL=getMemoryInternals.d.ts.map
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { __assign, __spreadArray } from "tslib";
|
|
2
|
+
import { cacheSizes } from "./sizes.js";
|
|
3
|
+
var globalCaches = {};
|
|
4
|
+
export function registerGlobalCache(name, getSize) {
|
|
5
|
+
globalCaches[name] = getSize;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* For internal purposes only - please call `ApolloClient.getMemoryInternals` instead
|
|
9
|
+
* @internal
|
|
10
|
+
*/
|
|
11
|
+
export var getApolloClientMemoryInternals = globalThis.__DEV__ !== false ?
|
|
12
|
+
_getApolloClientMemoryInternals
|
|
13
|
+
: undefined;
|
|
14
|
+
/**
|
|
15
|
+
* For internal purposes only - please call `ApolloClient.getMemoryInternals` instead
|
|
16
|
+
* @internal
|
|
17
|
+
*/
|
|
18
|
+
export var getInMemoryCacheMemoryInternals = globalThis.__DEV__ !== false ?
|
|
19
|
+
_getInMemoryCacheMemoryInternals
|
|
20
|
+
: undefined;
|
|
21
|
+
/**
|
|
22
|
+
* For internal purposes only - please call `ApolloClient.getMemoryInternals` instead
|
|
23
|
+
* @internal
|
|
24
|
+
*/
|
|
25
|
+
export var getApolloCacheMemoryInternals = globalThis.__DEV__ !== false ?
|
|
26
|
+
_getApolloCacheMemoryInternals
|
|
27
|
+
: undefined;
|
|
28
|
+
function getCurrentCacheSizes() {
|
|
29
|
+
// `defaultCacheSizes` is a `const enum` that will be inlined during build, so we have to reconstruct it's shape here
|
|
30
|
+
var defaults = {
|
|
31
|
+
parser: 1000 /* defaultCacheSizes["parser"] */,
|
|
32
|
+
canonicalStringify: 1000 /* defaultCacheSizes["canonicalStringify"] */,
|
|
33
|
+
print: 2000 /* defaultCacheSizes["print"] */,
|
|
34
|
+
"documentTransform.cache": 2000 /* defaultCacheSizes["documentTransform.cache"] */,
|
|
35
|
+
"queryManager.getDocumentInfo": 2000 /* defaultCacheSizes["queryManager.getDocumentInfo"] */,
|
|
36
|
+
"PersistedQueryLink.persistedQueryHashes": 2000 /* defaultCacheSizes["PersistedQueryLink.persistedQueryHashes"] */,
|
|
37
|
+
"fragmentRegistry.transform": 2000 /* defaultCacheSizes["fragmentRegistry.transform"] */,
|
|
38
|
+
"fragmentRegistry.lookup": 1000 /* defaultCacheSizes["fragmentRegistry.lookup"] */,
|
|
39
|
+
"fragmentRegistry.findFragmentSpreads": 4000 /* defaultCacheSizes["fragmentRegistry.findFragmentSpreads"] */,
|
|
40
|
+
"cache.fragmentQueryDocuments": 1000 /* defaultCacheSizes["cache.fragmentQueryDocuments"] */,
|
|
41
|
+
"removeTypenameFromVariables.getVariableDefinitions": 2000 /* defaultCacheSizes["removeTypenameFromVariables.getVariableDefinitions"] */,
|
|
42
|
+
"inMemoryCache.maybeBroadcastWatch": 5000 /* defaultCacheSizes["inMemoryCache.maybeBroadcastWatch"] */,
|
|
43
|
+
"inMemoryCache.executeSelectionSet": 10000 /* defaultCacheSizes["inMemoryCache.executeSelectionSet"] */,
|
|
44
|
+
"inMemoryCache.executeSubSelectedArray": 5000 /* defaultCacheSizes["inMemoryCache.executeSubSelectedArray"] */,
|
|
45
|
+
};
|
|
46
|
+
return Object.fromEntries(Object.entries(defaults).map(function (_a) {
|
|
47
|
+
var k = _a[0], v = _a[1];
|
|
48
|
+
return [
|
|
49
|
+
k,
|
|
50
|
+
cacheSizes[k] || v,
|
|
51
|
+
];
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
function _getApolloClientMemoryInternals() {
|
|
55
|
+
var _a, _b, _c, _d, _e;
|
|
56
|
+
if (!(globalThis.__DEV__ !== false))
|
|
57
|
+
throw new Error("only supported in development mode");
|
|
58
|
+
return {
|
|
59
|
+
limits: getCurrentCacheSizes(),
|
|
60
|
+
sizes: __assign({ print: (_a = globalCaches.print) === null || _a === void 0 ? void 0 : _a.call(globalCaches), parser: (_b = globalCaches.parser) === null || _b === void 0 ? void 0 : _b.call(globalCaches), canonicalStringify: (_c = globalCaches.canonicalStringify) === null || _c === void 0 ? void 0 : _c.call(globalCaches), links: linkInfo(this.link), queryManager: {
|
|
61
|
+
getDocumentInfo: this["queryManager"]["transformCache"].size,
|
|
62
|
+
documentTransforms: transformInfo(this["queryManager"].documentTransform),
|
|
63
|
+
} }, (_e = (_d = this.cache).getMemoryInternals) === null || _e === void 0 ? void 0 : _e.call(_d)),
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function _getApolloCacheMemoryInternals() {
|
|
67
|
+
return {
|
|
68
|
+
cache: {
|
|
69
|
+
fragmentQueryDocuments: getWrapperInformation(this["getFragmentDoc"]),
|
|
70
|
+
},
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
function _getInMemoryCacheMemoryInternals() {
|
|
74
|
+
var fragments = this.config.fragments;
|
|
75
|
+
return __assign(__assign({}, _getApolloCacheMemoryInternals.apply(this)), { addTypenameDocumentTransform: transformInfo(this["addTypenameTransform"]), inMemoryCache: {
|
|
76
|
+
executeSelectionSet: getWrapperInformation(this["storeReader"]["executeSelectionSet"]),
|
|
77
|
+
executeSubSelectedArray: getWrapperInformation(this["storeReader"]["executeSubSelectedArray"]),
|
|
78
|
+
maybeBroadcastWatch: getWrapperInformation(this["maybeBroadcastWatch"]),
|
|
79
|
+
}, fragmentRegistry: {
|
|
80
|
+
findFragmentSpreads: getWrapperInformation(fragments === null || fragments === void 0 ? void 0 : fragments.findFragmentSpreads),
|
|
81
|
+
lookup: getWrapperInformation(fragments === null || fragments === void 0 ? void 0 : fragments.lookup),
|
|
82
|
+
transform: getWrapperInformation(fragments === null || fragments === void 0 ? void 0 : fragments.transform),
|
|
83
|
+
} });
|
|
84
|
+
}
|
|
85
|
+
function isWrapper(f) {
|
|
86
|
+
return !!f && "dirtyKey" in f;
|
|
87
|
+
}
|
|
88
|
+
function getWrapperInformation(f) {
|
|
89
|
+
return isWrapper(f) ? f.size : undefined;
|
|
90
|
+
}
|
|
91
|
+
function isDefined(value) {
|
|
92
|
+
return value != null;
|
|
93
|
+
}
|
|
94
|
+
function transformInfo(transform) {
|
|
95
|
+
return recurseTransformInfo(transform).map(function (cache) { return ({ cache: cache }); });
|
|
96
|
+
}
|
|
97
|
+
function recurseTransformInfo(transform) {
|
|
98
|
+
return transform ?
|
|
99
|
+
__spreadArray(__spreadArray([
|
|
100
|
+
getWrapperInformation(transform === null || transform === void 0 ? void 0 : transform["performWork"])
|
|
101
|
+
], recurseTransformInfo(transform === null || transform === void 0 ? void 0 : transform["left"]), true), recurseTransformInfo(transform === null || transform === void 0 ? void 0 : transform["right"]), true).filter(isDefined)
|
|
102
|
+
: [];
|
|
103
|
+
}
|
|
104
|
+
function linkInfo(link) {
|
|
105
|
+
var _a;
|
|
106
|
+
return link ?
|
|
107
|
+
__spreadArray(__spreadArray([
|
|
108
|
+
(_a = link === null || link === void 0 ? void 0 : link.getMemoryInternals) === null || _a === void 0 ? void 0 : _a.call(link)
|
|
109
|
+
], linkInfo(link === null || link === void 0 ? void 0 : link.left), true), linkInfo(link === null || link === void 0 ? void 0 : link.right), true).filter(isDefined)
|
|
110
|
+
: [];
|
|
111
|
+
}
|
|
112
|
+
//# sourceMappingURL=getMemoryInternals.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getMemoryInternals.js","sourceRoot":"","sources":["../../../src/utilities/caching/getMemoryInternals.ts"],"names":[],"mappings":";AASA,OAAO,EAAE,UAAU,EAAqB,MAAM,YAAY,CAAC;AAE3D,IAAM,YAAY,GAId,EAAE,CAAC;AAEP,MAAM,UAAU,mBAAmB,CACjC,IAA+B,EAC/B,OAAqB;IAErB,YAAY,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC;AAC/B,CAAC;AAwCD;;;GAGG;AACH,MAAM,CAAC,IAAM,8BAA8B,GACzC,OAAO,CAAC,CAAC;IACN,+BAEC;IACJ,CAAC,CAAC,SAAS,CAAC;AAEd;;;GAGG;AACH,MAAM,CAAC,IAAM,+BAA+B,GAC1C,OAAO,CAAC,CAAC;IACN,gCAEC;IACJ,CAAC,CAAC,SAAS,CAAC;AAEd;;;GAGG;AACH,MAAM,CAAC,IAAM,6BAA6B,GACxC,OAAO,CAAC,CAAC;IACN,8BAEC;IACJ,CAAC,CAAC,SAAS,CAAC;AAEd,SAAS,oBAAoB;IAC3B,qHAAqH;IACrH,IAAM,QAAQ,GAAqC;QACjD,MAAM,wCAA6B;QACnC,kBAAkB,oDAAyC;QAC3D,KAAK,uCAA4B;QACjC,yBAAyB,yDAA8C;QACvE,8BAA8B,8DACqB;QACnD,yCAAyC,yEACqB;QAC9D,4BAA4B,4DACqB;QACjD,yBAAyB,yDAA8C;QACvE,sCAAsC,sEACqB;QAC3D,8BAA8B,8DACqB;QACnD,oDAAoD,oFACqB;QACzE,mCAAmC,mEACqB;QACxD,mCAAmC,oEACqB;QACxD,uCAAuC,uEACqB;KAC7D,CAAC;IACF,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,UAAC,EAAM;YAAL,CAAC,QAAA,EAAE,CAAC,QAAA;QAAM,OAAA;YACvC,CAAC;YACD,UAAU,CAAC,CAAqB,CAAC,IAAI,CAAC;SACvC;IAHwC,CAGxC,CAAC,CACH,CAAC;AACJ,CAAC;AAED,SAAS,+BAA+B;;IACtC,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,oCAAoC,CAAC,CAAC;IAEpE,OAAO;QACL,MAAM,EAAE,oBAAoB,EAAE;QAC9B,KAAK,aACH,KAAK,EAAE,MAAA,YAAY,CAAC,KAAK,4DAAI,EAC7B,MAAM,EAAE,MAAA,YAAY,CAAC,MAAM,4DAAI,EAC/B,kBAAkB,EAAE,MAAA,YAAY,CAAC,kBAAkB,4DAAI,EACvD,KAAK,EAAE,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAC1B,YAAY,EAAE;gBACZ,eAAe,EAAE,IAAI,CAAC,cAAc,CAAC,CAAC,gBAAgB,CAAC,CAAC,IAAI;gBAC5D,kBAAkB,EAAE,aAAa,CAC/B,IAAI,CAAC,cAAc,CAAC,CAAC,iBAAiB,CACvC;aACF,IACG,MAAA,MAAA,IAAI,CAAC,KAAK,EAAC,kBAAkB,kDAG8B,CAChE;KACF,CAAC;AACJ,CAAC;AAED,SAAS,8BAA8B;IACrC,OAAO;QACL,KAAK,EAAE;YACL,sBAAsB,EAAE,qBAAqB,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;SACtE;KACF,CAAC;AACJ,CAAC;AAED,SAAS,gCAAgC;IACvC,IAAM,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,SAMzB,CAAC;IAEN,6BACK,8BAA8B,CAAC,KAAK,CAAC,IAAW,CAAC,KACpD,4BAA4B,EAAE,aAAa,CAAC,IAAI,CAAC,sBAAsB,CAAC,CAAC,EACzE,aAAa,EAAE;YACb,mBAAmB,EAAE,qBAAqB,CACxC,IAAI,CAAC,aAAa,CAAC,CAAC,qBAAqB,CAAC,CAC3C;YACD,uBAAuB,EAAE,qBAAqB,CAC5C,IAAI,CAAC,aAAa,CAAC,CAAC,yBAAyB,CAAC,CAC/C;YACD,mBAAmB,EAAE,qBAAqB,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC;SACxE,EACD,gBAAgB,EAAE;YAChB,mBAAmB,EAAE,qBAAqB,CACxC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,mBAAmB,CAC/B;YACD,MAAM,EAAE,qBAAqB,CAAC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,MAAM,CAAC;YAChD,SAAS,EAAE,qBAAqB,CAAC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAE,SAAS,CAAC;SACvD,IACD;AACJ,CAAC;AAED,SAAS,SAAS,CAAC,CAAY;IAC7B,OAAO,CAAC,CAAC,CAAC,IAAI,UAAU,IAAI,CAAC,CAAC;AAChC,CAAC;AAED,SAAS,qBAAqB,CAAC,CAAY;IACzC,OAAO,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAC;AAC3C,CAAC;AAED,SAAS,SAAS,CAAI,KAA2B;IAC/C,OAAO,KAAK,IAAI,IAAI,CAAC;AACvB,CAAC;AAED,SAAS,aAAa,CAAC,SAA6B;IAClD,OAAO,oBAAoB,CAAC,SAAS,CAAC,CAAC,GAAG,CAAC,UAAC,KAAK,IAAK,OAAA,CAAC,EAAE,KAAK,OAAA,EAAE,CAAC,EAAX,CAAW,CAAC,CAAC;AACrE,CAAC;AAED,SAAS,oBAAoB,CAAC,SAA6B;IACzD,OAAO,SAAS,CAAC,CAAC;QACd;YACE,qBAAqB,CAAC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAG,aAAa,CAAC,CAAC;WAC9C,oBAAoB,CAAC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAG,MAAM,CAAC,CAAC,SACzC,oBAAoB,CAAC,SAAS,aAAT,SAAS,uBAAT,SAAS,CAAG,OAAO,CAAC,CAAC,QAC7C,MAAM,CAAC,SAAS,CAAC;QACrB,CAAC,CAAC,EAAE,CAAC;AACT,CAAC;AAED,SAAS,QAAQ,CAAC,IAAiB;;IACjC,OAAO,IAAI,CAAC,CAAC;QACT;YACE,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,kBAAkB,oDAAI;WACzB,QAAQ,CAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,IAAI,CAAC,SACpB,QAAQ,CAAC,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,KAAK,CAAC,QACxB,MAAM,CAAC,SAAS,CAAC;QACrB,CAAC,CAAC,EAAE,CAAC;AACT,CAAC","sourcesContent":["import type { OptimisticWrapperFunction } from \"optimism\";\nimport type {\n InMemoryCache,\n DocumentTransform,\n ApolloLink,\n ApolloCache,\n} from \"../../core/index.js\";\nimport type { ApolloClient } from \"../../core/index.js\";\nimport type { CacheSizes } from \"./sizes.js\";\nimport { cacheSizes, defaultCacheSizes } from \"./sizes.js\";\n\nconst globalCaches: {\n print?: () => number;\n parser?: () => number;\n canonicalStringify?: () => number;\n} = {};\n\nexport function registerGlobalCache(\n name: keyof typeof globalCaches,\n getSize: () => number\n) {\n globalCaches[name] = getSize;\n}\n\n/**\n * Transformative helper type to turn a function of the form\n * ```ts\n * (this: any) => R\n * ```\n * into a function of the form\n * ```ts\n * () => R\n * ```\n * preserving the return type, but removing the `this` parameter.\n *\n * @remarks\n *\n * Further down in the definitions of `_getApolloClientMemoryInternals`,\n * `_getApolloCacheMemoryInternals` and `_getInMemoryCacheMemoryInternals`,\n * having the `this` parameter annotation is extremely useful for type checking\n * inside the function.\n *\n * If this is preserved in the exported types, though, it leads to a situation\n * where `ApolloCache.getMemoryInternals` is a function that requires a `this`\n * of the type `ApolloCache`, while the extending class `InMemoryCache` has a\n * `getMemoryInternals` function that requires a `this` of the type\n * `InMemoryCache`.\n * This is not compatible with TypeScript's inheritence system (although it is\n * perfectly correct), and so TypeScript will complain loudly.\n *\n * We still want to define our functions with the `this` annotation, though,\n * and have the return type inferred.\n * (This requirement for return type inference here makes it impossible to use\n * a function overload that is more explicit on the inner overload than it is\n * on the external overload.)\n *\n * So in the end, we use this helper to remove the `this` annotation from the\n * exported function types, while keeping it in the internal implementation.\n *\n */\ntype RemoveThis<T> = T extends (this: any) => infer R ? () => R : never;\n\n/**\n * For internal purposes only - please call `ApolloClient.getMemoryInternals` instead\n * @internal\n */\nexport const getApolloClientMemoryInternals =\n __DEV__ ?\n (_getApolloClientMemoryInternals as RemoveThis<\n typeof _getApolloClientMemoryInternals\n >)\n : undefined;\n\n/**\n * For internal purposes only - please call `ApolloClient.getMemoryInternals` instead\n * @internal\n */\nexport const getInMemoryCacheMemoryInternals =\n __DEV__ ?\n (_getInMemoryCacheMemoryInternals as RemoveThis<\n typeof _getInMemoryCacheMemoryInternals\n >)\n : undefined;\n\n/**\n * For internal purposes only - please call `ApolloClient.getMemoryInternals` instead\n * @internal\n */\nexport const getApolloCacheMemoryInternals =\n __DEV__ ?\n (_getApolloCacheMemoryInternals as RemoveThis<\n typeof _getApolloCacheMemoryInternals\n >)\n : undefined;\n\nfunction getCurrentCacheSizes() {\n // `defaultCacheSizes` is a `const enum` that will be inlined during build, so we have to reconstruct it's shape here\n const defaults: Record<keyof CacheSizes, number> = {\n parser: defaultCacheSizes[\"parser\"],\n canonicalStringify: defaultCacheSizes[\"canonicalStringify\"],\n print: defaultCacheSizes[\"print\"],\n \"documentTransform.cache\": defaultCacheSizes[\"documentTransform.cache\"],\n \"queryManager.getDocumentInfo\":\n defaultCacheSizes[\"queryManager.getDocumentInfo\"],\n \"PersistedQueryLink.persistedQueryHashes\":\n defaultCacheSizes[\"PersistedQueryLink.persistedQueryHashes\"],\n \"fragmentRegistry.transform\":\n defaultCacheSizes[\"fragmentRegistry.transform\"],\n \"fragmentRegistry.lookup\": defaultCacheSizes[\"fragmentRegistry.lookup\"],\n \"fragmentRegistry.findFragmentSpreads\":\n defaultCacheSizes[\"fragmentRegistry.findFragmentSpreads\"],\n \"cache.fragmentQueryDocuments\":\n defaultCacheSizes[\"cache.fragmentQueryDocuments\"],\n \"removeTypenameFromVariables.getVariableDefinitions\":\n defaultCacheSizes[\"removeTypenameFromVariables.getVariableDefinitions\"],\n \"inMemoryCache.maybeBroadcastWatch\":\n defaultCacheSizes[\"inMemoryCache.maybeBroadcastWatch\"],\n \"inMemoryCache.executeSelectionSet\":\n defaultCacheSizes[\"inMemoryCache.executeSelectionSet\"],\n \"inMemoryCache.executeSubSelectedArray\":\n defaultCacheSizes[\"inMemoryCache.executeSubSelectedArray\"],\n };\n return Object.fromEntries(\n Object.entries(defaults).map(([k, v]) => [\n k,\n cacheSizes[k as keyof CacheSizes] || v,\n ])\n );\n}\n\nfunction _getApolloClientMemoryInternals(this: ApolloClient<any>) {\n if (!__DEV__) throw new Error(\"only supported in development mode\");\n\n return {\n limits: getCurrentCacheSizes(),\n sizes: {\n print: globalCaches.print?.(),\n parser: globalCaches.parser?.(),\n canonicalStringify: globalCaches.canonicalStringify?.(),\n links: linkInfo(this.link),\n queryManager: {\n getDocumentInfo: this[\"queryManager\"][\"transformCache\"].size,\n documentTransforms: transformInfo(\n this[\"queryManager\"].documentTransform\n ),\n },\n ...(this.cache.getMemoryInternals?.() as Partial<\n ReturnType<typeof _getApolloCacheMemoryInternals>\n > &\n Partial<ReturnType<typeof _getInMemoryCacheMemoryInternals>>),\n },\n };\n}\n\nfunction _getApolloCacheMemoryInternals(this: ApolloCache<any>) {\n return {\n cache: {\n fragmentQueryDocuments: getWrapperInformation(this[\"getFragmentDoc\"]),\n },\n };\n}\n\nfunction _getInMemoryCacheMemoryInternals(this: InMemoryCache) {\n const fragments = this.config.fragments as\n | undefined\n | {\n findFragmentSpreads?: Function;\n transform?: Function;\n lookup?: Function;\n };\n\n return {\n ..._getApolloCacheMemoryInternals.apply(this as any),\n addTypenameDocumentTransform: transformInfo(this[\"addTypenameTransform\"]),\n inMemoryCache: {\n executeSelectionSet: getWrapperInformation(\n this[\"storeReader\"][\"executeSelectionSet\"]\n ),\n executeSubSelectedArray: getWrapperInformation(\n this[\"storeReader\"][\"executeSubSelectedArray\"]\n ),\n maybeBroadcastWatch: getWrapperInformation(this[\"maybeBroadcastWatch\"]),\n },\n fragmentRegistry: {\n findFragmentSpreads: getWrapperInformation(\n fragments?.findFragmentSpreads\n ),\n lookup: getWrapperInformation(fragments?.lookup),\n transform: getWrapperInformation(fragments?.transform),\n },\n };\n}\n\nfunction isWrapper(f?: Function): f is OptimisticWrapperFunction<any, any> {\n return !!f && \"dirtyKey\" in f;\n}\n\nfunction getWrapperInformation(f?: Function) {\n return isWrapper(f) ? f.size : undefined;\n}\n\nfunction isDefined<T>(value: T | undefined | null): value is T {\n return value != null;\n}\n\nfunction transformInfo(transform?: DocumentTransform) {\n return recurseTransformInfo(transform).map((cache) => ({ cache }));\n}\n\nfunction recurseTransformInfo(transform?: DocumentTransform): number[] {\n return transform ?\n [\n getWrapperInformation(transform?.[\"performWork\"]),\n ...recurseTransformInfo(transform?.[\"left\"]),\n ...recurseTransformInfo(transform?.[\"right\"]),\n ].filter(isDefined)\n : [];\n}\n\nfunction linkInfo(link?: ApolloLink): unknown[] {\n return link ?\n [\n link?.getMemoryInternals?.(),\n ...linkInfo(link?.left),\n ...linkInfo(link?.right),\n ].filter(isDefined)\n : [];\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utilities/caching/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAE3E,OAAO,EAAE,UAAU,EAAqB,MAAM,YAAY,CAAC","sourcesContent":["export { AutoCleanedStrongCache, AutoCleanedWeakCache } from \"./caches.js\";\nexport type { CacheSizes } from \"./sizes.js\";\nexport { cacheSizes, defaultCacheSizes } from \"./sizes.js\";\n"]}
|
|
@@ -0,0 +1,261 @@
|
|
|
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
|
+
* Note that these caches are all derivative and if an item is cache-collected,
|
|
10
|
+
* it's not the end of the world - the cached item will just be recalculated.
|
|
11
|
+
*
|
|
12
|
+
* As a result, these cache sizes should not be chosen to hold every value ever
|
|
13
|
+
* encountered, but rather to hold a reasonable number of values that can be
|
|
14
|
+
* assumed to be on the screen at any given time.
|
|
15
|
+
*
|
|
16
|
+
* We assume a "base value" of 1000 here, which is already very generous.
|
|
17
|
+
* In most applications, it will be very unlikely that 1000 different queries
|
|
18
|
+
* are on screen at the same time.
|
|
19
|
+
*/
|
|
20
|
+
export interface CacheSizes {
|
|
21
|
+
/**
|
|
22
|
+
* Cache size for the [`print`](../../utilities/graphql/print.ts) function.
|
|
23
|
+
*
|
|
24
|
+
* @defaultValue
|
|
25
|
+
* Defaults to `2000`.
|
|
26
|
+
*
|
|
27
|
+
* @remarks
|
|
28
|
+
* This method is called from the `QueryManager` and various `Link`s,
|
|
29
|
+
* always with the "serverQuery", so the server-facing part of a transformed
|
|
30
|
+
* DocumentNode.
|
|
31
|
+
*/
|
|
32
|
+
print: number;
|
|
33
|
+
/**
|
|
34
|
+
* Cache size for the [`parser`](../../react/parser/index.ts) function.
|
|
35
|
+
*
|
|
36
|
+
* @defaultValue
|
|
37
|
+
* Defaults to `1000`.
|
|
38
|
+
*
|
|
39
|
+
* @remarks
|
|
40
|
+
* This function is used directly in HOCs, and nowadays mainly accessed by
|
|
41
|
+
* calling `verifyDocumentType` from various hooks.
|
|
42
|
+
* It is called with a user-provided DocumentNode.
|
|
43
|
+
*/
|
|
44
|
+
parser: number;
|
|
45
|
+
/**
|
|
46
|
+
* Cache size for the `performWork` method of each [`DocumentTransform`](../../utilities/graphql/DocumentTransform.ts).
|
|
47
|
+
*
|
|
48
|
+
* @defaultValue
|
|
49
|
+
* Defaults to `2000`.
|
|
50
|
+
*
|
|
51
|
+
* @remarks
|
|
52
|
+
* This method is called from `transformDocument`, which is called from
|
|
53
|
+
* `QueryManager` with a user-provided DocumentNode.
|
|
54
|
+
* It is also called with already-transformed DocumentNodes, assuming the
|
|
55
|
+
* user provided additional transforms.
|
|
56
|
+
*
|
|
57
|
+
* The cache size here should be chosen with other DocumentTransforms in mind.
|
|
58
|
+
* For example, if there was a DocumentTransform that would take `n` DocumentNodes,
|
|
59
|
+
* and returned a differently-transformed DocumentNode depending if the app is
|
|
60
|
+
* online or offline, then we assume that the cache returns `2*n` documents.
|
|
61
|
+
*
|
|
62
|
+
* No user-provided DocumentNode will actually be "the last one", as we run the
|
|
63
|
+
* `defaultDocumentTransform` before *and* after the user-provided transforms.
|
|
64
|
+
*
|
|
65
|
+
* So if we assume that the user-provided transforms receive `n` documents and
|
|
66
|
+
* return `n` documents, the cache size should be `2*n`.
|
|
67
|
+
*
|
|
68
|
+
* If we assume that the user-provided transforms receive `n` documents and
|
|
69
|
+
* returns `2*n` documents, the cache size should be `3*n`.
|
|
70
|
+
*
|
|
71
|
+
* This size should also then be used in every other cache that mentions that
|
|
72
|
+
* it operates on a "transformed" DocumentNode.
|
|
73
|
+
*/
|
|
74
|
+
"documentTransform.cache": number;
|
|
75
|
+
/**
|
|
76
|
+
* Cache size for the `transformCache` used in the `getDocumentInfo` method of
|
|
77
|
+
* [`QueryManager`](../../core/QueryManager.ts).
|
|
78
|
+
*
|
|
79
|
+
* @defaultValue
|
|
80
|
+
* Defaults to `2000`.
|
|
81
|
+
*
|
|
82
|
+
* @remarks
|
|
83
|
+
* `getDocumentInfo` is called throughout the `QueryManager` with transformed
|
|
84
|
+
* DocumentNodes.
|
|
85
|
+
*/
|
|
86
|
+
"queryManager.getDocumentInfo": number;
|
|
87
|
+
/**
|
|
88
|
+
* Cache size for the `hashesByQuery` cache in the [`PersistedQueryLink`](../../link/persisted-queries/index.ts).
|
|
89
|
+
*
|
|
90
|
+
* @defaultValue
|
|
91
|
+
* Defaults to `2000`.
|
|
92
|
+
*
|
|
93
|
+
* @remarks
|
|
94
|
+
* This cache is used to cache the hashes of persisted queries. It is working with
|
|
95
|
+
* transformed DocumentNodes.
|
|
96
|
+
*/
|
|
97
|
+
"PersistedQueryLink.persistedQueryHashes": number;
|
|
98
|
+
/**
|
|
99
|
+
* Cache for the `sortingMap` used by [`canonicalStringify`](../../utilities/common/canonicalStringify.ts).
|
|
100
|
+
*
|
|
101
|
+
* @defaultValue
|
|
102
|
+
* Defaults to `1000`.
|
|
103
|
+
*
|
|
104
|
+
* @remarks
|
|
105
|
+
* This cache contains the sorted keys of objects that are stringified by
|
|
106
|
+
* `canonicalStringify`.
|
|
107
|
+
* It uses the stringified unsorted keys of objects as keys.
|
|
108
|
+
* The cache will not grow beyond the size of different object **shapes**
|
|
109
|
+
* encountered in an application, no matter how much actual data gets stringified.
|
|
110
|
+
*/
|
|
111
|
+
canonicalStringify: number;
|
|
112
|
+
/**
|
|
113
|
+
* Cache size for the `transform` method of [`FragmentRegistry`](../../cache/inmemory/fragmentRegistry.ts).
|
|
114
|
+
*
|
|
115
|
+
* @defaultValue
|
|
116
|
+
* Defaults to `2000`.
|
|
117
|
+
*
|
|
118
|
+
* @remarks
|
|
119
|
+
* This function is called as part of the `defaultDocumentTransform` which will be called with
|
|
120
|
+
* user-provided and already-transformed DocumentNodes.
|
|
121
|
+
*
|
|
122
|
+
*/
|
|
123
|
+
"fragmentRegistry.transform": number;
|
|
124
|
+
/**
|
|
125
|
+
* Cache size for the `lookup` method of [`FragmentRegistry`](../../cache/inmemory/fragmentRegistry.ts).
|
|
126
|
+
*
|
|
127
|
+
* @defaultValue
|
|
128
|
+
* Defaults to `1000`.
|
|
129
|
+
*
|
|
130
|
+
* @remarks
|
|
131
|
+
* This function is called with fragment names in the form of a string.
|
|
132
|
+
*
|
|
133
|
+
* Note:
|
|
134
|
+
* This function is a dependency of `transform`, so having a too small cache size here
|
|
135
|
+
* might involuntarily invalidate values in the `transform` cache.
|
|
136
|
+
*/
|
|
137
|
+
"fragmentRegistry.lookup": number;
|
|
138
|
+
/**
|
|
139
|
+
* Cache size for the `findFragmentSpreads` method of [`FragmentRegistry`](../../cache/inmemory/fragmentRegistry.ts).
|
|
140
|
+
*
|
|
141
|
+
* @defaultValue
|
|
142
|
+
* Defaults to `4000`.
|
|
143
|
+
*
|
|
144
|
+
* @remarks
|
|
145
|
+
* This function is called with transformed DocumentNodes, as well as recursively
|
|
146
|
+
* with every fragment spread referenced within that, or a fragment referenced by a
|
|
147
|
+
* fragment spread.
|
|
148
|
+
*
|
|
149
|
+
* Note:
|
|
150
|
+
* This function is a dependency of `transform`, so having a too small cache size here
|
|
151
|
+
* might involuntarily invalidate values in the `transform` cache.
|
|
152
|
+
*/
|
|
153
|
+
"fragmentRegistry.findFragmentSpreads": number;
|
|
154
|
+
/**
|
|
155
|
+
* Cache size for the `getFragmentDoc` method of [`ApolloCache`](../../cache/core/cache.ts).
|
|
156
|
+
*
|
|
157
|
+
* @defaultValue
|
|
158
|
+
* Defaults to `1000`.
|
|
159
|
+
*
|
|
160
|
+
* @remarks
|
|
161
|
+
* This function is called from `readFragment` with user-provided fragment definitions.
|
|
162
|
+
*/
|
|
163
|
+
"cache.fragmentQueryDocuments": number;
|
|
164
|
+
/**
|
|
165
|
+
* Cache size for the `getVariableDefinitions` function in [`removeTypenameFromVariables`](../../link/remove-typename/removeTypenameFromVariables.ts).
|
|
166
|
+
*
|
|
167
|
+
* @defaultValue
|
|
168
|
+
* Defaults to `2000`.
|
|
169
|
+
*
|
|
170
|
+
* @remarks
|
|
171
|
+
* This function is called in a link with transformed DocumentNodes.
|
|
172
|
+
*/
|
|
173
|
+
"removeTypenameFromVariables.getVariableDefinitions": number;
|
|
174
|
+
/**
|
|
175
|
+
* Cache size for the `maybeBroadcastWatch` method on [`InMemoryCache`](../../cache/inmemory/inMemoryCache.ts).
|
|
176
|
+
*
|
|
177
|
+
* `maybeBroadcastWatch` will be set to the `resultCacheMaxSize` option and
|
|
178
|
+
* will fall back to this configuration value if the option is not set.
|
|
179
|
+
*
|
|
180
|
+
* @defaultValue
|
|
181
|
+
* Defaults to `5000`.
|
|
182
|
+
*
|
|
183
|
+
* @remarks
|
|
184
|
+
* This method is used for dependency tracking in the `InMemoryCache` and
|
|
185
|
+
* prevents from unnecessary re-renders.
|
|
186
|
+
* It is recommended to keep this value significantly higher than the number of
|
|
187
|
+
* possible subscribers you will have active at the same time in your application
|
|
188
|
+
* at any time.
|
|
189
|
+
*/
|
|
190
|
+
"inMemoryCache.maybeBroadcastWatch": number;
|
|
191
|
+
/**
|
|
192
|
+
* Cache size for the `executeSelectionSet` method on [`StoreReader`](../../cache/inmemory/readFromStore.ts).
|
|
193
|
+
*
|
|
194
|
+
* `executeSelectionSet` will be set to the `resultCacheMaxSize` option and
|
|
195
|
+
* will fall back to this configuration value if the option is not set.
|
|
196
|
+
*
|
|
197
|
+
* @defaultValue
|
|
198
|
+
* Defaults to `10000`.
|
|
199
|
+
*
|
|
200
|
+
* @remarks
|
|
201
|
+
* Every object that is read from the cache will be cached here, so it is
|
|
202
|
+
* recommended to set this to a high value.
|
|
203
|
+
*/
|
|
204
|
+
"inMemoryCache.executeSelectionSet": number;
|
|
205
|
+
/**
|
|
206
|
+
* Cache size for the `executeSubSelectedArray` method on [`StoreReader`](../../cache/inmemory/readFromStore.ts).
|
|
207
|
+
*
|
|
208
|
+
* `executeSubSelectedArray` will be set to the `resultCacheMaxSize` option and
|
|
209
|
+
* will fall back to this configuration value if the option is not set.
|
|
210
|
+
*
|
|
211
|
+
* @defaultValue
|
|
212
|
+
* Defaults to `5000`.
|
|
213
|
+
*
|
|
214
|
+
* @remarks
|
|
215
|
+
* Every array that is read from the cache will be cached here, so it is
|
|
216
|
+
* recommended to set this to a high value.
|
|
217
|
+
*/
|
|
218
|
+
"inMemoryCache.executeSubSelectedArray": number;
|
|
219
|
+
}
|
|
220
|
+
declare const cacheSizeSymbol: unique symbol;
|
|
221
|
+
/**
|
|
222
|
+
*
|
|
223
|
+
* The global cache size configuration for Apollo Client.
|
|
224
|
+
*
|
|
225
|
+
* @remarks
|
|
226
|
+
*
|
|
227
|
+
* You can directly modify this object, but any modification will
|
|
228
|
+
* only have an effect on caches that are created after the modification.
|
|
229
|
+
*
|
|
230
|
+
* So for global caches, such as `parser`, `canonicalStringify` and `print`,
|
|
231
|
+
* you might need to call `.reset` on them, which will essentially re-create them.
|
|
232
|
+
*
|
|
233
|
+
* Alternatively, you can set `globalThis[Symbol.for("apollo.cacheSize")]` before
|
|
234
|
+
* you load the Apollo Client package:
|
|
235
|
+
*
|
|
236
|
+
* @example
|
|
237
|
+
* ```ts
|
|
238
|
+
* globalThis[Symbol.for("apollo.cacheSize")] = {
|
|
239
|
+
* parser: 100
|
|
240
|
+
* } satisfies Partial<CacheSizes> // the `satisfies` is optional if using TypeScript
|
|
241
|
+
* ```
|
|
242
|
+
*/
|
|
243
|
+
export declare const cacheSizes: Partial<CacheSizes>;
|
|
244
|
+
export declare const enum defaultCacheSizes {
|
|
245
|
+
parser = 1000,
|
|
246
|
+
canonicalStringify = 1000,
|
|
247
|
+
print = 2000,
|
|
248
|
+
"documentTransform.cache" = 2000,
|
|
249
|
+
"queryManager.getDocumentInfo" = 2000,
|
|
250
|
+
"PersistedQueryLink.persistedQueryHashes" = 2000,
|
|
251
|
+
"fragmentRegistry.transform" = 2000,
|
|
252
|
+
"fragmentRegistry.lookup" = 1000,
|
|
253
|
+
"fragmentRegistry.findFragmentSpreads" = 4000,
|
|
254
|
+
"cache.fragmentQueryDocuments" = 1000,
|
|
255
|
+
"removeTypenameFromVariables.getVariableDefinitions" = 2000,
|
|
256
|
+
"inMemoryCache.maybeBroadcastWatch" = 5000,
|
|
257
|
+
"inMemoryCache.executeSelectionSet" = 10000,
|
|
258
|
+
"inMemoryCache.executeSubSelectedArray" = 5000
|
|
259
|
+
}
|
|
260
|
+
export {};
|
|
261
|
+
//# 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;AA+N7C,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 * Note that these caches are all derivative and if an item is cache-collected,\n * it's not the end of the world - the cached item will just be recalculated.\n *\n * As a result, these cache sizes should not be chosen to hold every value ever\n * encountered, but rather to hold a reasonable number of values that can be\n * assumed to be on the screen at any given time.\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`](../../utilities/graphql/print.ts) function.\n *\n * @defaultValue\n * Defaults to `2000`.\n *\n * @remarks\n * This method is called from the `QueryManager` and various `Link`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`](../../react/parser/index.ts) function.\n *\n * @defaultValue\n * Defaults to `1000`.\n *\n * @remarks\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 `performWork` method of each [`DocumentTransform`](../../utilities/graphql/DocumentTransform.ts).\n *\n * @defaultValue\n * Defaults to `2000`.\n *\n * @remarks\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 * The cache size here should be chosen with other DocumentTransforms in mind.\n * For example, if there was a DocumentTransform that would take `n` DocumentNodes,\n * and returned a differently-transformed DocumentNode depending if the app is\n * online or offline, then we assume that the cache returns `2*n` documents.\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 *\n * So 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 user-provided transforms receive `n` documents and\n * returns `2*n` documents, the cache size should be `3*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 \"documentTransform.cache\": number;\n /**\n * Cache size for the `transformCache` used in the `getDocumentInfo` method of\n * [`QueryManager`](../../core/QueryManager.ts).\n *\n * @defaultValue\n * Defaults to `2000`.\n *\n * @remarks\n * `getDocumentInfo` is called throughout the `QueryManager` with transformed\n * DocumentNodes.\n */\n \"queryManager.getDocumentInfo\": number;\n /**\n * Cache size for the `hashesByQuery` cache in the [`PersistedQueryLink`](../../link/persisted-queries/index.ts).\n *\n * @defaultValue\n * Defaults to `2000`.\n *\n * @remarks\n * This cache is used to cache the hashes of persisted queries. It is working with\n * transformed DocumentNodes.\n */\n \"PersistedQueryLink.persistedQueryHashes\": number;\n /**\n * Cache for the `sortingMap` used by [`canonicalStringify`](../../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 canonicalStringify: number;\n /**\n * Cache size for the `transform` method of [`FragmentRegistry`](../../cache/inmemory/fragmentRegistry.ts).\n *\n * @defaultValue\n * Defaults to `2000`.\n *\n * @remarks\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 * Cache size for the `lookup` method of [`FragmentRegistry`](../../cache/inmemory/fragmentRegistry.ts).\n *\n * @defaultValue\n * Defaults to `1000`.\n *\n * @remarks\n * This function is called with fragment names in the form of a string.\n *\n * Note:\n * This function is a dependency of `transform`, so having a too small cache size here\n * might involuntarily invalidate values in the `transform` cache.\n */\n \"fragmentRegistry.lookup\": number;\n /**\n * Cache size for the `findFragmentSpreads` method of [`FragmentRegistry`](../../cache/inmemory/fragmentRegistry.ts).\n *\n * @defaultValue\n * Defaults to `4000`.\n *\n * @remarks\n * This function is called with transformed DocumentNodes, as well as recursively\n * with every fragment spread referenced within that, or a fragment referenced by a\n * fragment spread.\n *\n * Note:\n * This function is a dependency of `transform`, so having a too small 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`](../../cache/core/cache.ts).\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 size for the `getVariableDefinitions` function in [`removeTypenameFromVariables`](../../link/remove-typename/removeTypenameFromVariables.ts).\n *\n * @defaultValue\n * Defaults to `2000`.\n *\n * @remarks\n * This function is called in a link with transformed DocumentNodes.\n */\n \"removeTypenameFromVariables.getVariableDefinitions\": number;\n /**\n * Cache size for the `maybeBroadcastWatch` method on [`InMemoryCache`](../../cache/inmemory/inMemoryCache.ts).\n *\n * `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`](../../cache/inmemory/readFromStore.ts).\n *\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`](../../cache/inmemory/readFromStore.ts).\n *\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"]}
|