@apollo/client 4.0.0-alpha.1 → 4.0.0-alpha.11
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-grapes-call.md +5 -0
- package/.changeset/afraid-moons-arrive.md +5 -0
- package/.changeset/beige-mirrors-talk.md +15 -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/gentle-waves-cough.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/lucky-sheep-explain.md +34 -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/orange-suits-laugh.md +5 -0
- package/.changeset/perfect-ducks-reflect.md +12 -0
- package/.changeset/perfect-vans-give.md +7 -0
- package/.changeset/poor-eels-punch.md +5 -0
- package/.changeset/pre.json +70 -0
- package/.changeset/purple-bears-flash.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/seven-schools-carry.md +5 -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/small-poems-rest.md +5 -0
- package/.changeset/swift-rivers-share.md +13 -0
- package/.changeset/tall-bikes-develop.md +5 -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 +535 -0
- package/__cjs/cache/core/cache.cjs +2 -2
- package/__cjs/cache/core/cache.cjs.map +1 -1
- package/__cjs/cache/core/cache.d.cts +18 -18
- 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 +9 -8
- 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 +4 -12
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.d.cts +8 -9
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/policies.cjs +9 -9
- 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 +14 -56
- 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 +8 -8
- 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 +37 -21
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +37 -27
- package/__cjs/core/LocalState.cjs +2 -3
- package/__cjs/core/LocalState.cjs.map +1 -1
- package/__cjs/core/LocalState.d.cts +7 -8
- package/__cjs/core/ObservableQuery.cjs +267 -103
- 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 +173 -128
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +51 -32
- 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 +65 -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 +131 -138
- 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/batchHttpLink.cjs.map +1 -1
- package/__cjs/link/batch-http/batchHttpLink.d.cts +3 -2
- 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 +2 -3
- package/__cjs/link/core/ApolloLink.cjs +4 -22
- package/__cjs/link/core/ApolloLink.cjs.map +1 -1
- package/__cjs/link/core/ApolloLink.d.cts +3 -5
- 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 +15 -4
- 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/HttpLink.cjs.map +1 -1
- package/__cjs/link/http/HttpLink.d.cts +128 -3
- package/__cjs/link/http/checkFetcher.cjs +1 -1
- package/__cjs/link/http/createHttpLink.cjs +1 -1
- package/__cjs/link/http/createHttpLink.cjs.map +1 -1
- package/__cjs/link/http/createHttpLink.d.cts +3 -2
- package/__cjs/link/http/index.cjs.map +1 -1
- package/__cjs/link/http/index.d.cts +0 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
- package/__cjs/link/http/rewriteURIForGET.cjs.map +1 -1
- package/__cjs/link/http/rewriteURIForGET.d.cts +2 -2
- package/__cjs/link/http/selectHttpOptionsAndBody.cjs.map +1 -1
- package/__cjs/link/http/selectHttpOptionsAndBody.d.cts +7 -82
- 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/createOperation.cjs +5 -1
- package/__cjs/link/utils/createOperation.cjs.map +1 -1
- package/__cjs/link/utils/createOperation.d.cts +2 -2
- 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 +1 -1
- package/__cjs/react/context/ApolloConsumer.cjs.map +1 -1
- package/__cjs/react/context/ApolloConsumer.d.cts +7 -4
- package/__cjs/react/context/ApolloContext.cjs +1 -1
- package/__cjs/react/context/ApolloContext.cjs.map +1 -1
- package/__cjs/react/context/ApolloContext.d.cts +4 -4
- package/__cjs/react/context/ApolloProvider.cjs +1 -1
- package/__cjs/react/context/ApolloProvider.cjs.map +1 -1
- package/__cjs/react/context/ApolloProvider.d.cts +7 -5
- package/__cjs/react/hooks/internal/__use.d.cts +3 -1
- package/__cjs/react/hooks/internal/useIsomorphicLayoutEffect.d.cts +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 +2 -2
- package/__cjs/react/hooks/useApolloClient.cjs.map +1 -1
- package/__cjs/react/hooks/useApolloClient.d.cts +2 -2
- package/__cjs/react/hooks/useBackgroundQuery.cjs +2 -2
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +143 -46
- package/__cjs/react/hooks/useFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useFragment.d.cts +51 -26
- package/__cjs/react/hooks/useLazyQuery.cjs +31 -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 +21 -2
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +106 -34
- package/__cjs/react/hooks/useMutation.cjs +14 -21
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +231 -4
- package/__cjs/react/hooks/useQuery.cjs +87 -206
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +274 -4
- package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
- package/__cjs/react/hooks/useQueryRefHandlers.d.cts +23 -22
- package/__cjs/react/hooks/useReactiveVar.cjs.map +1 -1
- package/__cjs/react/hooks/useReactiveVar.d.cts +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 +9 -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.map +1 -1
- package/__cjs/react/hooks/useSuspenseFragment.d.cts +40 -38
- package/__cjs/react/hooks/useSuspenseQuery.cjs +7 -32
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +199 -38
- package/__cjs/react/hooks/useSyncExternalStore.cjs +1 -1
- package/__cjs/react/index.cjs +37 -11
- package/__cjs/react/index.cjs.map +1 -1
- package/__cjs/react/index.d.cts +22 -6
- package/__cjs/react/index.react-server.cjs +1 -5
- package/__cjs/react/index.react-server.cjs.map +1 -1
- package/__cjs/react/index.react-server.d.cts +0 -1
- 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 +17 -8
- package/__cjs/testing/internal/index.cjs.map +1 -1
- package/__cjs/testing/internal/index.d.cts +5 -3
- package/__cjs/testing/internal/link.cjs +16 -0
- package/__cjs/testing/internal/link.cjs.map +1 -0
- package/__cjs/testing/internal/link.d.cts +5 -0
- 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/isSameClient.cjs +19 -0
- package/__cjs/testing/matchers/isSameClient.cjs.map +1 -0
- package/__cjs/testing/matchers/isSameClient.d.cts +3 -0
- package/__cjs/testing/matchers/isSameObservableQuery.cjs +19 -0
- package/__cjs/testing/matchers/isSameObservableQuery.cjs.map +1 -0
- package/__cjs/testing/matchers/isSameObservableQuery.d.cts +3 -0
- 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 +32 -0
- package/__cjs/testing/matchers/toStrictEqualTyped.cjs.map +1 -0
- package/__cjs/testing/matchers/toStrictEqualTyped.d.cts +8 -0
- package/__cjs/testing/matchers/utils/getSerializableProperties.cjs +24 -0
- package/__cjs/testing/matchers/utils/getSerializableProperties.cjs.map +1 -0
- package/__cjs/testing/matchers/utils/getSerializableProperties.d.cts +4 -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/errorHandling.d.cts +1 -1
- 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/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/internal/getMemoryInternals.cjs +0 -2
- package/__cjs/utilities/internal/getMemoryInternals.cjs.map +1 -1
- package/__cjs/utilities/internal/getMemoryInternals.d.cts +1 -2
- package/__cjs/utilities/internal/index.cjs +3 -1
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +1 -0
- package/__cjs/utilities/internal/index.production.cjs +1 -0
- package/__cjs/utilities/internal/index.production.cjs.map +1 -1
- 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 +18 -18
- 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 +9 -8
- 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 +8 -9
- package/cache/inmemory/inMemoryCache.js +4 -12
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.d.ts +1 -1
- package/cache/inmemory/policies.js +9 -9
- 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 +14 -56
- 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 +8 -8
- 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 +37 -27
- package/core/ApolloClient.js +38 -22
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.d.ts +5 -6
- package/core/LocalState.js +2 -3
- package/core/LocalState.js.map +1 -1
- package/core/ObservableQuery.d.ts +156 -17
- package/core/ObservableQuery.js +266 -101
- 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 +38 -29
- package/core/QueryManager.js +176 -131
- 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 +65 -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 +131 -138
- 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/index.d.ts +2 -1
- package/link/batch/index.js +1 -1
- package/link/batch/index.js.map +1 -1
- package/link/batch-http/batchHttpLink.d.ts +3 -2
- package/link/batch-http/batchHttpLink.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 +2 -3
- package/link/context/index.js.map +1 -1
- package/link/core/ApolloLink.d.ts +3 -5
- package/link/core/ApolloLink.js +4 -22
- 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 +15 -4
- 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/HttpLink.d.ts +128 -3
- package/link/http/HttpLink.js.map +1 -1
- package/link/http/checkFetcher.js +1 -1
- package/link/http/createHttpLink.d.ts +2 -2
- package/link/http/createHttpLink.js +1 -1
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/index.d.ts +0 -1
- package/link/http/index.js.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js +1 -1
- package/link/http/rewriteURIForGET.d.ts +2 -2
- package/link/http/rewriteURIForGET.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.d.ts +7 -82
- package/link/http/selectHttpOptionsAndBody.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/createOperation.d.ts +2 -2
- package/link/utils/createOperation.js +5 -1
- package/link/utils/createOperation.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 +20 -40
- package/react/context/ApolloConsumer.d.ts +7 -4
- package/react/context/ApolloConsumer.js +1 -1
- package/react/context/ApolloConsumer.js.map +1 -1
- package/react/context/ApolloContext.d.ts +4 -4
- package/react/context/ApolloContext.js +1 -1
- package/react/context/ApolloContext.js.map +1 -1
- package/react/context/ApolloProvider.d.ts +7 -5
- package/react/context/ApolloProvider.js +1 -1
- package/react/context/ApolloProvider.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 +1 -1
- package/react/hooks/useApolloClient.js.map +1 -1
- package/react/hooks/useBackgroundQuery.d.ts +143 -46
- package/react/hooks/useBackgroundQuery.js +2 -2
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useFragment.d.ts +51 -26
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +278 -276
- package/react/hooks/useLazyQuery.js +30 -31
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +106 -34
- package/react/hooks/useLoadableQuery.js +21 -2
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +231 -4
- package/react/hooks/useMutation.js +14 -21
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +274 -4
- package/react/hooks/useQuery.js +86 -205
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.d.ts +23 -22
- package/react/hooks/useQueryRefHandlers.js.map +1 -1
- package/react/hooks/useReactiveVar.d.ts +1 -1
- package/react/hooks/useReactiveVar.js.map +1 -1
- package/react/hooks/useReadQuery.d.ts +27 -25
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +94 -9
- package/react/hooks/useSubscription.js +8 -56
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseFragment.d.ts +40 -38
- package/react/hooks/useSuspenseFragment.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +199 -38
- package/react/hooks/useSuspenseQuery.js +5 -26
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/index.d.ts +22 -6
- package/react/index.js +18 -3
- package/react/index.js.map +1 -1
- package/react/index.react-server.d.ts +0 -1
- package/react/index.react-server.js +0 -1
- package/react/index.react-server.js.map +1 -1
- 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 +5 -3
- package/testing/internal/index.js +5 -3
- package/testing/internal/index.js.map +1 -1
- package/testing/internal/link.d.ts +5 -0
- package/testing/internal/link.js +12 -0
- package/testing/internal/link.js.map +1 -0
- 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/isSameClient.d.ts +3 -0
- package/testing/matchers/isSameClient.js +15 -0
- package/testing/matchers/isSameClient.js.map +1 -0
- package/testing/matchers/isSameObservableQuery.d.ts +3 -0
- package/testing/matchers/isSameObservableQuery.js +15 -0
- package/testing/matchers/isSameObservableQuery.js.map +1 -0
- 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 +8 -0
- package/testing/matchers/toStrictEqualTyped.js +28 -0
- package/testing/matchers/toStrictEqualTyped.js.map +1 -0
- package/testing/matchers/utils/getSerializableProperties.d.ts +4 -0
- package/testing/matchers/utils/getSerializableProperties.js +21 -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/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/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/internal/getMemoryInternals.d.ts +0 -1
- package/utilities/internal/getMemoryInternals.js +0 -2
- package/utilities/internal/getMemoryInternals.js.map +1 -1
- package/utilities/internal/index.d.ts +1 -0
- package/utilities/internal/index.js +2 -1
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/index.production.js +1 -0
- package/utilities/internal/index.production.js.map +1 -1
- 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/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/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/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/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/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/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.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";
|
|
@@ -19,9 +20,8 @@ import { QueryInfo, shouldWriteResult, } from "./QueryInfo.js";
|
|
|
19
20
|
const { hasOwnProperty } = Object.prototype;
|
|
20
21
|
const IGNORE = {};
|
|
21
22
|
export class QueryManager {
|
|
22
|
-
cache;
|
|
23
|
-
link;
|
|
24
23
|
defaultOptions;
|
|
24
|
+
client;
|
|
25
25
|
assumeImmutableResults;
|
|
26
26
|
documentTransform;
|
|
27
27
|
ssrMode;
|
|
@@ -30,6 +30,17 @@ export class QueryManager {
|
|
|
30
30
|
queryDeduplication;
|
|
31
31
|
clientAwareness = {};
|
|
32
32
|
localState;
|
|
33
|
+
/**
|
|
34
|
+
* Whether to prioritize cache values over network results when
|
|
35
|
+
* `fetchObservableWithInfo` is called.
|
|
36
|
+
* This will essentially turn a `"network-only"` or `"cache-and-network"`
|
|
37
|
+
* fetchPolicy into a `"cache-first"` fetchPolicy, but without influencing
|
|
38
|
+
* the `fetchPolicy` of the `ObservableQuery`.
|
|
39
|
+
*
|
|
40
|
+
* This can e.g. be used to prioritize the cache during the first render after
|
|
41
|
+
* SSR.
|
|
42
|
+
*/
|
|
43
|
+
prioritizeCacheValues = false;
|
|
33
44
|
onBroadcast;
|
|
34
45
|
mutationStore;
|
|
35
46
|
// All the queries that the QueryManager is currently managing (not
|
|
@@ -44,8 +55,7 @@ export class QueryManager {
|
|
|
44
55
|
const defaultDocumentTransform = new DocumentTransform((document) => this.cache.transformDocument(document),
|
|
45
56
|
// Allow the apollo cache to manage its own transform caches
|
|
46
57
|
{ cache: false });
|
|
47
|
-
this.
|
|
48
|
-
this.link = options.link;
|
|
58
|
+
this.client = options.client;
|
|
49
59
|
this.defaultOptions = options.defaultOptions;
|
|
50
60
|
this.queryDeduplication = options.queryDeduplication;
|
|
51
61
|
this.clientAwareness = options.clientAwareness;
|
|
@@ -69,6 +79,12 @@ export class QueryManager {
|
|
|
69
79
|
this.mutationStore = {};
|
|
70
80
|
}
|
|
71
81
|
}
|
|
82
|
+
get link() {
|
|
83
|
+
return this.client.link;
|
|
84
|
+
}
|
|
85
|
+
get cache() {
|
|
86
|
+
return this.client.cache;
|
|
87
|
+
}
|
|
72
88
|
/**
|
|
73
89
|
* Call this method to terminate any active query processes, making it safe
|
|
74
90
|
* to dispose of this QueryManager instance.
|
|
@@ -77,15 +93,16 @@ export class QueryManager {
|
|
|
77
93
|
this.queries.forEach((_info, queryId) => {
|
|
78
94
|
this.removeQuery(queryId);
|
|
79
95
|
});
|
|
80
|
-
this.cancelPendingFetches(newInvariantError(
|
|
96
|
+
this.cancelPendingFetches(newInvariantError(74));
|
|
81
97
|
}
|
|
82
98
|
cancelPendingFetches(error) {
|
|
83
99
|
this.fetchCancelFns.forEach((cancel) => cancel(error));
|
|
84
100
|
this.fetchCancelFns.clear();
|
|
85
101
|
}
|
|
86
102
|
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
|
-
|
|
103
|
+
invariant(mutation, 75);
|
|
104
|
+
checkDocument(mutation, OperationTypeNode.MUTATION);
|
|
105
|
+
invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 76);
|
|
89
106
|
const mutationId = this.generateMutationId();
|
|
90
107
|
mutation = this.cache.transformForLink(this.transform(mutation));
|
|
91
108
|
const { hasClientExports } = this.getDocumentInfo(mutation);
|
|
@@ -118,9 +135,10 @@ export class QueryManager {
|
|
|
118
135
|
...context,
|
|
119
136
|
optimisticResponse: isOptimistic ? optimisticResponse : void 0,
|
|
120
137
|
}, variables, {}, false)
|
|
121
|
-
.pipe(mergeMap((result) => {
|
|
122
|
-
|
|
123
|
-
|
|
138
|
+
.pipe(validateDidEmitValue(), mergeMap((result) => {
|
|
139
|
+
const hasErrors = graphQLResultHasError(result);
|
|
140
|
+
if (hasErrors && errorPolicy === "none") {
|
|
141
|
+
throw new CombinedGraphQLErrors(result);
|
|
124
142
|
}
|
|
125
143
|
if (mutationStoreValue) {
|
|
126
144
|
mutationStoreValue.loading = false;
|
|
@@ -130,8 +148,7 @@ export class QueryManager {
|
|
|
130
148
|
if (typeof refetchQueries === "function") {
|
|
131
149
|
refetchQueries = refetchQueries(storeResult);
|
|
132
150
|
}
|
|
133
|
-
if (errorPolicy === "ignore" &&
|
|
134
|
-
graphQLResultHasError(storeResult)) {
|
|
151
|
+
if (errorPolicy === "ignore" && hasErrors) {
|
|
135
152
|
delete storeResult.errors;
|
|
136
153
|
}
|
|
137
154
|
return from(this.markMutationResult({
|
|
@@ -160,28 +177,39 @@ export class QueryManager {
|
|
|
160
177
|
// ExecutionPatchResult has arrived and we have assembled the
|
|
161
178
|
// multipart response into a single result.
|
|
162
179
|
if (!("hasNext" in storeResult) || storeResult.hasNext === false) {
|
|
163
|
-
|
|
164
|
-
...storeResult,
|
|
180
|
+
const result = {
|
|
165
181
|
data: this.maskOperation({
|
|
166
182
|
document: mutation,
|
|
167
183
|
data: storeResult.data,
|
|
168
184
|
fetchPolicy,
|
|
169
185
|
id: mutationId,
|
|
170
186
|
}),
|
|
171
|
-
}
|
|
187
|
+
};
|
|
188
|
+
if (graphQLResultHasError(storeResult)) {
|
|
189
|
+
result.error = new CombinedGraphQLErrors(storeResult);
|
|
190
|
+
}
|
|
191
|
+
if (storeResult.extensions) {
|
|
192
|
+
result.extensions = storeResult.extensions;
|
|
193
|
+
}
|
|
194
|
+
resolve(result);
|
|
172
195
|
}
|
|
173
196
|
},
|
|
174
|
-
error: (
|
|
175
|
-
err = maybeWrapError(err);
|
|
197
|
+
error: (error) => {
|
|
176
198
|
if (mutationStoreValue) {
|
|
177
199
|
mutationStoreValue.loading = false;
|
|
178
|
-
mutationStoreValue.error =
|
|
200
|
+
mutationStoreValue.error = error;
|
|
179
201
|
}
|
|
180
202
|
if (isOptimistic) {
|
|
181
203
|
this.cache.removeOptimistic(mutationId);
|
|
182
204
|
}
|
|
183
205
|
this.broadcastQueries();
|
|
184
|
-
|
|
206
|
+
if (errorPolicy === "ignore") {
|
|
207
|
+
return resolve({ data: undefined });
|
|
208
|
+
}
|
|
209
|
+
if (errorPolicy === "all") {
|
|
210
|
+
return resolve({ data: undefined, error });
|
|
211
|
+
}
|
|
212
|
+
reject(error);
|
|
185
213
|
},
|
|
186
214
|
});
|
|
187
215
|
});
|
|
@@ -371,7 +399,11 @@ export class QueryManager {
|
|
|
371
399
|
return true;
|
|
372
400
|
}
|
|
373
401
|
fetchQuery(queryId, options, networkStatus) {
|
|
374
|
-
return lastValueFrom(this.fetchObservableWithInfo(queryId, options, networkStatus).observable, {
|
|
402
|
+
return lastValueFrom(this.fetchObservableWithInfo(this.getOrCreateQuery(queryId), options, networkStatus).observable.pipe(map(toQueryResult)), {
|
|
403
|
+
// This default is needed when a `standby` fetch policy is used to avoid
|
|
404
|
+
// an EmptyError from rejecting this promise.
|
|
405
|
+
defaultValue: { data: undefined },
|
|
406
|
+
});
|
|
375
407
|
}
|
|
376
408
|
transform(document) {
|
|
377
409
|
return this.documentTransform.transformDocument(document);
|
|
@@ -417,12 +449,15 @@ export class QueryManager {
|
|
|
417
449
|
return transformCache.get(document);
|
|
418
450
|
}
|
|
419
451
|
getVariables(document, variables) {
|
|
452
|
+
const defaultVars = this.getDocumentInfo(document).defaultVars;
|
|
453
|
+
const varsWithDefaults = Object.entries(variables ?? {}).map(([key, value]) => [key, value === undefined ? defaultVars[key] : value]);
|
|
420
454
|
return {
|
|
421
|
-
...
|
|
422
|
-
...
|
|
455
|
+
...defaultVars,
|
|
456
|
+
...Object.fromEntries(varsWithDefaults),
|
|
423
457
|
};
|
|
424
458
|
}
|
|
425
459
|
watchQuery(options) {
|
|
460
|
+
checkDocument(options.query, OperationTypeNode.QUERY);
|
|
426
461
|
const query = this.transform(options.query);
|
|
427
462
|
// assign variable default values if supplied
|
|
428
463
|
// NOTE: We don't modify options.query here with the transformed query to
|
|
@@ -432,7 +467,7 @@ export class QueryManager {
|
|
|
432
467
|
variables: this.getVariables(query, options.variables),
|
|
433
468
|
};
|
|
434
469
|
if (typeof options.notifyOnNetworkStatusChange === "undefined") {
|
|
435
|
-
options.notifyOnNetworkStatusChange =
|
|
470
|
+
options.notifyOnNetworkStatusChange = true;
|
|
436
471
|
}
|
|
437
472
|
const queryInfo = new QueryInfo(this);
|
|
438
473
|
const observable = new ObservableQuery({
|
|
@@ -441,35 +476,31 @@ export class QueryManager {
|
|
|
441
476
|
options,
|
|
442
477
|
});
|
|
443
478
|
observable["lastQuery"] = query;
|
|
444
|
-
|
|
479
|
+
if (!ObservableQuery["inactiveOnCreation"].getValue()) {
|
|
480
|
+
this.queries.set(observable.queryId, queryInfo);
|
|
481
|
+
}
|
|
445
482
|
// We give queryInfo the transformed query to ensure the first cache diff
|
|
446
483
|
// uses the transformed query instead of the raw query
|
|
447
|
-
queryInfo.init({
|
|
448
|
-
|
|
449
|
-
observableQuery: observable,
|
|
450
|
-
variables: observable.variables,
|
|
451
|
-
});
|
|
484
|
+
queryInfo.init({ document: query, variables: observable.variables });
|
|
485
|
+
queryInfo.setObservableQuery(observable);
|
|
452
486
|
return observable;
|
|
453
487
|
}
|
|
454
|
-
// TODO: catch `EmptyError` and rethrow as network error if `complete`
|
|
455
|
-
// notification is emitted without a value.
|
|
456
488
|
query(options, queryId = this.generateQueryId()) {
|
|
457
|
-
invariant(options.query, 75);
|
|
458
|
-
invariant(options.query.kind === "Document", 76);
|
|
459
|
-
invariant(!options.returnPartialData, 77);
|
|
460
|
-
invariant(!options.pollInterval, 78);
|
|
461
489
|
const query = this.transform(options.query);
|
|
462
|
-
return this.fetchQuery(queryId, {
|
|
463
|
-
|
|
464
|
-
|
|
490
|
+
return this.fetchQuery(queryId, {
|
|
491
|
+
...options,
|
|
492
|
+
query,
|
|
493
|
+
})
|
|
494
|
+
.then((value) => ({
|
|
495
|
+
...value,
|
|
465
496
|
data: this.maskOperation({
|
|
466
497
|
document: query,
|
|
467
|
-
data:
|
|
498
|
+
data: value?.data,
|
|
468
499
|
fetchPolicy: options.fetchPolicy,
|
|
469
500
|
id: queryId,
|
|
470
501
|
}),
|
|
471
|
-
})
|
|
472
|
-
.finally(() => this.
|
|
502
|
+
}))
|
|
503
|
+
.finally(() => this.removeQuery(queryId));
|
|
473
504
|
}
|
|
474
505
|
queryIdCounter = 1;
|
|
475
506
|
generateQueryId() {
|
|
@@ -491,7 +522,7 @@ export class QueryManager {
|
|
|
491
522
|
// depend on values that previously existed in the data portion of the
|
|
492
523
|
// store. So, we cancel the promises and observers that we have issued
|
|
493
524
|
// so far and not yet resolved (in the case of queries).
|
|
494
|
-
this.cancelPendingFetches(newInvariantError(
|
|
525
|
+
this.cancelPendingFetches(newInvariantError(77));
|
|
495
526
|
this.queries.forEach((queryInfo) => {
|
|
496
527
|
if (queryInfo.observableQuery) {
|
|
497
528
|
// Set loading to true so listeners don't trigger unless they want
|
|
@@ -557,7 +588,7 @@ export class QueryManager {
|
|
|
557
588
|
// pre-allocate a new query ID here, using a special prefix to enable
|
|
558
589
|
// cleaning up these temporary queries later, after fetching.
|
|
559
590
|
const queryId = makeUniqueId("legacyOneTimeQuery");
|
|
560
|
-
const queryInfo = this.
|
|
591
|
+
const queryInfo = this.getOrCreateQuery(queryId).init({
|
|
561
592
|
document: options.query,
|
|
562
593
|
variables: options.variables,
|
|
563
594
|
});
|
|
@@ -579,10 +610,10 @@ export class QueryManager {
|
|
|
579
610
|
if (!included) {
|
|
580
611
|
const queryName = queryNames.get(nameOrQueryString);
|
|
581
612
|
if (queryName) {
|
|
582
|
-
__DEV__ && invariant.warn(
|
|
613
|
+
__DEV__ && invariant.warn(78, queryName);
|
|
583
614
|
}
|
|
584
615
|
else {
|
|
585
|
-
__DEV__ && invariant.warn(
|
|
616
|
+
__DEV__ && invariant.warn(79);
|
|
586
617
|
}
|
|
587
618
|
}
|
|
588
619
|
});
|
|
@@ -598,51 +629,59 @@ export class QueryManager {
|
|
|
598
629
|
(fetchPolicy !== "standby" && fetchPolicy !== "cache-only")) {
|
|
599
630
|
observableQueryPromises.push(observableQuery.refetch());
|
|
600
631
|
}
|
|
601
|
-
this.
|
|
632
|
+
(this.queries.get(queryId) || observableQuery["queryInfo"]).setDiff(null);
|
|
602
633
|
});
|
|
603
634
|
this.broadcastQueries();
|
|
604
635
|
return Promise.all(observableQueryPromises);
|
|
605
636
|
}
|
|
606
|
-
setObservableQuery(observableQuery) {
|
|
607
|
-
this.getQuery(observableQuery.queryId).setObservableQuery(observableQuery);
|
|
608
|
-
}
|
|
609
637
|
startGraphQLSubscription(options) {
|
|
610
638
|
let { query, variables } = options;
|
|
611
639
|
const { fetchPolicy, errorPolicy = "none", context = {}, extensions = {}, } = options;
|
|
640
|
+
checkDocument(query, OperationTypeNode.SUBSCRIPTION);
|
|
612
641
|
query = this.transform(query);
|
|
613
642
|
variables = this.getVariables(query, variables);
|
|
614
|
-
const makeObservable = (variables) => this.getObservableFromLink(query, context, variables, extensions).pipe(map((
|
|
643
|
+
const makeObservable = (variables) => this.getObservableFromLink(query, context, variables, extensions).pipe(map((rawResult) => {
|
|
615
644
|
if (fetchPolicy !== "no-cache") {
|
|
616
645
|
// the subscription interface should handle not sending us results we no longer subscribe to.
|
|
617
646
|
// XXX I don't think we ever send in an object with errors, but we might in the future...
|
|
618
|
-
if (shouldWriteResult(
|
|
647
|
+
if (shouldWriteResult(rawResult, errorPolicy)) {
|
|
619
648
|
this.cache.write({
|
|
620
649
|
query,
|
|
621
|
-
result:
|
|
650
|
+
result: rawResult.data,
|
|
622
651
|
dataId: "ROOT_SUBSCRIPTION",
|
|
623
652
|
variables: variables,
|
|
624
653
|
});
|
|
625
654
|
}
|
|
626
655
|
this.broadcastQueries();
|
|
627
656
|
}
|
|
628
|
-
const
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
657
|
+
const result = {
|
|
658
|
+
data: rawResult.data ?? undefined,
|
|
659
|
+
};
|
|
660
|
+
if (graphQLResultHasError(rawResult)) {
|
|
661
|
+
result.error = new CombinedGraphQLErrors(rawResult);
|
|
632
662
|
}
|
|
633
|
-
if (
|
|
634
|
-
|
|
635
|
-
//
|
|
636
|
-
|
|
637
|
-
|
|
663
|
+
else if (graphQLResultHasProtocolErrors(rawResult)) {
|
|
664
|
+
result.error = rawResult.extensions[PROTOCOL_ERRORS_SYMBOL];
|
|
665
|
+
// Don't emit protocol errors added by HttpLink
|
|
666
|
+
delete rawResult.extensions[PROTOCOL_ERRORS_SYMBOL];
|
|
667
|
+
}
|
|
668
|
+
if (rawResult.extensions &&
|
|
669
|
+
Object.keys(rawResult.extensions).length) {
|
|
670
|
+
result.extensions = rawResult.extensions;
|
|
671
|
+
}
|
|
672
|
+
if (result.error && errorPolicy === "none") {
|
|
673
|
+
result.data = undefined;
|
|
638
674
|
}
|
|
639
675
|
if (errorPolicy === "ignore") {
|
|
640
|
-
delete result.
|
|
676
|
+
delete result.error;
|
|
641
677
|
}
|
|
642
678
|
return result;
|
|
643
679
|
}), catchError((error) => {
|
|
644
|
-
|
|
645
|
-
|
|
680
|
+
if (errorPolicy === "ignore") {
|
|
681
|
+
return of({ data: undefined });
|
|
682
|
+
}
|
|
683
|
+
return of({ data: undefined, error });
|
|
684
|
+
}), filter((result) => !!(result.data || result.error)));
|
|
646
685
|
if (this.getDocumentInfo(query).hasClientExports) {
|
|
647
686
|
const observablePromise = this.localState
|
|
648
687
|
.addExportedVariables(query, variables, context)
|
|
@@ -655,10 +694,6 @@ export class QueryManager {
|
|
|
655
694
|
}
|
|
656
695
|
return makeObservable(variables);
|
|
657
696
|
}
|
|
658
|
-
stopQuery(queryId) {
|
|
659
|
-
this.removeQuery(queryId);
|
|
660
|
-
this.broadcastQueries();
|
|
661
|
-
}
|
|
662
697
|
removeQuery(queryId) {
|
|
663
698
|
// teardown all links
|
|
664
699
|
// Both `QueryManager.fetchRequest` and `QueryManager.query` create separate promises
|
|
@@ -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;
|
|
@@ -688,16 +723,25 @@ export class QueryManager {
|
|
|
688
723
|
this.queryDeduplication) {
|
|
689
724
|
let observable;
|
|
690
725
|
const { serverQuery, clientQuery } = this.getDocumentInfo(query);
|
|
726
|
+
const prepareContext = (context = {}) => {
|
|
727
|
+
const newContext = this.localState.prepareContext(context);
|
|
728
|
+
return {
|
|
729
|
+
...this.defaultContext,
|
|
730
|
+
...newContext,
|
|
731
|
+
queryDeduplication: deduplication,
|
|
732
|
+
clientAwareness: this.clientAwareness,
|
|
733
|
+
};
|
|
734
|
+
};
|
|
735
|
+
const executeContext = {
|
|
736
|
+
client: this.client,
|
|
737
|
+
};
|
|
691
738
|
if (serverQuery) {
|
|
692
739
|
const { inFlightLinkObservables, link } = this;
|
|
693
740
|
const operation = {
|
|
694
741
|
query: serverQuery,
|
|
695
742
|
variables,
|
|
696
743
|
operationName: getOperationName(serverQuery) || void 0,
|
|
697
|
-
context:
|
|
698
|
-
...context,
|
|
699
|
-
forceFetch: !deduplication,
|
|
700
|
-
}),
|
|
744
|
+
context: prepareContext(context),
|
|
701
745
|
extensions,
|
|
702
746
|
};
|
|
703
747
|
context = operation.context;
|
|
@@ -707,7 +751,7 @@ export class QueryManager {
|
|
|
707
751
|
const entry = inFlightLinkObservables.lookup(printedServerQuery, varJson);
|
|
708
752
|
observable = entry.observable;
|
|
709
753
|
if (!observable) {
|
|
710
|
-
observable = entry.observable = execute(link, operation).pipe(onAnyEvent((event) => {
|
|
754
|
+
observable = entry.observable = execute(link, operation, executeContext).pipe(onAnyEvent((event) => {
|
|
711
755
|
if ((event.type !== "next" ||
|
|
712
756
|
!("hasNext" in event.value) ||
|
|
713
757
|
!event.value.hasNext) &&
|
|
@@ -719,12 +763,12 @@ export class QueryManager {
|
|
|
719
763
|
}
|
|
720
764
|
}
|
|
721
765
|
else {
|
|
722
|
-
observable = execute(link, operation);
|
|
766
|
+
observable = execute(link, operation, executeContext);
|
|
723
767
|
}
|
|
724
768
|
}
|
|
725
769
|
else {
|
|
726
770
|
observable = of({ data: {} });
|
|
727
|
-
context =
|
|
771
|
+
context = prepareContext(context);
|
|
728
772
|
}
|
|
729
773
|
if (clientQuery) {
|
|
730
774
|
observable = observable.pipe(mergeMap((result) => {
|
|
@@ -736,34 +780,30 @@ export class QueryManager {
|
|
|
736
780
|
}));
|
|
737
781
|
}));
|
|
738
782
|
}
|
|
739
|
-
return observable
|
|
783
|
+
return observable.pipe(catchError((error) => {
|
|
784
|
+
error = toErrorLike(error);
|
|
785
|
+
registerLinkError(error);
|
|
786
|
+
throw error;
|
|
787
|
+
}));
|
|
740
788
|
}
|
|
741
789
|
getResultsFromLink(queryInfo, cacheWriteBehavior, options) {
|
|
742
790
|
const requestId = (queryInfo.lastRequestId = this.generateRequestId());
|
|
791
|
+
const { errorPolicy } = options;
|
|
743
792
|
// Performing transformForLink here gives this.cache a chance to fill in
|
|
744
793
|
// missing fragment definitions (for example) before sending this document
|
|
745
794
|
// through the link chain.
|
|
746
795
|
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) => {
|
|
796
|
+
return this.getObservableFromLink(linkDocument, options.context, options.variables).pipe(map((result) => {
|
|
756
797
|
const graphQLErrors = getGraphQLErrorsFromResult(result);
|
|
757
798
|
const hasErrors = graphQLErrors.length > 0;
|
|
758
|
-
const { errorPolicy } = options;
|
|
759
799
|
// If we interrupted this request by calling getResultsFromLink again
|
|
760
800
|
// with the same QueryInfo object, we ignore the old results.
|
|
761
801
|
if (requestId >= queryInfo.lastRequestId) {
|
|
762
802
|
if (hasErrors && errorPolicy === "none") {
|
|
763
803
|
queryInfo.resetLastWrite();
|
|
764
|
-
queryInfo.
|
|
804
|
+
queryInfo.observableQuery?.["resetNotifications"]();
|
|
765
805
|
// Throwing here effectively calls observer.error.
|
|
766
|
-
throw new CombinedGraphQLErrors(
|
|
806
|
+
throw new CombinedGraphQLErrors(result);
|
|
767
807
|
}
|
|
768
808
|
// Use linkDocument rather than queryInfo.document so the
|
|
769
809
|
// operation/fragments used to write the result are the same as the
|
|
@@ -784,21 +824,42 @@ export class QueryManager {
|
|
|
784
824
|
aqr.data = void 0;
|
|
785
825
|
}
|
|
786
826
|
if (hasErrors && errorPolicy !== "ignore") {
|
|
787
|
-
aqr.error = new CombinedGraphQLErrors(
|
|
827
|
+
aqr.error = new CombinedGraphQLErrors(result);
|
|
788
828
|
aqr.networkStatus = NetworkStatus.error;
|
|
789
829
|
}
|
|
790
830
|
return aqr;
|
|
831
|
+
}), catchError((error) => {
|
|
832
|
+
// Avoid storing errors from older interrupted queries.
|
|
833
|
+
if (requestId >= queryInfo.lastRequestId && errorPolicy === "none") {
|
|
834
|
+
queryInfo.resetLastWrite();
|
|
835
|
+
queryInfo.observableQuery?.["resetNotifications"]();
|
|
836
|
+
throw error;
|
|
837
|
+
}
|
|
838
|
+
const aqr = {
|
|
839
|
+
data: undefined,
|
|
840
|
+
loading: false,
|
|
841
|
+
networkStatus: NetworkStatus.ready,
|
|
842
|
+
partial: true,
|
|
843
|
+
};
|
|
844
|
+
if (errorPolicy !== "ignore") {
|
|
845
|
+
aqr.error = error;
|
|
846
|
+
aqr.networkStatus = NetworkStatus.error;
|
|
847
|
+
}
|
|
848
|
+
return of(aqr);
|
|
791
849
|
}));
|
|
792
850
|
}
|
|
793
|
-
fetchObservableWithInfo(
|
|
851
|
+
fetchObservableWithInfo(queryInfo, options,
|
|
794
852
|
// The initial networkStatus for this fetch, most often
|
|
795
853
|
// NetworkStatus.loading, but also possibly fetchMore, poll, refetch,
|
|
796
854
|
// or setVariables.
|
|
797
855
|
networkStatus = NetworkStatus.loading, query = options.query, emitLoadingState = false) {
|
|
798
856
|
const variables = this.getVariables(query, options.variables);
|
|
799
|
-
const queryInfo = this.getQuery(queryId);
|
|
800
857
|
const defaults = this.defaultOptions.watchQuery;
|
|
801
|
-
let { fetchPolicy = (defaults && defaults.fetchPolicy) || "cache-first", errorPolicy = (defaults && defaults.errorPolicy) || "none", returnPartialData = false, notifyOnNetworkStatusChange =
|
|
858
|
+
let { fetchPolicy = (defaults && defaults.fetchPolicy) || "cache-first", errorPolicy = (defaults && defaults.errorPolicy) || "none", returnPartialData = false, notifyOnNetworkStatusChange = true, context = {}, } = options;
|
|
859
|
+
if (this.prioritizeCacheValues &&
|
|
860
|
+
(fetchPolicy === "network-only" || fetchPolicy === "cache-and-network")) {
|
|
861
|
+
fetchPolicy = "cache-first";
|
|
862
|
+
}
|
|
802
863
|
const normalized = Object.assign({}, options, {
|
|
803
864
|
query,
|
|
804
865
|
variables,
|
|
@@ -826,13 +887,13 @@ export class QueryManager {
|
|
|
826
887
|
// This cancel function needs to be set before the concast is created,
|
|
827
888
|
// in case concast creation synchronously cancels the request.
|
|
828
889
|
const cleanupCancelFn = () => {
|
|
829
|
-
this.fetchCancelFns.delete(queryId);
|
|
890
|
+
this.fetchCancelFns.delete(queryInfo.queryId);
|
|
830
891
|
// We need to call `complete` on the subject here otherwise the merged
|
|
831
892
|
// observable will never complete since it waits for all source
|
|
832
893
|
// observables to complete before itself completes.
|
|
833
894
|
fetchCancelSubject.complete();
|
|
834
895
|
};
|
|
835
|
-
this.fetchCancelFns.set(queryId, (reason) => {
|
|
896
|
+
this.fetchCancelFns.set(queryInfo.queryId, (reason) => {
|
|
836
897
|
fetchCancelSubject.error(reason);
|
|
837
898
|
cleanupCancelFn();
|
|
838
899
|
});
|
|
@@ -870,7 +931,7 @@ export class QueryManager {
|
|
|
870
931
|
this.getObservableQueries(include).forEach((oq, queryId) => {
|
|
871
932
|
includedQueriesById.set(queryId, {
|
|
872
933
|
oq,
|
|
873
|
-
lastDiff: this.
|
|
934
|
+
lastDiff: (this.queries.get(queryId) || oq["queryInfo"]).getDiff(),
|
|
874
935
|
});
|
|
875
936
|
});
|
|
876
937
|
}
|
|
@@ -956,9 +1017,7 @@ export class QueryManager {
|
|
|
956
1017
|
// queries, even the QueryOptions ones.
|
|
957
1018
|
if (onQueryUpdated) {
|
|
958
1019
|
if (!diff) {
|
|
959
|
-
|
|
960
|
-
info.reset(); // Force info.getDiff() to read from cache.
|
|
961
|
-
diff = info.getDiff();
|
|
1020
|
+
diff = this.cache.diff(oq["queryInfo"]["getDiffOptions"]());
|
|
962
1021
|
}
|
|
963
1022
|
result = onQueryUpdated(oq, diff, lastDiff);
|
|
964
1023
|
}
|
|
@@ -998,7 +1057,7 @@ export class QueryManager {
|
|
|
998
1057
|
!isFullyUnmaskedOperation(document) &&
|
|
999
1058
|
!this.noCacheWarningsByQueryId.has(operationId)) {
|
|
1000
1059
|
this.noCacheWarningsByQueryId.add(operationId);
|
|
1001
|
-
__DEV__ && invariant.warn(
|
|
1060
|
+
__DEV__ && invariant.warn(80, getOperationName(document) ??
|
|
1002
1061
|
`Unnamed ${operationType ?? "operation"}`);
|
|
1003
1062
|
}
|
|
1004
1063
|
}
|
|
@@ -1088,7 +1147,7 @@ export class QueryManager {
|
|
|
1088
1147
|
context,
|
|
1089
1148
|
fetchPolicy,
|
|
1090
1149
|
errorPolicy,
|
|
1091
|
-
});
|
|
1150
|
+
}).pipe(validateDidEmitValue());
|
|
1092
1151
|
switch (fetchPolicy) {
|
|
1093
1152
|
default:
|
|
1094
1153
|
case "cache-first": {
|
|
@@ -1145,36 +1204,22 @@ export class QueryManager {
|
|
|
1145
1204
|
return { fromLink: false, observable: EMPTY };
|
|
1146
1205
|
}
|
|
1147
1206
|
}
|
|
1148
|
-
|
|
1207
|
+
getOrCreateQuery(queryId) {
|
|
1149
1208
|
if (queryId && !this.queries.has(queryId)) {
|
|
1150
1209
|
this.queries.set(queryId, new QueryInfo(this, queryId));
|
|
1151
1210
|
}
|
|
1152
1211
|
return this.queries.get(queryId);
|
|
1153
1212
|
}
|
|
1154
|
-
prepareContext(context = {}) {
|
|
1155
|
-
const newContext = this.localState.prepareContext(context);
|
|
1156
|
-
return {
|
|
1157
|
-
...this.defaultContext,
|
|
1158
|
-
...newContext,
|
|
1159
|
-
clientAwareness: this.clientAwareness,
|
|
1160
|
-
};
|
|
1161
|
-
}
|
|
1162
1213
|
}
|
|
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);
|
|
1214
|
+
function validateDidEmitValue() {
|
|
1215
|
+
let didEmitValue = false;
|
|
1216
|
+
return tap({
|
|
1217
|
+
next() {
|
|
1218
|
+
didEmitValue = true;
|
|
1219
|
+
},
|
|
1220
|
+
complete() {
|
|
1221
|
+
invariant(didEmitValue, 81);
|
|
1222
|
+
},
|
|
1223
|
+
});
|
|
1179
1224
|
}
|
|
1180
1225
|
//# sourceMappingURL=QueryManager.js.map
|