@apollo/client 4.0.0-alpha.0 → 4.0.0-alpha.10
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/afraid-moons-arrive.md +5 -0
- package/.changeset/beige-mirrors-talk.md +15 -0
- package/.changeset/clean-sheep-hide.md +6 -0
- package/.changeset/cool-bikes-shake.md +12 -0
- package/.changeset/cool-kiwis-hunt.md +15 -0
- package/.changeset/cuddly-spiders-tie.md +5 -0
- package/.changeset/dirty-eagles-poke.md +5 -0
- package/.changeset/early-eggs-develop.md +22 -0
- package/.changeset/eighty-squids-fix.md +15 -0
- package/.changeset/eleven-kangaroos-jump.md +5 -0
- package/.changeset/forty-shrimps-fry.md +5 -0
- package/.changeset/forty-tomatoes-punch.md +5 -0
- package/.changeset/four-countries-clean.md +24 -0
- package/.changeset/four-ghosts-watch.md +5 -0
- package/.changeset/funny-jeans-invent.md +16 -0
- package/.changeset/funny-terms-deny.md +5 -0
- package/.changeset/fuzzy-tips-sit.md +5 -0
- package/.changeset/gentle-badgers-train.md +5 -0
- package/.changeset/giant-apes-thank.md +5 -0
- package/.changeset/giant-bags-share.md +5 -0
- package/.changeset/gorgeous-chefs-tap.md +5 -0
- package/.changeset/great-roses-jog.md +15 -0
- package/.changeset/grumpy-vans-type.md +5 -0
- package/.changeset/hip-vans-act.md +5 -0
- package/.changeset/hungry-bikes-cough.md +5 -0
- package/.changeset/itchy-chefs-run.md +23 -0
- package/.changeset/khaki-keys-deliver.md +5 -0
- package/.changeset/khaki-spies-work.md +11 -0
- package/.changeset/large-plants-know.md +5 -0
- package/.changeset/light-apes-rescue.md +5 -0
- package/.changeset/little-spoons-kick.md +7 -0
- package/.changeset/loud-cows-raise.md +7 -0
- package/.changeset/many-buses-allow.md +5 -0
- package/.changeset/mean-lizards-think.md +5 -0
- package/.changeset/nervous-fireants-bow.md +5 -0
- package/.changeset/nervous-goats-allow.md +5 -0
- package/.changeset/nice-dots-matter.md +5 -0
- package/.changeset/ninety-bags-bake.md +17 -0
- package/.changeset/odd-chicken-hide.md +17 -0
- package/.changeset/odd-lemons-relax.md +5 -0
- package/.changeset/perfect-vans-give.md +7 -0
- package/.changeset/poor-eels-punch.md +5 -0
- package/.changeset/pre.json +67 -0
- package/.changeset/purple-bears-flash.md +5 -0
- package/.changeset/rare-houses-prove.md +5 -0
- package/.changeset/real-teachers-peel.md +5 -0
- package/.changeset/serious-moons-juggle.md +5 -0
- package/.changeset/seven-dragons-repair.md +14 -0
- package/.changeset/shaggy-pugs-add.md +52 -0
- package/.changeset/short-months-complain.md +5 -0
- package/.changeset/slimy-chicken-melt.md +5 -0
- package/.changeset/slimy-maps-press.md +5 -0
- package/.changeset/small-buttons-rhyme.md +5 -0
- package/.changeset/swift-rivers-share.md +13 -0
- package/.changeset/tall-bikes-develop.md +5 -0
- package/.changeset/tame-doors-shop.md +14 -0
- package/.changeset/tame-points-work.md +11 -0
- package/.changeset/tender-swans-flash.md +16 -0
- package/.changeset/thick-books-grin.md +5 -0
- package/.changeset/thin-peas-hear.md +16 -0
- package/.changeset/tidy-pandas-punch.md +5 -0
- package/.changeset/tough-rockets-allow.md +5 -0
- package/.changeset/tricky-tables-shave.md +5 -0
- package/.changeset/unlucky-kiwis-sell.md +5 -0
- package/.changeset/warm-ties-sit.md +7 -0
- package/.changeset/wicked-forks-double.md +33 -0
- package/.changeset/young-phones-fold.md +5 -0
- package/.changeset/young-snails-grin.md +5 -0
- package/CHANGELOG.md +507 -0
- package/__cjs/cache/core/cache.cjs +3 -3
- package/__cjs/cache/core/cache.cjs.map +1 -1
- package/__cjs/cache/core/cache.d.cts +19 -19
- package/__cjs/cache/core/types/Cache.cjs.map +1 -1
- package/__cjs/cache/core/types/Cache.d.cts +9 -16
- package/__cjs/cache/core/types/DataProxy.d.cts +8 -23
- package/__cjs/cache/core/types/common.cjs +1 -0
- package/__cjs/cache/core/types/common.cjs.map +1 -1
- package/__cjs/cache/index.cjs +4 -4
- package/__cjs/cache/index.cjs.map +1 -1
- package/__cjs/cache/index.d.cts +3 -3
- package/__cjs/cache/inmemory/entityStore.cjs +6 -5
- package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/entityStore.d.cts +3 -2
- package/__cjs/cache/inmemory/fragmentRegistry.cjs +3 -3
- package/__cjs/cache/inmemory/fragmentRegistry.cjs.map +1 -1
- package/__cjs/cache/inmemory/helpers.cjs +0 -8
- package/__cjs/cache/inmemory/helpers.cjs.map +1 -1
- package/__cjs/cache/inmemory/helpers.d.cts +3 -4
- package/__cjs/cache/inmemory/inMemoryCache.cjs +6 -18
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.d.cts +9 -11
- package/__cjs/cache/inmemory/policies.cjs +5 -5
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/policies.d.cts +1 -1
- package/__cjs/cache/inmemory/reactiveVars.cjs.map +1 -1
- package/__cjs/cache/inmemory/reactiveVars.d.cts +7 -7
- package/__cjs/cache/inmemory/readFromStore.cjs +12 -54
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/readFromStore.d.cts +1 -6
- package/__cjs/cache/inmemory/types.d.cts +3 -17
- package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
- package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/writeToStore.d.cts +2 -2
- package/__cjs/config/jest/areCombinedGraphQLErrorsEqual.cjs +6 -4
- package/__cjs/config/jest/areCombinedGraphQLErrorsEqual.cjs.map +1 -1
- package/__cjs/config/jest/areCombinedProtocolErrorsEqual.cjs +3 -3
- package/__cjs/config/jest/areCombinedProtocolErrorsEqual.cjs.map +1 -1
- package/__cjs/config/jest/areMissingFieldErrorsEqual.cjs +2 -3
- package/__cjs/config/jest/areMissingFieldErrorsEqual.cjs.map +1 -1
- package/__cjs/config/jest/areServerErrorsEqual.cjs +22 -0
- package/__cjs/config/jest/areServerErrorsEqual.cjs.map +1 -0
- package/__cjs/config/jest/areServerErrorsEqual.d.cts +3 -0
- package/__cjs/config/jest/resolver.cjs +11 -0
- package/__cjs/config/jest/resolver.cjs.map +1 -1
- package/__cjs/config/jest/setup.cjs +18 -1
- package/__cjs/config/jest/setup.cjs.map +1 -1
- package/__cjs/core/ApolloClient.cjs +36 -19
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +36 -26
- package/__cjs/core/LocalState.cjs +2 -2
- package/__cjs/core/LocalState.cjs.map +1 -1
- package/__cjs/core/LocalState.d.cts +8 -8
- package/__cjs/core/ObservableQuery.cjs +268 -104
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +156 -17
- package/__cjs/core/QueryInfo.cjs +12 -86
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +2 -11
- package/__cjs/core/QueryManager.cjs +148 -104
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +45 -24
- package/__cjs/core/index.cjs +42 -21
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +12 -11
- package/__cjs/core/types.d.cts +60 -7
- package/__cjs/core/watchQueryOptions.d.cts +32 -119
- package/__cjs/errors/CombinedGraphQLErrors.cjs +30 -11
- package/__cjs/errors/CombinedGraphQLErrors.cjs.map +1 -1
- package/__cjs/errors/CombinedGraphQLErrors.d.cts +21 -2
- package/__cjs/errors/CombinedProtocolErrors.cjs +13 -6
- package/__cjs/errors/CombinedProtocolErrors.cjs.map +1 -1
- package/__cjs/errors/CombinedProtocolErrors.d.cts +9 -0
- package/__cjs/errors/LinkError.cjs +20 -0
- package/__cjs/errors/LinkError.cjs.map +1 -0
- package/__cjs/errors/LinkError.d.cts +14 -0
- package/__cjs/errors/ServerError.cjs +6 -0
- package/__cjs/errors/ServerError.cjs.map +1 -1
- package/__cjs/errors/ServerError.d.cts +2 -0
- package/__cjs/errors/ServerParseError.cjs +6 -0
- package/__cjs/errors/ServerParseError.cjs.map +1 -1
- package/__cjs/errors/ServerParseError.d.cts +2 -0
- package/__cjs/errors/UnconventionalError.cjs +6 -0
- package/__cjs/errors/UnconventionalError.cjs.map +1 -1
- package/__cjs/errors/UnconventionalError.d.cts +2 -0
- package/__cjs/errors/index.cjs +19 -4
- package/__cjs/errors/index.cjs.map +1 -1
- package/__cjs/errors/index.d.cts +2 -3
- package/__cjs/errors/isErrorLike.cjs +12 -0
- package/__cjs/errors/isErrorLike.cjs.map +1 -0
- package/__cjs/errors/isErrorLike.d.cts +3 -0
- package/__cjs/errors/utils.cjs +18 -0
- package/__cjs/errors/utils.cjs.map +1 -0
- package/__cjs/errors/utils.d.cts +3 -0
- package/__cjs/invariantErrorCodes.cjs +121 -122
- package/__cjs/link/batch/batching.cjs.map +1 -1
- package/__cjs/link/batch/index.cjs +4 -2
- package/__cjs/link/batch/index.cjs.map +1 -1
- package/__cjs/link/batch/index.d.cts +2 -1
- package/__cjs/link/batch-http/index.cjs +3 -2
- package/__cjs/link/batch-http/index.cjs.map +1 -1
- package/__cjs/link/batch-http/index.d.cts +1 -1
- package/__cjs/link/context/index.cjs.map +1 -1
- package/__cjs/link/context/index.d.cts +1 -1
- package/__cjs/link/core/ApolloLink.cjs +2 -20
- package/__cjs/link/core/ApolloLink.cjs.map +1 -1
- package/__cjs/link/core/ApolloLink.d.cts +1 -3
- package/__cjs/link/core/index.cjs.map +1 -1
- package/__cjs/link/core/index.d.cts +1 -1
- package/__cjs/link/core/types.d.cts +1 -1
- package/__cjs/link/error/index.cjs +13 -28
- package/__cjs/link/error/index.cjs.map +1 -1
- package/__cjs/link/error/index.d.cts +4 -15
- package/__cjs/link/http/checkFetcher.cjs +1 -1
- package/__cjs/link/http/createHttpLink.cjs +1 -1
- package/__cjs/link/http/createHttpLink.d.cts +2 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs +4 -3
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs.map +1 -1
- package/__cjs/link/http/serializeFetchParameter.cjs +1 -1
- package/__cjs/link/persisted-queries/index.cjs +3 -3
- package/__cjs/link/persisted-queries/index.cjs.map +1 -1
- package/__cjs/link/persisted-queries/index.d.cts +14 -3
- package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs +1 -1
- package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs.map +1 -1
- package/__cjs/link/remove-typename/removeTypenameFromVariables.d.cts +10 -1
- package/__cjs/link/retry/index.cjs +3 -2
- package/__cjs/link/retry/index.cjs.map +1 -1
- package/__cjs/link/retry/index.d.cts +1 -1
- package/__cjs/link/subscriptions/index.cjs +3 -1
- package/__cjs/link/subscriptions/index.cjs.map +1 -1
- package/__cjs/link/utils/validateOperation.cjs +1 -1
- package/__cjs/masking/maskDefinition.cjs +2 -2
- package/__cjs/masking/maskDefinition.cjs.map +1 -1
- package/__cjs/masking/maskDefinition.d.cts +1 -1
- package/__cjs/masking/maskFragment.cjs +2 -2
- package/__cjs/masking/maskFragment.cjs.map +1 -1
- package/__cjs/masking/maskFragment.d.cts +2 -2
- package/__cjs/masking/maskOperation.cjs +1 -1
- package/__cjs/masking/maskOperation.cjs.map +1 -1
- package/__cjs/masking/maskOperation.d.cts +2 -2
- package/__cjs/masking/utils.cjs +1 -1
- package/__cjs/react/context/ApolloConsumer.cjs +2 -2
- package/__cjs/react/context/ApolloConsumer.cjs.map +1 -1
- package/__cjs/react/context/ApolloConsumer.d.cts +7 -4
- package/__cjs/react/context/ApolloContext.cjs +2 -2
- package/__cjs/react/context/ApolloContext.cjs.map +1 -1
- package/__cjs/react/context/ApolloContext.d.cts +4 -4
- package/__cjs/react/context/ApolloProvider.cjs +2 -2
- package/__cjs/react/context/ApolloProvider.cjs.map +1 -1
- package/__cjs/react/context/ApolloProvider.d.cts +7 -5
- package/__cjs/react/hooks/internal/__use.cjs +1 -1
- package/__cjs/react/hooks/internal/__use.cjs.map +1 -1
- package/__cjs/react/hooks/internal/__use.d.cts +3 -1
- package/__cjs/react/hooks/internal/useDeepMemo.cjs +3 -1
- package/__cjs/react/hooks/internal/useDeepMemo.cjs.map +1 -1
- package/__cjs/react/hooks/internal/useIsomorphicLayoutEffect.cjs +1 -1
- package/__cjs/react/hooks/internal/useIsomorphicLayoutEffect.cjs.map +1 -1
- package/__cjs/react/hooks/internal/useIsomorphicLayoutEffect.d.cts +2 -2
- package/__cjs/react/hooks/internal/useRenderGuard.cjs +1 -1
- package/__cjs/react/hooks/internal/useRenderGuard.cjs.map +1 -1
- package/__cjs/react/hooks/internal/validateSuspenseHookOptions.cjs +28 -0
- package/__cjs/react/hooks/internal/validateSuspenseHookOptions.cjs.map +1 -0
- package/__cjs/react/hooks/internal/validateSuspenseHookOptions.d.cts +3 -0
- package/__cjs/react/hooks/internal/wrapHook.cjs +26 -5
- package/__cjs/react/hooks/internal/wrapHook.cjs.map +1 -1
- package/__cjs/react/hooks/internal/wrapHook.d.cts +7 -5
- package/__cjs/react/hooks/useApolloClient.cjs +3 -3
- package/__cjs/react/hooks/useApolloClient.cjs.map +1 -1
- package/__cjs/react/hooks/useApolloClient.d.cts +2 -2
- package/__cjs/react/hooks/useBackgroundQuery.cjs +3 -3
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +143 -46
- package/__cjs/react/hooks/useFragment.cjs +1 -1
- package/__cjs/react/hooks/useFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useFragment.d.cts +51 -26
- package/__cjs/react/hooks/useLazyQuery.cjs +33 -32
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +278 -276
- package/__cjs/react/hooks/useLoadableQuery.cjs +22 -3
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +106 -34
- package/__cjs/react/hooks/useMutation.cjs +15 -23
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +198 -4
- package/__cjs/react/hooks/useQuery.cjs +88 -207
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +274 -4
- package/__cjs/react/hooks/useQueryRefHandlers.cjs +1 -1
- package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
- package/__cjs/react/hooks/useQueryRefHandlers.d.cts +23 -22
- package/__cjs/react/hooks/useReactiveVar.cjs +1 -1
- package/__cjs/react/hooks/useReactiveVar.cjs.map +1 -1
- package/__cjs/react/hooks/useReactiveVar.d.cts +1 -1
- package/__cjs/react/hooks/useReadQuery.cjs +1 -1
- package/__cjs/react/hooks/useReadQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useReadQuery.d.cts +27 -25
- package/__cjs/react/hooks/useSubscription.cjs +10 -60
- package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
- package/__cjs/react/hooks/useSubscription.d.cts +94 -3
- package/__cjs/react/hooks/useSuspenseFragment.cjs +1 -1
- package/__cjs/react/hooks/useSuspenseFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseFragment.d.cts +40 -38
- package/__cjs/react/hooks/useSuspenseQuery.cjs +8 -33
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +199 -38
- package/__cjs/react/hooks/useSyncExternalStore.cjs +2 -2
- package/__cjs/react/hooks/useSyncExternalStore.cjs.map +1 -1
- package/__cjs/react/index.cjs +35 -11
- package/__cjs/react/index.cjs.map +1 -1
- package/__cjs/react/index.d.cts +21 -6
- package/__cjs/react/index.react-server.cjs +48 -0
- package/__cjs/react/index.react-server.cjs.map +1 -0
- package/__cjs/react/index.react-server.d.cts +19 -0
- package/__cjs/react/internal/cache/FragmentReference.cjs.map +1 -1
- package/__cjs/react/internal/cache/FragmentReference.d.cts +3 -3
- package/__cjs/react/internal/cache/QueryReference.cjs +3 -14
- package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
- package/__cjs/react/internal/cache/QueryReference.d.cts +7 -7
- package/__cjs/react/internal/cache/SuspenseCache.cjs.map +1 -1
- package/__cjs/react/internal/cache/SuspenseCache.d.cts +3 -3
- package/__cjs/react/internal/cache/getSuspenseCache.cjs.map +1 -1
- package/__cjs/react/internal/cache/getSuspenseCache.d.cts +4 -4
- package/__cjs/react/internal/index.cjs +3 -1
- package/__cjs/react/internal/index.cjs.map +1 -1
- package/__cjs/react/internal/index.d.cts +2 -0
- package/__cjs/react/internal/types.d.cts +9 -0
- package/__cjs/react/query-preloader/createQueryPreloader.cjs +1 -0
- package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.d.cts +6 -45
- package/__cjs/react/ssr/getDataFromTree.cjs +24 -30
- package/__cjs/react/ssr/getDataFromTree.cjs.map +1 -1
- package/__cjs/react/ssr/getDataFromTree.d.cts +12 -1
- package/__cjs/react/ssr/index.cjs +3 -3
- package/__cjs/react/ssr/index.cjs.map +1 -1
- package/__cjs/react/ssr/index.d.cts +1 -1
- package/__cjs/react/ssr/prerenderStatic.cjs +151 -0
- package/__cjs/react/ssr/prerenderStatic.cjs.map +1 -0
- package/__cjs/react/ssr/prerenderStatic.d.cts +122 -0
- package/__cjs/react/ssr/renderToStringWithData.cjs +11 -5
- package/__cjs/react/ssr/renderToStringWithData.cjs.map +1 -1
- package/__cjs/react/ssr/renderToStringWithData.d.cts +5 -0
- package/__cjs/react/ssr/useSSRQuery.cjs +60 -0
- package/__cjs/react/ssr/useSSRQuery.cjs.map +1 -0
- package/__cjs/react/ssr/useSSRQuery.d.cts +5 -0
- package/__cjs/{utilities/types/TODO.cjs → react/types/deprecated.cjs} +1 -1
- package/__cjs/react/types/deprecated.cjs.map +1 -0
- package/__cjs/react/types/deprecated.d.cts +75 -0
- package/__cjs/react/types/types.documentation.d.cts +6 -34
- package/__cjs/testing/core/index.cjs +6 -3
- package/__cjs/testing/core/index.cjs.map +1 -1
- package/__cjs/testing/core/index.d.cts +3 -3
- package/__cjs/testing/core/mocking/mockClient.cjs +3 -4
- package/__cjs/testing/core/mocking/mockClient.cjs.map +1 -1
- package/__cjs/testing/core/mocking/mockClient.d.cts +2 -3
- package/__cjs/testing/core/mocking/mockLink.cjs +118 -112
- package/__cjs/testing/core/mocking/mockLink.cjs.map +1 -1
- package/__cjs/testing/core/mocking/mockLink.d.cts +26 -7
- package/__cjs/testing/experimental/createSchemaFetch.cjs +4 -4
- package/__cjs/testing/experimental/createSchemaFetch.cjs.map +1 -1
- package/__cjs/testing/experimental/createTestSchema.cjs.map +1 -1
- package/__cjs/testing/experimental/createTestSchema.d.cts +1 -1
- package/__cjs/testing/index.cjs +13 -2
- package/__cjs/testing/index.cjs.map +1 -1
- package/__cjs/testing/index.d.cts +2 -1
- package/__cjs/testing/internal/disposables/spyOnConsole.cjs +0 -1
- package/__cjs/testing/internal/disposables/spyOnConsole.cjs.map +1 -1
- package/__cjs/testing/internal/disposables/spyOnConsole.d.cts +0 -1
- package/__cjs/testing/internal/disposables/withProdMode.d.cts +1 -1
- package/__cjs/testing/internal/incremental.cjs.map +1 -1
- package/__cjs/testing/internal/incremental.d.cts +4 -3
- package/__cjs/testing/internal/index.cjs +14 -8
- package/__cjs/testing/internal/index.cjs.map +1 -1
- package/__cjs/testing/internal/index.d.cts +4 -3
- package/__cjs/testing/internal/renderHelpers.cjs.map +1 -1
- package/__cjs/testing/internal/renderHelpers.d.cts +3 -3
- package/__cjs/testing/internal/resetApolloContext.cjs +24 -0
- package/__cjs/testing/internal/resetApolloContext.cjs.map +1 -0
- package/__cjs/testing/internal/resetApolloContext.d.cts +10 -0
- package/__cjs/testing/internal/scenarios/index.cjs +9 -7
- package/__cjs/testing/internal/scenarios/index.cjs.map +1 -1
- package/__cjs/testing/internal/scenarios/index.d.cts +14 -5
- package/__cjs/testing/matchers/arrayWithLength.cjs +15 -0
- package/__cjs/testing/matchers/arrayWithLength.cjs.map +1 -0
- package/__cjs/testing/matchers/arrayWithLength.d.cts +3 -0
- package/__cjs/testing/matchers/index.cjs +6 -18
- package/__cjs/testing/matchers/index.cjs.map +1 -1
- package/__cjs/testing/matchers/toComplete.cjs.map +1 -1
- package/__cjs/testing/matchers/toEmitAnything.cjs.map +1 -1
- package/__cjs/testing/matchers/toEmitError.cjs.map +1 -1
- package/__cjs/testing/matchers/toEmitNext.cjs.map +1 -1
- package/__cjs/testing/matchers/{toEmitFetchResult.cjs → toEmitTypedValue.cjs} +9 -7
- package/__cjs/testing/matchers/toEmitTypedValue.cjs.map +1 -0
- package/__cjs/testing/matchers/{toEmitValueStrict.d.cts → toEmitTypedValue.d.cts} +2 -2
- package/__cjs/testing/matchers/toHaveSuspenseCacheEntryUsing.cjs +2 -2
- package/__cjs/testing/matchers/toHaveSuspenseCacheEntryUsing.cjs.map +1 -1
- package/__cjs/testing/matchers/toHaveSuspenseCacheEntryUsing.d.cts +1 -1
- package/__cjs/testing/matchers/toMatchDocument.cjs.map +1 -1
- package/__cjs/testing/matchers/toMatchDocument.d.cts +1 -1
- package/__cjs/testing/matchers/toStrictEqualTyped.cjs +26 -0
- package/__cjs/testing/matchers/toStrictEqualTyped.cjs.map +1 -0
- package/__cjs/testing/matchers/toStrictEqualTyped.d.cts +3 -0
- package/__cjs/testing/matchers/utils/getSerializableProperties.cjs +23 -0
- package/__cjs/testing/matchers/utils/getSerializableProperties.cjs.map +1 -0
- package/__cjs/testing/matchers/utils/getSerializableProperties.d.cts +2 -0
- package/__cjs/testing/react/MockedProvider.cjs +11 -7
- package/__cjs/testing/react/MockedProvider.cjs.map +1 -1
- package/__cjs/testing/react/MockedProvider.d.cts +8 -6
- package/__cjs/utilities/caching/sizes.cjs +2 -2
- package/__cjs/utilities/caching/sizes.cjs.map +1 -1
- package/__cjs/utilities/caching/sizes.d.cts +2 -20
- package/__cjs/utilities/common/canonicalStringify.cjs +2 -2
- package/__cjs/utilities/common/canonicalStringify.cjs.map +1 -1
- package/__cjs/utilities/common/errorHandling.d.cts +1 -1
- package/__cjs/utilities/common/maybeDeepFreeze.cjs +1 -0
- package/__cjs/utilities/common/maybeDeepFreeze.cjs.map +1 -1
- package/__cjs/utilities/common/maybeDeepFreeze.d.cts +1 -0
- package/__cjs/utilities/common/mergeOptions.cjs.map +1 -1
- package/__cjs/utilities/common/mergeOptions.d.cts +1 -1
- package/__cjs/utilities/graphql/getFromAST.cjs +15 -6
- package/__cjs/utilities/graphql/getFromAST.cjs.map +1 -1
- package/__cjs/utilities/graphql/getFromAST.d.cts +2 -2
- package/__cjs/utilities/graphql/operations.cjs.map +1 -1
- package/__cjs/utilities/graphql/operations.d.cts +1 -1
- package/__cjs/utilities/graphql/print.cjs +2 -2
- package/__cjs/utilities/graphql/print.cjs.map +1 -1
- package/__cjs/utilities/graphql/storeUtils.cjs +1 -1
- package/__cjs/utilities/graphql/transform.cjs +2 -2
- package/__cjs/utilities/index.cjs +39 -19
- package/__cjs/utilities/index.cjs.map +1 -1
- package/__cjs/utilities/index.d.cts +16 -15
- package/__cjs/utilities/{caching → internal}/getMemoryInternals.cjs +1 -3
- package/__cjs/utilities/internal/getMemoryInternals.cjs.map +1 -0
- package/__cjs/utilities/{caching → internal}/getMemoryInternals.d.cts +1 -2
- package/__cjs/utilities/internal/index.cjs +8 -1
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +2 -0
- package/__cjs/utilities/internal/index.production.cjs +11 -0
- package/__cjs/utilities/internal/index.production.cjs.map +1 -0
- package/__cjs/utilities/internal/index.production.d.cts +3 -0
- package/__cjs/utilities/internal/toQueryResult.cjs +13 -0
- package/__cjs/utilities/internal/toQueryResult.cjs.map +1 -0
- package/__cjs/utilities/internal/toQueryResult.d.cts +3 -0
- package/__cjs/utilities/invariant/index.development.cjs +1 -0
- package/__cjs/utilities/invariant/index.development.cjs.map +1 -1
- package/__cjs/utilities/subscriptions/relay/index.cjs +2 -2
- package/__cjs/utilities/subscriptions/relay/index.cjs.map +1 -1
- package/__cjs/utilities/subscriptions/relay/index.d.cts +1 -1
- package/__cjs/utilities/types/NoInfer.d.cts +1 -1
- package/__cjs/utilities/types/{OnlyRequiredProperties.cjs → VariablesOption.cjs} +1 -1
- package/__cjs/utilities/types/VariablesOption.cjs.map +1 -0
- package/__cjs/utilities/types/VariablesOption.d.cts +25 -0
- package/__cjs/version.cjs +1 -1
- package/__cjs/version.cjs.map +1 -1
- package/__cjs/version.d.cts +1 -1
- package/cache/core/cache.d.ts +19 -19
- package/cache/core/cache.js +1 -1
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +9 -16
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/core/types/DataProxy.d.ts +8 -23
- package/cache/core/types/common.js +1 -0
- package/cache/core/types/common.js.map +1 -1
- package/cache/index.d.ts +3 -3
- package/cache/index.js +1 -1
- package/cache/index.js.map +1 -1
- package/cache/inmemory/entityStore.d.ts +3 -2
- package/cache/inmemory/entityStore.js +6 -5
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/fragmentRegistry.js +1 -1
- package/cache/inmemory/fragmentRegistry.js.map +1 -1
- package/cache/inmemory/helpers.d.ts +0 -1
- package/cache/inmemory/helpers.js +0 -7
- package/cache/inmemory/helpers.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +9 -11
- package/cache/inmemory/inMemoryCache.js +5 -17
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/policies.d.ts +1 -1
- package/cache/inmemory/policies.js +5 -5
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/reactiveVars.d.ts +7 -7
- package/cache/inmemory/reactiveVars.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +1 -6
- package/cache/inmemory/readFromStore.js +12 -54
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +3 -17
- package/cache/inmemory/writeToStore.d.ts +2 -2
- package/cache/inmemory/writeToStore.js +4 -4
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/config/jest/areCombinedGraphQLErrorsEqual.js +6 -4
- package/config/jest/areCombinedGraphQLErrorsEqual.js.map +1 -1
- package/config/jest/areCombinedProtocolErrorsEqual.js +3 -3
- package/config/jest/areCombinedProtocolErrorsEqual.js.map +1 -1
- package/config/jest/areMissingFieldErrorsEqual.js +2 -3
- package/config/jest/areMissingFieldErrorsEqual.js.map +1 -1
- package/config/jest/areServerErrorsEqual.d.ts +3 -0
- package/config/jest/areServerErrorsEqual.js +18 -0
- package/config/jest/areServerErrorsEqual.js.map +1 -0
- package/config/jest/resolver.js +12 -1
- package/config/jest/resolver.js.map +1 -1
- package/config/jest/setup.js +19 -2
- package/config/jest/setup.js.map +1 -1
- package/core/ApolloClient.d.ts +36 -26
- package/core/ApolloClient.js +36 -19
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.d.ts +6 -6
- package/core/LocalState.js +2 -2
- package/core/LocalState.js.map +1 -1
- package/core/ObservableQuery.d.ts +156 -17
- package/core/ObservableQuery.js +267 -102
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +2 -11
- package/core/QueryInfo.js +12 -86
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +32 -21
- package/core/QueryManager.js +151 -107
- package/core/QueryManager.js.map +1 -1
- package/core/index.d.ts +12 -11
- package/core/index.js +9 -6
- package/core/index.js.map +1 -1
- package/core/types.d.ts +60 -7
- package/core/watchQueryOptions.d.ts +32 -119
- package/errors/CombinedGraphQLErrors.d.ts +21 -2
- package/errors/CombinedGraphQLErrors.js +30 -11
- package/errors/CombinedGraphQLErrors.js.map +1 -1
- package/errors/CombinedProtocolErrors.d.ts +9 -0
- package/errors/CombinedProtocolErrors.js +13 -6
- package/errors/CombinedProtocolErrors.js.map +1 -1
- package/errors/LinkError.d.ts +14 -0
- package/errors/LinkError.js +16 -0
- package/errors/LinkError.js.map +1 -0
- package/errors/ServerError.d.ts +2 -0
- package/errors/ServerError.js +6 -0
- package/errors/ServerError.js.map +1 -1
- package/errors/ServerParseError.d.ts +2 -0
- package/errors/ServerParseError.js +6 -0
- package/errors/ServerParseError.js.map +1 -1
- package/errors/UnconventionalError.d.ts +2 -0
- package/errors/UnconventionalError.js +6 -0
- package/errors/UnconventionalError.js.map +1 -1
- package/errors/index.d.ts +2 -3
- package/errors/index.js +13 -1
- package/errors/index.js.map +1 -1
- package/errors/isErrorLike.d.ts +3 -0
- package/errors/isErrorLike.js +9 -0
- package/errors/isErrorLike.js.map +1 -0
- package/errors/utils.d.ts +3 -0
- package/errors/utils.js +14 -0
- package/errors/utils.js.map +1 -0
- package/invariantErrorCodes.js +121 -122
- package/legacyEntryPoints/testing/internal/index.d.ts +1 -0
- package/legacyEntryPoints/testing/internal/index.js +1 -0
- package/legacyEntryPoints/testing/internal/internal.cjs +1 -0
- package/legacyEntryPoints/testing/internal/internal.d.cts +1 -0
- package/link/batch/batching.js +1 -1
- package/link/batch/batching.js.map +1 -1
- package/link/batch/index.d.ts +2 -1
- package/link/batch/index.js +1 -1
- package/link/batch/index.js.map +1 -1
- package/link/batch-http/index.d.ts +1 -1
- package/link/batch-http/index.js +1 -1
- package/link/batch-http/index.js.map +1 -1
- package/link/context/index.d.ts +1 -1
- package/link/context/index.js.map +1 -1
- package/link/core/ApolloLink.d.ts +1 -3
- package/link/core/ApolloLink.js +2 -20
- package/link/core/ApolloLink.js.map +1 -1
- package/link/core/index.d.ts +1 -1
- package/link/core/index.js.map +1 -1
- package/link/core/types.d.ts +1 -1
- package/link/error/index.d.ts +4 -15
- package/link/error/index.js +14 -29
- package/link/error/index.js.map +1 -1
- package/link/http/checkFetcher.js +1 -1
- package/link/http/createHttpLink.js +1 -1
- package/link/http/parseAndCheckHttpResponse.js +4 -3
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/persisted-queries/index.d.ts +2 -2
- package/link/persisted-queries/index.js +3 -3
- package/link/persisted-queries/index.js.map +1 -1
- package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
- package/link/retry/index.d.ts +1 -1
- package/link/retry/index.js +1 -1
- package/link/retry/index.js.map +1 -1
- package/link/subscriptions/index.js +3 -1
- package/link/subscriptions/index.js.map +1 -1
- package/link/utils/validateOperation.js +1 -1
- package/masking/maskDefinition.d.ts +1 -1
- package/masking/maskDefinition.js +2 -2
- package/masking/maskDefinition.js.map +1 -1
- package/masking/maskFragment.d.ts +2 -2
- package/masking/maskFragment.js +2 -2
- package/masking/maskFragment.js.map +1 -1
- package/masking/maskOperation.d.ts +2 -2
- package/masking/maskOperation.js +1 -1
- package/masking/maskOperation.js.map +1 -1
- package/masking/utils.js +1 -1
- package/package.json +58 -56
- package/react/context/ApolloConsumer.d.ts +7 -4
- package/react/context/ApolloConsumer.js +2 -2
- package/react/context/ApolloConsumer.js.map +1 -1
- package/react/context/ApolloContext.d.ts +4 -4
- package/react/context/ApolloContext.js +2 -2
- package/react/context/ApolloContext.js.map +1 -1
- package/react/context/ApolloProvider.d.ts +7 -5
- package/react/context/ApolloProvider.js +2 -2
- package/react/context/ApolloProvider.js.map +1 -1
- package/react/hooks/internal/__use.js +1 -1
- package/react/hooks/internal/__use.js.map +1 -1
- package/react/hooks/internal/useDeepMemo.js +3 -1
- package/react/hooks/internal/useDeepMemo.js.map +1 -1
- package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts +1 -1
- package/react/hooks/internal/useIsomorphicLayoutEffect.js +1 -1
- package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -1
- package/react/hooks/internal/useRenderGuard.js +1 -1
- package/react/hooks/internal/useRenderGuard.js.map +1 -1
- package/react/hooks/internal/validateSuspenseHookOptions.d.ts +3 -0
- package/react/hooks/internal/validateSuspenseHookOptions.js +22 -0
- package/react/hooks/internal/validateSuspenseHookOptions.js.map +1 -0
- package/react/hooks/internal/wrapHook.d.ts +7 -5
- package/react/hooks/internal/wrapHook.js +24 -5
- package/react/hooks/internal/wrapHook.js.map +1 -1
- package/react/hooks/useApolloClient.d.ts +2 -2
- package/react/hooks/useApolloClient.js +2 -2
- package/react/hooks/useApolloClient.js.map +1 -1
- package/react/hooks/useBackgroundQuery.d.ts +143 -46
- package/react/hooks/useBackgroundQuery.js +3 -3
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useFragment.d.ts +51 -26
- package/react/hooks/useFragment.js +1 -1
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +278 -276
- package/react/hooks/useLazyQuery.js +32 -31
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +106 -34
- package/react/hooks/useLoadableQuery.js +22 -3
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +198 -4
- package/react/hooks/useMutation.js +15 -23
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +274 -4
- package/react/hooks/useQuery.js +87 -206
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.d.ts +23 -22
- package/react/hooks/useQueryRefHandlers.js +1 -1
- package/react/hooks/useQueryRefHandlers.js.map +1 -1
- package/react/hooks/useReactiveVar.d.ts +1 -1
- package/react/hooks/useReactiveVar.js +1 -1
- package/react/hooks/useReactiveVar.js.map +1 -1
- package/react/hooks/useReadQuery.d.ts +27 -25
- package/react/hooks/useReadQuery.js +1 -1
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +94 -9
- package/react/hooks/useSubscription.js +9 -56
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseFragment.d.ts +40 -38
- package/react/hooks/useSuspenseFragment.js +1 -1
- package/react/hooks/useSuspenseFragment.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +199 -38
- package/react/hooks/useSuspenseQuery.js +6 -27
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +2 -2
- package/react/hooks/useSyncExternalStore.js.map +1 -1
- package/react/index.d.ts +21 -6
- package/react/index.js +17 -3
- package/react/index.js.map +1 -1
- package/react/index.react-server.d.ts +19 -0
- package/react/index.react-server.js +45 -0
- package/react/index.react-server.js.map +1 -0
- package/react/internal/cache/FragmentReference.d.ts +3 -3
- package/react/internal/cache/FragmentReference.js.map +1 -1
- package/react/internal/cache/QueryReference.d.ts +5 -5
- package/react/internal/cache/QueryReference.js +3 -14
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/internal/cache/SuspenseCache.d.ts +3 -3
- package/react/internal/cache/SuspenseCache.js.map +1 -1
- package/react/internal/cache/getSuspenseCache.d.ts +3 -3
- package/react/internal/cache/getSuspenseCache.js.map +1 -1
- package/react/internal/index.d.ts +2 -0
- package/react/internal/index.js +2 -1
- package/react/internal/index.js.map +1 -1
- package/react/internal/types.d.ts +9 -0
- package/react/query-preloader/createQueryPreloader.d.ts +6 -45
- package/react/query-preloader/createQueryPreloader.js +1 -0
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/ssr/getDataFromTree.d.ts +12 -1
- package/react/ssr/getDataFromTree.js +24 -29
- package/react/ssr/getDataFromTree.js.map +1 -1
- package/react/ssr/index.d.ts +1 -1
- package/react/ssr/index.js +1 -1
- package/react/ssr/index.js.map +1 -1
- package/react/ssr/prerenderStatic.d.ts +122 -0
- package/react/ssr/prerenderStatic.js +147 -0
- package/react/ssr/prerenderStatic.js.map +1 -0
- package/react/ssr/renderToStringWithData.d.ts +5 -0
- package/react/ssr/renderToStringWithData.js +11 -5
- package/react/ssr/renderToStringWithData.js.map +1 -1
- package/react/ssr/useSSRQuery.d.ts +5 -0
- package/react/ssr/useSSRQuery.js +56 -0
- package/react/ssr/useSSRQuery.js.map +1 -0
- package/react/types/deprecated.d.ts +75 -0
- package/react/types/deprecated.js +2 -0
- package/react/types/deprecated.js.map +1 -0
- package/react/types/types.documentation.d.ts +6 -34
- package/testing/core/index.d.ts +3 -3
- package/testing/core/index.js +2 -2
- package/testing/core/index.js.map +1 -1
- package/testing/core/mocking/mockClient.d.ts +2 -3
- package/testing/core/mocking/mockClient.js +2 -3
- package/testing/core/mocking/mockClient.js.map +1 -1
- package/testing/core/mocking/mockLink.d.ts +26 -7
- package/testing/core/mocking/mockLink.js +117 -113
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/experimental/createSchemaFetch.js +2 -2
- package/testing/experimental/createSchemaFetch.js.map +1 -1
- package/testing/experimental/createTestSchema.d.ts +1 -1
- package/testing/experimental/createTestSchema.js.map +1 -1
- package/testing/index.d.ts +2 -1
- package/testing/index.js +1 -1
- package/testing/index.js.map +1 -1
- package/testing/internal/disposables/spyOnConsole.d.ts +0 -1
- package/testing/internal/disposables/spyOnConsole.js +0 -1
- package/testing/internal/disposables/spyOnConsole.js.map +1 -1
- package/testing/internal/incremental.d.ts +1 -1
- package/testing/internal/incremental.js.map +1 -1
- package/testing/internal/index.d.ts +4 -3
- package/testing/internal/index.js +4 -3
- package/testing/internal/index.js.map +1 -1
- package/testing/internal/renderHelpers.d.ts +3 -3
- package/testing/internal/renderHelpers.js.map +1 -1
- package/testing/internal/resetApolloContext.d.ts +10 -0
- package/testing/internal/resetApolloContext.js +20 -0
- package/testing/internal/resetApolloContext.js.map +1 -0
- package/testing/internal/scenarios/index.d.ts +6 -8
- package/testing/internal/scenarios/index.js +4 -2
- package/testing/internal/scenarios/index.js.map +1 -1
- package/testing/matchers/arrayWithLength.d.ts +3 -0
- package/testing/matchers/arrayWithLength.js +11 -0
- package/testing/matchers/arrayWithLength.js.map +1 -0
- package/testing/matchers/index.js +6 -18
- package/testing/matchers/index.js.map +1 -1
- package/testing/matchers/toComplete.js.map +1 -1
- package/testing/matchers/toEmitAnything.js.map +1 -1
- package/testing/matchers/toEmitError.js.map +1 -1
- package/testing/matchers/toEmitNext.js.map +1 -1
- package/testing/matchers/{toEmitValueStrict.d.ts → toEmitTypedValue.d.ts} +2 -2
- package/testing/matchers/{toEmitFetchResult.js → toEmitTypedValue.js} +7 -5
- package/testing/matchers/toEmitTypedValue.js.map +1 -0
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.d.ts +1 -1
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.js +1 -1
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.js.map +1 -1
- package/testing/matchers/toMatchDocument.d.ts +1 -1
- package/testing/matchers/toMatchDocument.js.map +1 -1
- package/testing/matchers/toStrictEqualTyped.d.ts +3 -0
- package/testing/matchers/toStrictEqualTyped.js +22 -0
- package/testing/matchers/toStrictEqualTyped.js.map +1 -0
- package/testing/matchers/utils/getSerializableProperties.d.ts +2 -0
- package/testing/matchers/utils/getSerializableProperties.js +20 -0
- package/testing/matchers/utils/getSerializableProperties.js.map +1 -0
- package/testing/react/MockedProvider.d.ts +8 -6
- package/testing/react/MockedProvider.js +8 -4
- package/testing/react/MockedProvider.js.map +1 -1
- package/utilities/caching/sizes.d.ts +2 -20
- package/utilities/caching/sizes.js +2 -2
- package/utilities/caching/sizes.js.map +1 -1
- package/utilities/common/canonicalStringify.js +1 -1
- package/utilities/common/canonicalStringify.js.map +1 -1
- package/utilities/common/maybeDeepFreeze.d.ts +1 -0
- package/utilities/common/maybeDeepFreeze.js +1 -0
- package/utilities/common/maybeDeepFreeze.js.map +1 -1
- package/utilities/common/mergeOptions.d.ts +1 -1
- package/utilities/common/mergeOptions.js.map +1 -1
- package/utilities/graphql/getFromAST.d.ts +2 -2
- package/utilities/graphql/getFromAST.js +15 -6
- package/utilities/graphql/getFromAST.js.map +1 -1
- package/utilities/graphql/operations.d.ts +1 -1
- package/utilities/graphql/operations.js.map +1 -1
- package/utilities/graphql/print.js +1 -1
- package/utilities/graphql/print.js.map +1 -1
- package/utilities/graphql/storeUtils.js +1 -1
- package/utilities/graphql/transform.js +2 -2
- package/utilities/index.d.ts +16 -15
- package/utilities/index.js +12 -12
- package/utilities/index.js.map +1 -1
- package/utilities/{caching → internal}/getMemoryInternals.d.ts +0 -1
- package/utilities/{caching → internal}/getMemoryInternals.js +1 -3
- package/utilities/internal/getMemoryInternals.js.map +1 -0
- package/utilities/internal/index.d.ts +2 -0
- package/utilities/internal/index.js +2 -0
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/index.production.d.ts +3 -0
- package/utilities/internal/index.production.js +7 -0
- package/utilities/internal/index.production.js.map +1 -0
- package/utilities/internal/toQueryResult.d.ts +3 -0
- package/utilities/internal/toQueryResult.js +10 -0
- package/utilities/internal/toQueryResult.js.map +1 -0
- package/utilities/invariant/index.development.js +1 -0
- package/utilities/invariant/index.development.js.map +1 -1
- package/utilities/subscriptions/relay/index.d.ts +1 -1
- package/utilities/subscriptions/relay/index.js +1 -1
- package/utilities/subscriptions/relay/index.js.map +1 -1
- package/utilities/types/NoInfer.d.ts +1 -1
- package/utilities/types/VariablesOption.d.ts +25 -0
- package/utilities/types/VariablesOption.js +2 -0
- package/utilities/types/VariablesOption.js.map +1 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/__cjs/cache/inmemory/fixPolyfills.cjs +0 -10
- package/__cjs/cache/inmemory/fixPolyfills.cjs.map +0 -1
- package/__cjs/cache/inmemory/fixPolyfills.d.cts +0 -2
- package/__cjs/cache/inmemory/fixPolyfills.native.cjs +0 -53
- package/__cjs/cache/inmemory/fixPolyfills.native.cjs.map +0 -1
- package/__cjs/cache/inmemory/fixPolyfills.native.d.cts +0 -2
- package/__cjs/cache/inmemory/object-canon.cjs +0 -180
- package/__cjs/cache/inmemory/object-canon.cjs.map +0 -1
- package/__cjs/cache/inmemory/object-canon.d.cts +0 -12
- package/__cjs/index.cjs +0 -8
- package/__cjs/index.cjs.map +0 -1
- package/__cjs/index.d.cts +0 -3
- package/__cjs/link/http/iterators/async.cjs +0 -19
- package/__cjs/link/http/iterators/async.cjs.map +0 -1
- package/__cjs/link/http/iterators/async.d.cts +0 -6
- package/__cjs/link/http/iterators/nodeStream.cjs +0 -75
- package/__cjs/link/http/iterators/nodeStream.cjs.map +0 -1
- package/__cjs/link/http/iterators/nodeStream.d.cts +0 -7
- package/__cjs/link/http/iterators/promise.cjs +0 -32
- package/__cjs/link/http/iterators/promise.cjs.map +0 -1
- package/__cjs/link/http/iterators/promise.d.cts +0 -6
- package/__cjs/link/http/iterators/reader.cjs +0 -19
- package/__cjs/link/http/iterators/reader.cjs.map +0 -1
- package/__cjs/link/http/iterators/reader.d.cts +0 -6
- package/__cjs/link/http/responseIterator.cjs +0 -50
- package/__cjs/link/http/responseIterator.cjs.map +0 -1
- package/__cjs/link/http/responseIterator.d.cts +0 -7
- package/__cjs/react/context/index.cjs +0 -10
- package/__cjs/react/context/index.cjs.map +0 -1
- package/__cjs/react/context/index.d.cts +0 -7
- package/__cjs/react/hooks/index.cjs +0 -27
- package/__cjs/react/hooks/index.cjs.map +0 -1
- package/__cjs/react/hooks/index.d.cts +0 -22
- package/__cjs/react/parser/index.cjs +0 -115
- package/__cjs/react/parser/index.cjs.map +0 -1
- package/__cjs/react/parser/index.d.cts +0 -18
- package/__cjs/react/ssr/RenderPromises.cjs +0 -104
- package/__cjs/react/ssr/RenderPromises.cjs.map +0 -1
- package/__cjs/react/ssr/RenderPromises.d.cts +0 -22
- package/__cjs/react/types/types.d.cts +0 -689
- package/__cjs/testing/matchers/toEmitApolloQueryResult.cjs +0 -40
- package/__cjs/testing/matchers/toEmitApolloQueryResult.cjs.map +0 -1
- package/__cjs/testing/matchers/toEmitApolloQueryResult.d.cts +0 -8
- package/__cjs/testing/matchers/toEmitFetchResult.cjs.map +0 -1
- package/__cjs/testing/matchers/toEmitFetchResult.d.cts +0 -8
- package/__cjs/testing/matchers/toEmitMatchedValue.cjs +0 -40
- package/__cjs/testing/matchers/toEmitMatchedValue.cjs.map +0 -1
- package/__cjs/testing/matchers/toEmitMatchedValue.d.cts +0 -7
- package/__cjs/testing/matchers/toEmitValue.cjs +0 -41
- package/__cjs/testing/matchers/toEmitValue.cjs.map +0 -1
- package/__cjs/testing/matchers/toEmitValue.d.cts +0 -4
- package/__cjs/testing/matchers/toEmitValueStrict.cjs +0 -46
- package/__cjs/testing/matchers/toEmitValueStrict.cjs.map +0 -1
- package/__cjs/testing/matchers/toEqualApolloQueryResult.cjs +0 -24
- package/__cjs/testing/matchers/toEqualApolloQueryResult.cjs.map +0 -1
- package/__cjs/testing/matchers/toEqualApolloQueryResult.d.cts +0 -6
- package/__cjs/testing/matchers/toEqualFetchResult.cjs +0 -24
- package/__cjs/testing/matchers/toEqualFetchResult.cjs.map +0 -1
- package/__cjs/testing/matchers/toEqualFetchResult.d.cts +0 -4
- package/__cjs/testing/matchers/toEqualLazyQueryResult.cjs +0 -40
- package/__cjs/testing/matchers/toEqualLazyQueryResult.cjs.map +0 -1
- package/__cjs/testing/matchers/toEqualLazyQueryResult.d.cts +0 -10
- package/__cjs/testing/matchers/toEqualQueryResult.cjs +0 -40
- package/__cjs/testing/matchers/toEqualQueryResult.cjs.map +0 -1
- package/__cjs/testing/matchers/toEqualQueryResult.d.cts +0 -9
- package/__cjs/utilities/caching/getMemoryInternals.cjs.map +0 -1
- package/__cjs/utilities/types/OnlyRequiredProperties.cjs.map +0 -1
- package/__cjs/utilities/types/OnlyRequiredProperties.d.cts +0 -7
- package/__cjs/utilities/types/TODO.cjs.map +0 -1
- package/__cjs/utilities/types/TODO.d.cts +0 -3
- package/cache/inmemory/fixPolyfills.d.ts +0 -2
- package/cache/inmemory/fixPolyfills.js +0 -10
- package/cache/inmemory/fixPolyfills.js.map +0 -1
- package/cache/inmemory/fixPolyfills.native.d.ts +0 -2
- package/cache/inmemory/fixPolyfills.native.js +0 -53
- package/cache/inmemory/fixPolyfills.native.js.map +0 -1
- package/cache/inmemory/object-canon.d.ts +0 -12
- package/cache/inmemory/object-canon.js +0 -176
- package/cache/inmemory/object-canon.js.map +0 -1
- package/index.d.ts +0 -3
- package/index.js +0 -3
- package/index.js.map +0 -1
- package/legacyEntryPoints/react/context/context.cjs +0 -1
- package/legacyEntryPoints/react/context/context.d.cts +0 -1
- package/legacyEntryPoints/react/context/index.d.ts +0 -1
- package/legacyEntryPoints/react/context/index.js +0 -1
- package/legacyEntryPoints/react/hooks/hooks.cjs +0 -1
- package/legacyEntryPoints/react/hooks/hooks.d.cts +0 -1
- package/legacyEntryPoints/react/hooks/index.d.ts +0 -1
- package/legacyEntryPoints/react/hooks/index.js +0 -1
- package/legacyEntryPoints/react/parser/index.d.ts +0 -1
- package/legacyEntryPoints/react/parser/index.js +0 -1
- package/legacyEntryPoints/react/parser/parser.cjs +0 -1
- package/legacyEntryPoints/react/parser/parser.d.cts +0 -1
- package/link/http/iterators/async.d.ts +0 -6
- package/link/http/iterators/async.js +0 -16
- package/link/http/iterators/async.js.map +0 -1
- package/link/http/iterators/nodeStream.d.ts +0 -7
- package/link/http/iterators/nodeStream.js +0 -72
- package/link/http/iterators/nodeStream.js.map +0 -1
- package/link/http/iterators/promise.d.ts +0 -6
- package/link/http/iterators/promise.js +0 -29
- package/link/http/iterators/promise.js.map +0 -1
- package/link/http/iterators/reader.d.ts +0 -6
- package/link/http/iterators/reader.js +0 -16
- package/link/http/iterators/reader.js.map +0 -1
- package/link/http/responseIterator.d.ts +0 -7
- package/link/http/responseIterator.js +0 -46
- package/link/http/responseIterator.js.map +0 -1
- package/react/context/index.d.ts +0 -7
- package/react/context/index.js +0 -4
- package/react/context/index.js.map +0 -1
- package/react/hooks/index.d.ts +0 -22
- package/react/hooks/index.js +0 -15
- package/react/hooks/index.js.map +0 -1
- package/react/parser/index.d.ts +0 -18
- package/react/parser/index.js +0 -109
- package/react/parser/index.js.map +0 -1
- package/react/ssr/RenderPromises.d.ts +0 -22
- package/react/ssr/RenderPromises.js +0 -100
- package/react/ssr/RenderPromises.js.map +0 -1
- package/react/types/types.d.ts +0 -689
- package/testing/matchers/toEmitApolloQueryResult.d.ts +0 -8
- package/testing/matchers/toEmitApolloQueryResult.js +0 -36
- package/testing/matchers/toEmitApolloQueryResult.js.map +0 -1
- package/testing/matchers/toEmitFetchResult.d.ts +0 -8
- package/testing/matchers/toEmitFetchResult.js.map +0 -1
- package/testing/matchers/toEmitMatchedValue.d.ts +0 -7
- package/testing/matchers/toEmitMatchedValue.js +0 -36
- package/testing/matchers/toEmitMatchedValue.js.map +0 -1
- package/testing/matchers/toEmitValue.d.ts +0 -4
- package/testing/matchers/toEmitValue.js +0 -37
- package/testing/matchers/toEmitValue.js.map +0 -1
- package/testing/matchers/toEmitValueStrict.js +0 -42
- package/testing/matchers/toEmitValueStrict.js.map +0 -1
- package/testing/matchers/toEqualApolloQueryResult.d.ts +0 -6
- package/testing/matchers/toEqualApolloQueryResult.js +0 -20
- package/testing/matchers/toEqualApolloQueryResult.js.map +0 -1
- package/testing/matchers/toEqualFetchResult.d.ts +0 -4
- package/testing/matchers/toEqualFetchResult.js +0 -20
- package/testing/matchers/toEqualFetchResult.js.map +0 -1
- package/testing/matchers/toEqualLazyQueryResult.d.ts +0 -10
- package/testing/matchers/toEqualLazyQueryResult.js +0 -36
- package/testing/matchers/toEqualLazyQueryResult.js.map +0 -1
- package/testing/matchers/toEqualQueryResult.d.ts +0 -9
- package/testing/matchers/toEqualQueryResult.js +0 -36
- package/testing/matchers/toEqualQueryResult.js.map +0 -1
- package/utilities/caching/getMemoryInternals.js.map +0 -1
- package/utilities/types/OnlyRequiredProperties.d.ts +0 -7
- package/utilities/types/OnlyRequiredProperties.js +0 -2
- package/utilities/types/OnlyRequiredProperties.js.map +0 -1
- package/utilities/types/TODO.d.ts +0 -3
- package/utilities/types/TODO.js +0 -2
- package/utilities/types/TODO.js.map +0 -1
- /package/__cjs/react/{types → internal}/types.cjs +0 -0
- /package/__cjs/react/{types → internal}/types.cjs.map +0 -0
- /package/react/{types → internal}/types.js +0 -0
- /package/react/{types → internal}/types.js.map +0 -0
package/core/QueryManager.d.ts
CHANGED
|
@@ -9,7 +9,8 @@ import type { DefaultOptions } from "./ApolloClient.js";
|
|
|
9
9
|
import type { LocalState } from "./LocalState.js";
|
|
10
10
|
import { NetworkStatus } from "./networkStatus.js";
|
|
11
11
|
import { ObservableQuery } from "./ObservableQuery.js";
|
|
12
|
-
import
|
|
12
|
+
import { QueryInfo } from "./QueryInfo.js";
|
|
13
|
+
import type { ApolloQueryResult, DefaultContext, InternalRefetchQueriesInclude, InternalRefetchQueriesMap, InternalRefetchQueriesOptions, MutateResult, MutationUpdaterFunction, OnQueryUpdated, OperationVariables, QueryResult, SubscribeResult, TypedDocumentNode } from "./types.js";
|
|
13
14
|
import type { ErrorPolicy, MutationFetchPolicy, MutationOptions, QueryOptions, SubscriptionOptions, WatchQueryFetchPolicy, WatchQueryOptions } from "./watchQueryOptions.js";
|
|
14
15
|
interface MutationStoreValue {
|
|
15
16
|
mutation: DocumentNode;
|
|
@@ -39,8 +40,8 @@ interface MaskOperationOptions<TData> {
|
|
|
39
40
|
id: string;
|
|
40
41
|
fetchPolicy?: WatchQueryFetchPolicy;
|
|
41
42
|
}
|
|
42
|
-
interface QueryManagerOptions
|
|
43
|
-
cache: ApolloCache
|
|
43
|
+
interface QueryManagerOptions {
|
|
44
|
+
cache: ApolloCache;
|
|
44
45
|
link: ApolloLink;
|
|
45
46
|
defaultOptions: DefaultOptions;
|
|
46
47
|
documentTransform: DocumentTransform | null | undefined;
|
|
@@ -48,13 +49,13 @@ interface QueryManagerOptions<TStore> {
|
|
|
48
49
|
onBroadcast: undefined | (() => void);
|
|
49
50
|
ssrMode: boolean;
|
|
50
51
|
clientAwareness: Record<string, string>;
|
|
51
|
-
localState: LocalState
|
|
52
|
+
localState: LocalState;
|
|
52
53
|
assumeImmutableResults: boolean;
|
|
53
54
|
defaultContext: Partial<DefaultContext> | undefined;
|
|
54
55
|
dataMasking: boolean;
|
|
55
56
|
}
|
|
56
|
-
export declare class QueryManager
|
|
57
|
-
cache: ApolloCache
|
|
57
|
+
export declare class QueryManager {
|
|
58
|
+
cache: ApolloCache;
|
|
58
59
|
link: ApolloLink;
|
|
59
60
|
defaultOptions: DefaultOptions;
|
|
60
61
|
readonly assumeImmutableResults: boolean;
|
|
@@ -65,21 +66,32 @@ export declare class QueryManager<TStore> {
|
|
|
65
66
|
private queryDeduplication;
|
|
66
67
|
private clientAwareness;
|
|
67
68
|
private localState;
|
|
69
|
+
/**
|
|
70
|
+
* Whether to prioritize cache values over network results when
|
|
71
|
+
* `fetchObservableWithInfo` is called.
|
|
72
|
+
* This will essentially turn a `"network-only"` or `"cache-and-network"`
|
|
73
|
+
* fetchPolicy into a `"cache-first"` fetchPolicy, but without influencing
|
|
74
|
+
* the `fetchPolicy` of the `ObservableQuery`.
|
|
75
|
+
*
|
|
76
|
+
* This can e.g. be used to prioritize the cache during the first render after
|
|
77
|
+
* SSR.
|
|
78
|
+
*/
|
|
79
|
+
prioritizeCacheValues: boolean;
|
|
68
80
|
private onBroadcast?;
|
|
69
81
|
mutationStore?: {
|
|
70
82
|
[mutationId: string]: MutationStoreValue;
|
|
71
83
|
};
|
|
72
84
|
private queries;
|
|
73
85
|
protected fetchCancelFns: Map<string, (error: any) => any>;
|
|
74
|
-
constructor(options: QueryManagerOptions
|
|
86
|
+
constructor(options: QueryManagerOptions);
|
|
75
87
|
/**
|
|
76
88
|
* Call this method to terminate any active query processes, making it safe
|
|
77
89
|
* to dispose of this QueryManager instance.
|
|
78
90
|
*/
|
|
79
91
|
stop(): void;
|
|
80
92
|
private cancelPendingFetches;
|
|
81
|
-
mutate<TData, TVariables extends OperationVariables, TContext extends Record<string, any>, TCache extends ApolloCache
|
|
82
|
-
markMutationResult<TData, TVariables, TContext, TCache extends ApolloCache
|
|
93
|
+
mutate<TData, TVariables extends OperationVariables, TContext extends Record<string, any>, TCache extends ApolloCache>({ mutation, variables, optimisticResponse, updateQueries, refetchQueries, awaitRefetchQueries, update: updateWithProxyFn, onQueryUpdated, fetchPolicy, errorPolicy, keepRootFields, context, }: MutationOptions<TData, TVariables, TContext>): Promise<MutateResult<MaybeMasked<TData>>>;
|
|
94
|
+
markMutationResult<TData, TVariables extends OperationVariables, TContext, TCache extends ApolloCache>(mutation: {
|
|
83
95
|
mutationId: string;
|
|
84
96
|
result: FetchResult<TData>;
|
|
85
97
|
document: DocumentNode;
|
|
@@ -94,8 +106,8 @@ export declare class QueryManager<TStore> {
|
|
|
94
106
|
removeOptimistic?: string;
|
|
95
107
|
onQueryUpdated?: OnQueryUpdated<any>;
|
|
96
108
|
keepRootFields?: boolean;
|
|
97
|
-
}, cache?: ApolloCache
|
|
98
|
-
markMutationOptimistic<TData, TVariables, TContext, TCache extends ApolloCache
|
|
109
|
+
}, cache?: ApolloCache): Promise<FetchResult<TData>>;
|
|
110
|
+
markMutationOptimistic<TData, TVariables extends OperationVariables, TContext, TCache extends ApolloCache>(optimisticResponse: any, mutation: {
|
|
99
111
|
mutationId: string;
|
|
100
112
|
document: DocumentNode;
|
|
101
113
|
variables?: TVariables;
|
|
@@ -106,13 +118,13 @@ export declare class QueryManager<TStore> {
|
|
|
106
118
|
update?: MutationUpdaterFunction<TData, TVariables, TContext, TCache>;
|
|
107
119
|
keepRootFields?: boolean;
|
|
108
120
|
}): boolean;
|
|
109
|
-
fetchQuery<TData, TVars extends OperationVariables>(queryId: string, options: WatchQueryOptions<TVars, TData>, networkStatus?: NetworkStatus): Promise<
|
|
121
|
+
fetchQuery<TData, TVars extends OperationVariables>(queryId: string, options: WatchQueryOptions<TVars, TData>, networkStatus?: NetworkStatus): Promise<QueryResult<TData>>;
|
|
110
122
|
transform(document: DocumentNode): DocumentNode;
|
|
111
123
|
private transformCache;
|
|
112
124
|
getDocumentInfo(document: DocumentNode): TransformCacheEntry;
|
|
113
|
-
|
|
125
|
+
getVariables<TVariables>(document: DocumentNode, variables?: TVariables): TVariables;
|
|
114
126
|
watchQuery<T, TVariables extends OperationVariables = OperationVariables>(options: WatchQueryOptions<TVariables, T>): ObservableQuery<T, TVariables>;
|
|
115
|
-
query<TData, TVars extends OperationVariables = OperationVariables>(options: QueryOptions<TVars, TData>, queryId?: string): Promise<
|
|
127
|
+
query<TData, TVars extends OperationVariables = OperationVariables>(options: QueryOptions<TVars, TData>, queryId?: string): Promise<QueryResult<MaybeMasked<TData>>>;
|
|
116
128
|
private queryIdCounter;
|
|
117
129
|
generateQueryId(): string;
|
|
118
130
|
private requestIdCounter;
|
|
@@ -121,25 +133,24 @@ export declare class QueryManager<TStore> {
|
|
|
121
133
|
generateMutationId(): string;
|
|
122
134
|
clearStore(options?: Cache.ResetOptions): Promise<void>;
|
|
123
135
|
getObservableQueries(include?: InternalRefetchQueriesInclude): Map<string, ObservableQuery<any, OperationVariables>>;
|
|
124
|
-
reFetchObservableQueries(includeStandby?: boolean): Promise<
|
|
125
|
-
|
|
126
|
-
startGraphQLSubscription<T = any>(options: SubscriptionOptions): Observable<FetchResult<T>>;
|
|
136
|
+
reFetchObservableQueries(includeStandby?: boolean): Promise<QueryResult<any>[]>;
|
|
137
|
+
startGraphQLSubscription<TData = unknown>(options: SubscriptionOptions): Observable<SubscribeResult<TData>>;
|
|
127
138
|
stopQuery(queryId: string): void;
|
|
128
139
|
removeQuery(queryId: string): void;
|
|
129
140
|
broadcastQueries(): void;
|
|
130
|
-
getLocalState(): LocalState
|
|
141
|
+
getLocalState(): LocalState;
|
|
131
142
|
protected inFlightLinkObservables: Trie<{
|
|
132
143
|
observable?: Observable<FetchResult<any>>;
|
|
133
144
|
}>;
|
|
134
145
|
private getObservableFromLink;
|
|
135
146
|
private getResultsFromLink;
|
|
136
|
-
fetchObservableWithInfo<TData, TVars extends OperationVariables>(
|
|
137
|
-
refetchQueries<TResult>({ updateCache, include, optimistic, removeOptimistic, onQueryUpdated, }: InternalRefetchQueriesOptions<ApolloCache
|
|
147
|
+
fetchObservableWithInfo<TData, TVars extends OperationVariables>(queryInfo: QueryInfo, options: WatchQueryOptions<TVars, TData>, networkStatus?: NetworkStatus, query?: DocumentNode | TypedDocumentNode<TData, TVars>, emitLoadingState?: boolean): ObservableAndInfo<TData>;
|
|
148
|
+
refetchQueries<TResult>({ updateCache, include, optimistic, removeOptimistic, onQueryUpdated, }: InternalRefetchQueriesOptions<ApolloCache, TResult>): InternalRefetchQueriesMap<TResult>;
|
|
138
149
|
private noCacheWarningsByQueryId;
|
|
139
150
|
maskOperation<TData = unknown>(options: MaskOperationOptions<TData>): MaybeMasked<TData>;
|
|
140
151
|
maskFragment<TData = unknown>(options: MaskFragmentOptions<TData>): TData;
|
|
141
152
|
private fetchQueryByPolicy;
|
|
142
|
-
|
|
153
|
+
getOrCreateQuery(queryId: string): QueryInfo;
|
|
143
154
|
private prepareContext;
|
|
144
155
|
}
|
|
145
156
|
export interface ObservableAndInfo<TData> {
|
package/core/QueryManager.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { Trie } from "@wry/trie";
|
|
2
|
-
import {
|
|
2
|
+
import { OperationTypeNode } from "graphql";
|
|
3
|
+
import { catchError, concat, EMPTY, filter, from, lastValueFrom, map, mergeMap, mergeWith, Observable, of, share, shareReplay, Subject, tap, } from "rxjs";
|
|
3
4
|
import { canonicalStringify } from "@apollo/client/cache";
|
|
4
|
-
import { CombinedGraphQLErrors, graphQLResultHasProtocolErrors,
|
|
5
|
+
import { CombinedGraphQLErrors, graphQLResultHasProtocolErrors, registerLinkError, toErrorLike, } from "@apollo/client/errors";
|
|
5
6
|
import { PROTOCOL_ERRORS_SYMBOL } from "@apollo/client/errors";
|
|
6
7
|
import { execute } from "@apollo/client/link/core";
|
|
7
8
|
import { maskFragment, maskOperation } from "@apollo/client/masking";
|
|
8
|
-
import { print } from "@apollo/client/utilities";
|
|
9
|
+
import { checkDocument, print } from "@apollo/client/utilities";
|
|
9
10
|
import { AutoCleanedWeakCache, cacheSizes } from "@apollo/client/utilities";
|
|
10
11
|
import { addNonReactiveToNamedFragments, hasDirectives, isExecutionPatchIncrementalResult, isExecutionPatchResult, isFullyUnmaskedOperation, removeDirectivesFromDocument, } from "@apollo/client/utilities";
|
|
11
12
|
import { DocumentTransform, getDefaultValues, getGraphQLErrorsFromResult, getOperationDefinition, getOperationName, graphQLResultHasError, hasClientExports, isDocumentNode, isNonEmptyArray, isNonNullObject, makeUniqueId, } from "@apollo/client/utilities";
|
|
12
13
|
import { mergeIncrementalData } from "@apollo/client/utilities";
|
|
13
14
|
import { __DEV__ } from "@apollo/client/utilities/environment";
|
|
14
|
-
import { onAnyEvent } from "@apollo/client/utilities/internal";
|
|
15
|
+
import { onAnyEvent, toQueryResult } from "@apollo/client/utilities/internal";
|
|
15
16
|
import { invariant, newInvariantError, } from "@apollo/client/utilities/invariant";
|
|
16
17
|
import { isNetworkRequestInFlight, NetworkStatus } from "./networkStatus.js";
|
|
17
18
|
import { logMissingFieldErrors, ObservableQuery } from "./ObservableQuery.js";
|
|
@@ -30,6 +31,17 @@ export class QueryManager {
|
|
|
30
31
|
queryDeduplication;
|
|
31
32
|
clientAwareness = {};
|
|
32
33
|
localState;
|
|
34
|
+
/**
|
|
35
|
+
* Whether to prioritize cache values over network results when
|
|
36
|
+
* `fetchObservableWithInfo` is called.
|
|
37
|
+
* This will essentially turn a `"network-only"` or `"cache-and-network"`
|
|
38
|
+
* fetchPolicy into a `"cache-first"` fetchPolicy, but without influencing
|
|
39
|
+
* the `fetchPolicy` of the `ObservableQuery`.
|
|
40
|
+
*
|
|
41
|
+
* This can e.g. be used to prioritize the cache during the first render after
|
|
42
|
+
* SSR.
|
|
43
|
+
*/
|
|
44
|
+
prioritizeCacheValues = false;
|
|
33
45
|
onBroadcast;
|
|
34
46
|
mutationStore;
|
|
35
47
|
// All the queries that the QueryManager is currently managing (not
|
|
@@ -77,15 +89,16 @@ export class QueryManager {
|
|
|
77
89
|
this.queries.forEach((_info, queryId) => {
|
|
78
90
|
this.removeQuery(queryId);
|
|
79
91
|
});
|
|
80
|
-
this.cancelPendingFetches(newInvariantError(
|
|
92
|
+
this.cancelPendingFetches(newInvariantError(74));
|
|
81
93
|
}
|
|
82
94
|
cancelPendingFetches(error) {
|
|
83
95
|
this.fetchCancelFns.forEach((cancel) => cancel(error));
|
|
84
96
|
this.fetchCancelFns.clear();
|
|
85
97
|
}
|
|
86
98
|
async mutate({ mutation, variables, optimisticResponse, updateQueries, refetchQueries = [], awaitRefetchQueries = false, update: updateWithProxyFn, onQueryUpdated, fetchPolicy = this.defaultOptions.mutate?.fetchPolicy || "network-only", errorPolicy = this.defaultOptions.mutate?.errorPolicy || "none", keepRootFields, context, }) {
|
|
87
|
-
invariant(mutation,
|
|
88
|
-
|
|
99
|
+
invariant(mutation, 75);
|
|
100
|
+
checkDocument(mutation, OperationTypeNode.MUTATION);
|
|
101
|
+
invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 76);
|
|
89
102
|
const mutationId = this.generateMutationId();
|
|
90
103
|
mutation = this.cache.transformForLink(this.transform(mutation));
|
|
91
104
|
const { hasClientExports } = this.getDocumentInfo(mutation);
|
|
@@ -118,9 +131,10 @@ export class QueryManager {
|
|
|
118
131
|
...context,
|
|
119
132
|
optimisticResponse: isOptimistic ? optimisticResponse : void 0,
|
|
120
133
|
}, variables, {}, false)
|
|
121
|
-
.pipe(mergeMap((result) => {
|
|
122
|
-
|
|
123
|
-
|
|
134
|
+
.pipe(validateDidEmitValue(), mergeMap((result) => {
|
|
135
|
+
const hasErrors = graphQLResultHasError(result);
|
|
136
|
+
if (hasErrors && errorPolicy === "none") {
|
|
137
|
+
throw new CombinedGraphQLErrors(result);
|
|
124
138
|
}
|
|
125
139
|
if (mutationStoreValue) {
|
|
126
140
|
mutationStoreValue.loading = false;
|
|
@@ -130,8 +144,7 @@ export class QueryManager {
|
|
|
130
144
|
if (typeof refetchQueries === "function") {
|
|
131
145
|
refetchQueries = refetchQueries(storeResult);
|
|
132
146
|
}
|
|
133
|
-
if (errorPolicy === "ignore" &&
|
|
134
|
-
graphQLResultHasError(storeResult)) {
|
|
147
|
+
if (errorPolicy === "ignore" && hasErrors) {
|
|
135
148
|
delete storeResult.errors;
|
|
136
149
|
}
|
|
137
150
|
return from(this.markMutationResult({
|
|
@@ -160,28 +173,39 @@ export class QueryManager {
|
|
|
160
173
|
// ExecutionPatchResult has arrived and we have assembled the
|
|
161
174
|
// multipart response into a single result.
|
|
162
175
|
if (!("hasNext" in storeResult) || storeResult.hasNext === false) {
|
|
163
|
-
|
|
164
|
-
...storeResult,
|
|
176
|
+
const result = {
|
|
165
177
|
data: this.maskOperation({
|
|
166
178
|
document: mutation,
|
|
167
179
|
data: storeResult.data,
|
|
168
180
|
fetchPolicy,
|
|
169
181
|
id: mutationId,
|
|
170
182
|
}),
|
|
171
|
-
}
|
|
183
|
+
};
|
|
184
|
+
if (graphQLResultHasError(storeResult)) {
|
|
185
|
+
result.error = new CombinedGraphQLErrors(storeResult);
|
|
186
|
+
}
|
|
187
|
+
if (storeResult.extensions) {
|
|
188
|
+
result.extensions = storeResult.extensions;
|
|
189
|
+
}
|
|
190
|
+
resolve(result);
|
|
172
191
|
}
|
|
173
192
|
},
|
|
174
|
-
error: (
|
|
175
|
-
err = maybeWrapError(err);
|
|
193
|
+
error: (error) => {
|
|
176
194
|
if (mutationStoreValue) {
|
|
177
195
|
mutationStoreValue.loading = false;
|
|
178
|
-
mutationStoreValue.error =
|
|
196
|
+
mutationStoreValue.error = error;
|
|
179
197
|
}
|
|
180
198
|
if (isOptimistic) {
|
|
181
199
|
this.cache.removeOptimistic(mutationId);
|
|
182
200
|
}
|
|
183
201
|
this.broadcastQueries();
|
|
184
|
-
|
|
202
|
+
if (errorPolicy === "ignore") {
|
|
203
|
+
return resolve({ data: undefined });
|
|
204
|
+
}
|
|
205
|
+
if (errorPolicy === "all") {
|
|
206
|
+
return resolve({ data: undefined, error });
|
|
207
|
+
}
|
|
208
|
+
reject(error);
|
|
185
209
|
},
|
|
186
210
|
});
|
|
187
211
|
});
|
|
@@ -371,7 +395,11 @@ export class QueryManager {
|
|
|
371
395
|
return true;
|
|
372
396
|
}
|
|
373
397
|
fetchQuery(queryId, options, networkStatus) {
|
|
374
|
-
return lastValueFrom(this.fetchObservableWithInfo(queryId, options, networkStatus).observable, {
|
|
398
|
+
return lastValueFrom(this.fetchObservableWithInfo(this.getOrCreateQuery(queryId), options, networkStatus).observable.pipe(map(toQueryResult)), {
|
|
399
|
+
// This default is needed when a `standby` fetch policy is used to avoid
|
|
400
|
+
// an EmptyError from rejecting this promise.
|
|
401
|
+
defaultValue: { data: undefined },
|
|
402
|
+
});
|
|
375
403
|
}
|
|
376
404
|
transform(document) {
|
|
377
405
|
return this.documentTransform.transformDocument(document);
|
|
@@ -417,12 +445,15 @@ export class QueryManager {
|
|
|
417
445
|
return transformCache.get(document);
|
|
418
446
|
}
|
|
419
447
|
getVariables(document, variables) {
|
|
448
|
+
const defaultVars = this.getDocumentInfo(document).defaultVars;
|
|
449
|
+
const varsWithDefaults = Object.entries(variables ?? {}).map(([key, value]) => [key, value === undefined ? defaultVars[key] : value]);
|
|
420
450
|
return {
|
|
421
|
-
...
|
|
422
|
-
...
|
|
451
|
+
...defaultVars,
|
|
452
|
+
...Object.fromEntries(varsWithDefaults),
|
|
423
453
|
};
|
|
424
454
|
}
|
|
425
455
|
watchQuery(options) {
|
|
456
|
+
checkDocument(options.query, OperationTypeNode.QUERY);
|
|
426
457
|
const query = this.transform(options.query);
|
|
427
458
|
// assign variable default values if supplied
|
|
428
459
|
// NOTE: We don't modify options.query here with the transformed query to
|
|
@@ -432,7 +463,7 @@ export class QueryManager {
|
|
|
432
463
|
variables: this.getVariables(query, options.variables),
|
|
433
464
|
};
|
|
434
465
|
if (typeof options.notifyOnNetworkStatusChange === "undefined") {
|
|
435
|
-
options.notifyOnNetworkStatusChange =
|
|
466
|
+
options.notifyOnNetworkStatusChange = true;
|
|
436
467
|
}
|
|
437
468
|
const queryInfo = new QueryInfo(this);
|
|
438
469
|
const observable = new ObservableQuery({
|
|
@@ -441,34 +472,30 @@ export class QueryManager {
|
|
|
441
472
|
options,
|
|
442
473
|
});
|
|
443
474
|
observable["lastQuery"] = query;
|
|
444
|
-
|
|
475
|
+
if (!ObservableQuery["inactiveOnCreation"].getValue()) {
|
|
476
|
+
this.queries.set(observable.queryId, queryInfo);
|
|
477
|
+
}
|
|
445
478
|
// We give queryInfo the transformed query to ensure the first cache diff
|
|
446
479
|
// uses the transformed query instead of the raw query
|
|
447
|
-
queryInfo.init({
|
|
448
|
-
|
|
449
|
-
observableQuery: observable,
|
|
450
|
-
variables: observable.variables,
|
|
451
|
-
});
|
|
480
|
+
queryInfo.init({ document: query, variables: observable.variables });
|
|
481
|
+
queryInfo.setObservableQuery(observable);
|
|
452
482
|
return observable;
|
|
453
483
|
}
|
|
454
|
-
// TODO: catch `EmptyError` and rethrow as network error if `complete`
|
|
455
|
-
// notification is emitted without a value.
|
|
456
484
|
query(options, queryId = this.generateQueryId()) {
|
|
457
|
-
invariant(options.query, 74);
|
|
458
|
-
invariant(options.query.kind === "Document", 75);
|
|
459
|
-
invariant(!options.returnPartialData, 76);
|
|
460
|
-
invariant(!options.pollInterval, 77);
|
|
461
485
|
const query = this.transform(options.query);
|
|
462
|
-
return this.fetchQuery(queryId, {
|
|
463
|
-
|
|
464
|
-
|
|
486
|
+
return this.fetchQuery(queryId, {
|
|
487
|
+
...options,
|
|
488
|
+
query,
|
|
489
|
+
})
|
|
490
|
+
.then((value) => ({
|
|
491
|
+
...value,
|
|
465
492
|
data: this.maskOperation({
|
|
466
493
|
document: query,
|
|
467
|
-
data:
|
|
494
|
+
data: value?.data,
|
|
468
495
|
fetchPolicy: options.fetchPolicy,
|
|
469
496
|
id: queryId,
|
|
470
497
|
}),
|
|
471
|
-
})
|
|
498
|
+
}))
|
|
472
499
|
.finally(() => this.stopQuery(queryId));
|
|
473
500
|
}
|
|
474
501
|
queryIdCounter = 1;
|
|
@@ -491,7 +518,7 @@ export class QueryManager {
|
|
|
491
518
|
// depend on values that previously existed in the data portion of the
|
|
492
519
|
// store. So, we cancel the promises and observers that we have issued
|
|
493
520
|
// so far and not yet resolved (in the case of queries).
|
|
494
|
-
this.cancelPendingFetches(newInvariantError(
|
|
521
|
+
this.cancelPendingFetches(newInvariantError(77));
|
|
495
522
|
this.queries.forEach((queryInfo) => {
|
|
496
523
|
if (queryInfo.observableQuery) {
|
|
497
524
|
// Set loading to true so listeners don't trigger unless they want
|
|
@@ -557,7 +584,7 @@ export class QueryManager {
|
|
|
557
584
|
// pre-allocate a new query ID here, using a special prefix to enable
|
|
558
585
|
// cleaning up these temporary queries later, after fetching.
|
|
559
586
|
const queryId = makeUniqueId("legacyOneTimeQuery");
|
|
560
|
-
const queryInfo = this.
|
|
587
|
+
const queryInfo = this.getOrCreateQuery(queryId).init({
|
|
561
588
|
document: options.query,
|
|
562
589
|
variables: options.variables,
|
|
563
590
|
});
|
|
@@ -579,10 +606,10 @@ export class QueryManager {
|
|
|
579
606
|
if (!included) {
|
|
580
607
|
const queryName = queryNames.get(nameOrQueryString);
|
|
581
608
|
if (queryName) {
|
|
582
|
-
__DEV__ && invariant.warn(
|
|
609
|
+
__DEV__ && invariant.warn(78, queryName);
|
|
583
610
|
}
|
|
584
611
|
else {
|
|
585
|
-
__DEV__ && invariant.warn(
|
|
612
|
+
__DEV__ && invariant.warn(79);
|
|
586
613
|
}
|
|
587
614
|
}
|
|
588
615
|
});
|
|
@@ -598,51 +625,59 @@ export class QueryManager {
|
|
|
598
625
|
(fetchPolicy !== "standby" && fetchPolicy !== "cache-only")) {
|
|
599
626
|
observableQueryPromises.push(observableQuery.refetch());
|
|
600
627
|
}
|
|
601
|
-
this.
|
|
628
|
+
(this.queries.get(queryId) || observableQuery["queryInfo"]).setDiff(null);
|
|
602
629
|
});
|
|
603
630
|
this.broadcastQueries();
|
|
604
631
|
return Promise.all(observableQueryPromises);
|
|
605
632
|
}
|
|
606
|
-
setObservableQuery(observableQuery) {
|
|
607
|
-
this.getQuery(observableQuery.queryId).setObservableQuery(observableQuery);
|
|
608
|
-
}
|
|
609
633
|
startGraphQLSubscription(options) {
|
|
610
634
|
let { query, variables } = options;
|
|
611
635
|
const { fetchPolicy, errorPolicy = "none", context = {}, extensions = {}, } = options;
|
|
636
|
+
checkDocument(query, OperationTypeNode.SUBSCRIPTION);
|
|
612
637
|
query = this.transform(query);
|
|
613
638
|
variables = this.getVariables(query, variables);
|
|
614
|
-
const makeObservable = (variables) => this.getObservableFromLink(query, context, variables, extensions).pipe(map((
|
|
639
|
+
const makeObservable = (variables) => this.getObservableFromLink(query, context, variables, extensions).pipe(map((rawResult) => {
|
|
615
640
|
if (fetchPolicy !== "no-cache") {
|
|
616
641
|
// the subscription interface should handle not sending us results we no longer subscribe to.
|
|
617
642
|
// XXX I don't think we ever send in an object with errors, but we might in the future...
|
|
618
|
-
if (shouldWriteResult(
|
|
643
|
+
if (shouldWriteResult(rawResult, errorPolicy)) {
|
|
619
644
|
this.cache.write({
|
|
620
645
|
query,
|
|
621
|
-
result:
|
|
646
|
+
result: rawResult.data,
|
|
622
647
|
dataId: "ROOT_SUBSCRIPTION",
|
|
623
648
|
variables: variables,
|
|
624
649
|
});
|
|
625
650
|
}
|
|
626
651
|
this.broadcastQueries();
|
|
627
652
|
}
|
|
628
|
-
const
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
653
|
+
const result = {
|
|
654
|
+
data: rawResult.data ?? undefined,
|
|
655
|
+
};
|
|
656
|
+
if (graphQLResultHasError(rawResult)) {
|
|
657
|
+
result.error = new CombinedGraphQLErrors(rawResult);
|
|
658
|
+
}
|
|
659
|
+
else if (graphQLResultHasProtocolErrors(rawResult)) {
|
|
660
|
+
result.error = rawResult.extensions[PROTOCOL_ERRORS_SYMBOL];
|
|
661
|
+
// Don't emit protocol errors added by HttpLink
|
|
662
|
+
delete rawResult.extensions[PROTOCOL_ERRORS_SYMBOL];
|
|
632
663
|
}
|
|
633
|
-
if (
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
664
|
+
if (rawResult.extensions &&
|
|
665
|
+
Object.keys(rawResult.extensions).length) {
|
|
666
|
+
result.extensions = rawResult.extensions;
|
|
667
|
+
}
|
|
668
|
+
if (result.error && errorPolicy === "none") {
|
|
669
|
+
result.data = undefined;
|
|
638
670
|
}
|
|
639
671
|
if (errorPolicy === "ignore") {
|
|
640
|
-
delete result.
|
|
672
|
+
delete result.error;
|
|
641
673
|
}
|
|
642
674
|
return result;
|
|
643
675
|
}), catchError((error) => {
|
|
644
|
-
|
|
645
|
-
|
|
676
|
+
if (errorPolicy === "ignore") {
|
|
677
|
+
return of({ data: undefined });
|
|
678
|
+
}
|
|
679
|
+
return of({ data: undefined, error });
|
|
680
|
+
}), filter((result) => !!(result.data || result.error)));
|
|
646
681
|
if (this.getDocumentInfo(query).hasClientExports) {
|
|
647
682
|
const observablePromise = this.localState
|
|
648
683
|
.addExportedVariables(query, variables, context)
|
|
@@ -667,14 +702,14 @@ export class QueryManager {
|
|
|
667
702
|
// The same queryId could have two rejection fns for two promises
|
|
668
703
|
this.fetchCancelFns.delete(queryId);
|
|
669
704
|
if (this.queries.has(queryId)) {
|
|
670
|
-
this.
|
|
705
|
+
this.queries.get(queryId)?.stop();
|
|
671
706
|
this.queries.delete(queryId);
|
|
672
707
|
}
|
|
673
708
|
}
|
|
674
709
|
broadcastQueries() {
|
|
675
710
|
if (this.onBroadcast)
|
|
676
711
|
this.onBroadcast();
|
|
677
|
-
this.queries.forEach((info) => info.notify());
|
|
712
|
+
this.queries.forEach((info) => info.observableQuery?.["notify"]());
|
|
678
713
|
}
|
|
679
714
|
getLocalState() {
|
|
680
715
|
return this.localState;
|
|
@@ -736,34 +771,30 @@ export class QueryManager {
|
|
|
736
771
|
}));
|
|
737
772
|
}));
|
|
738
773
|
}
|
|
739
|
-
return observable
|
|
774
|
+
return observable.pipe(catchError((error) => {
|
|
775
|
+
error = toErrorLike(error);
|
|
776
|
+
registerLinkError(error);
|
|
777
|
+
throw error;
|
|
778
|
+
}));
|
|
740
779
|
}
|
|
741
780
|
getResultsFromLink(queryInfo, cacheWriteBehavior, options) {
|
|
742
781
|
const requestId = (queryInfo.lastRequestId = this.generateRequestId());
|
|
782
|
+
const { errorPolicy } = options;
|
|
743
783
|
// Performing transformForLink here gives this.cache a chance to fill in
|
|
744
784
|
// missing fragment definitions (for example) before sending this document
|
|
745
785
|
// through the link chain.
|
|
746
786
|
const linkDocument = this.cache.transformForLink(options.query);
|
|
747
|
-
return this.getObservableFromLink(linkDocument, options.context, options.variables).pipe(
|
|
748
|
-
error = maybeWrapError(error);
|
|
749
|
-
// Avoid storing errors from older interrupted queries.
|
|
750
|
-
if (requestId >= queryInfo.lastRequestId) {
|
|
751
|
-
queryInfo.resetLastWrite();
|
|
752
|
-
queryInfo.reset();
|
|
753
|
-
}
|
|
754
|
-
throw error;
|
|
755
|
-
}), map((result) => {
|
|
787
|
+
return this.getObservableFromLink(linkDocument, options.context, options.variables).pipe(map((result) => {
|
|
756
788
|
const graphQLErrors = getGraphQLErrorsFromResult(result);
|
|
757
789
|
const hasErrors = graphQLErrors.length > 0;
|
|
758
|
-
const { errorPolicy } = options;
|
|
759
790
|
// If we interrupted this request by calling getResultsFromLink again
|
|
760
791
|
// with the same QueryInfo object, we ignore the old results.
|
|
761
792
|
if (requestId >= queryInfo.lastRequestId) {
|
|
762
793
|
if (hasErrors && errorPolicy === "none") {
|
|
763
794
|
queryInfo.resetLastWrite();
|
|
764
|
-
queryInfo.
|
|
795
|
+
queryInfo.observableQuery?.["resetNotifications"]();
|
|
765
796
|
// Throwing here effectively calls observer.error.
|
|
766
|
-
throw new CombinedGraphQLErrors(
|
|
797
|
+
throw new CombinedGraphQLErrors(result);
|
|
767
798
|
}
|
|
768
799
|
// Use linkDocument rather than queryInfo.document so the
|
|
769
800
|
// operation/fragments used to write the result are the same as the
|
|
@@ -784,21 +815,42 @@ export class QueryManager {
|
|
|
784
815
|
aqr.data = void 0;
|
|
785
816
|
}
|
|
786
817
|
if (hasErrors && errorPolicy !== "ignore") {
|
|
787
|
-
aqr.error = new CombinedGraphQLErrors(
|
|
818
|
+
aqr.error = new CombinedGraphQLErrors(result);
|
|
788
819
|
aqr.networkStatus = NetworkStatus.error;
|
|
789
820
|
}
|
|
790
821
|
return aqr;
|
|
822
|
+
}), catchError((error) => {
|
|
823
|
+
// Avoid storing errors from older interrupted queries.
|
|
824
|
+
if (requestId >= queryInfo.lastRequestId && errorPolicy === "none") {
|
|
825
|
+
queryInfo.resetLastWrite();
|
|
826
|
+
queryInfo.observableQuery?.["resetNotifications"]();
|
|
827
|
+
throw error;
|
|
828
|
+
}
|
|
829
|
+
const aqr = {
|
|
830
|
+
data: undefined,
|
|
831
|
+
loading: false,
|
|
832
|
+
networkStatus: NetworkStatus.ready,
|
|
833
|
+
partial: true,
|
|
834
|
+
};
|
|
835
|
+
if (errorPolicy !== "ignore") {
|
|
836
|
+
aqr.error = error;
|
|
837
|
+
aqr.networkStatus = NetworkStatus.error;
|
|
838
|
+
}
|
|
839
|
+
return of(aqr);
|
|
791
840
|
}));
|
|
792
841
|
}
|
|
793
|
-
fetchObservableWithInfo(
|
|
842
|
+
fetchObservableWithInfo(queryInfo, options,
|
|
794
843
|
// The initial networkStatus for this fetch, most often
|
|
795
844
|
// NetworkStatus.loading, but also possibly fetchMore, poll, refetch,
|
|
796
845
|
// or setVariables.
|
|
797
846
|
networkStatus = NetworkStatus.loading, query = options.query, emitLoadingState = false) {
|
|
798
847
|
const variables = this.getVariables(query, options.variables);
|
|
799
|
-
const queryInfo = this.getQuery(queryId);
|
|
800
848
|
const defaults = this.defaultOptions.watchQuery;
|
|
801
|
-
let { fetchPolicy = (defaults && defaults.fetchPolicy) || "cache-first", errorPolicy = (defaults && defaults.errorPolicy) || "none", returnPartialData = false, notifyOnNetworkStatusChange =
|
|
849
|
+
let { fetchPolicy = (defaults && defaults.fetchPolicy) || "cache-first", errorPolicy = (defaults && defaults.errorPolicy) || "none", returnPartialData = false, notifyOnNetworkStatusChange = true, context = {}, } = options;
|
|
850
|
+
if (this.prioritizeCacheValues &&
|
|
851
|
+
(fetchPolicy === "network-only" || fetchPolicy === "cache-and-network")) {
|
|
852
|
+
fetchPolicy = "cache-first";
|
|
853
|
+
}
|
|
802
854
|
const normalized = Object.assign({}, options, {
|
|
803
855
|
query,
|
|
804
856
|
variables,
|
|
@@ -826,13 +878,13 @@ export class QueryManager {
|
|
|
826
878
|
// This cancel function needs to be set before the concast is created,
|
|
827
879
|
// in case concast creation synchronously cancels the request.
|
|
828
880
|
const cleanupCancelFn = () => {
|
|
829
|
-
this.fetchCancelFns.delete(queryId);
|
|
881
|
+
this.fetchCancelFns.delete(queryInfo.queryId);
|
|
830
882
|
// We need to call `complete` on the subject here otherwise the merged
|
|
831
883
|
// observable will never complete since it waits for all source
|
|
832
884
|
// observables to complete before itself completes.
|
|
833
885
|
fetchCancelSubject.complete();
|
|
834
886
|
};
|
|
835
|
-
this.fetchCancelFns.set(queryId, (reason) => {
|
|
887
|
+
this.fetchCancelFns.set(queryInfo.queryId, (reason) => {
|
|
836
888
|
fetchCancelSubject.error(reason);
|
|
837
889
|
cleanupCancelFn();
|
|
838
890
|
});
|
|
@@ -870,7 +922,7 @@ export class QueryManager {
|
|
|
870
922
|
this.getObservableQueries(include).forEach((oq, queryId) => {
|
|
871
923
|
includedQueriesById.set(queryId, {
|
|
872
924
|
oq,
|
|
873
|
-
lastDiff: this.
|
|
925
|
+
lastDiff: (this.queries.get(queryId) || oq["queryInfo"]).getDiff(),
|
|
874
926
|
});
|
|
875
927
|
});
|
|
876
928
|
}
|
|
@@ -956,9 +1008,7 @@ export class QueryManager {
|
|
|
956
1008
|
// queries, even the QueryOptions ones.
|
|
957
1009
|
if (onQueryUpdated) {
|
|
958
1010
|
if (!diff) {
|
|
959
|
-
|
|
960
|
-
info.reset(); // Force info.getDiff() to read from cache.
|
|
961
|
-
diff = info.getDiff();
|
|
1011
|
+
diff = this.cache.diff(oq["queryInfo"]["getDiffOptions"]());
|
|
962
1012
|
}
|
|
963
1013
|
result = onQueryUpdated(oq, diff, lastDiff);
|
|
964
1014
|
}
|
|
@@ -998,7 +1048,7 @@ export class QueryManager {
|
|
|
998
1048
|
!isFullyUnmaskedOperation(document) &&
|
|
999
1049
|
!this.noCacheWarningsByQueryId.has(operationId)) {
|
|
1000
1050
|
this.noCacheWarningsByQueryId.add(operationId);
|
|
1001
|
-
__DEV__ && invariant.warn(
|
|
1051
|
+
__DEV__ && invariant.warn(80, getOperationName(document) ??
|
|
1002
1052
|
`Unnamed ${operationType ?? "operation"}`);
|
|
1003
1053
|
}
|
|
1004
1054
|
}
|
|
@@ -1088,7 +1138,7 @@ export class QueryManager {
|
|
|
1088
1138
|
context,
|
|
1089
1139
|
fetchPolicy,
|
|
1090
1140
|
errorPolicy,
|
|
1091
|
-
});
|
|
1141
|
+
}).pipe(validateDidEmitValue());
|
|
1092
1142
|
switch (fetchPolicy) {
|
|
1093
1143
|
default:
|
|
1094
1144
|
case "cache-first": {
|
|
@@ -1145,7 +1195,7 @@ export class QueryManager {
|
|
|
1145
1195
|
return { fromLink: false, observable: EMPTY };
|
|
1146
1196
|
}
|
|
1147
1197
|
}
|
|
1148
|
-
|
|
1198
|
+
getOrCreateQuery(queryId) {
|
|
1149
1199
|
if (queryId && !this.queries.has(queryId)) {
|
|
1150
1200
|
this.queries.set(queryId, new QueryInfo(this, queryId));
|
|
1151
1201
|
}
|
|
@@ -1160,21 +1210,15 @@ export class QueryManager {
|
|
|
1160
1210
|
};
|
|
1161
1211
|
}
|
|
1162
1212
|
}
|
|
1163
|
-
function
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
return error;
|
|
1174
|
-
}
|
|
1175
|
-
if (typeof error === "string") {
|
|
1176
|
-
return new Error(error, { cause: error });
|
|
1177
|
-
}
|
|
1178
|
-
return new UnconventionalError(error);
|
|
1213
|
+
function validateDidEmitValue() {
|
|
1214
|
+
let didEmitValue = false;
|
|
1215
|
+
return tap({
|
|
1216
|
+
next() {
|
|
1217
|
+
didEmitValue = true;
|
|
1218
|
+
},
|
|
1219
|
+
complete() {
|
|
1220
|
+
invariant(didEmitValue, 81);
|
|
1221
|
+
},
|
|
1222
|
+
});
|
|
1179
1223
|
}
|
|
1180
1224
|
//# sourceMappingURL=QueryManager.js.map
|