@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
|
@@ -5,17 +5,28 @@ const {
|
|
|
5
5
|
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.ObservableQuery = void 0;
|
|
8
|
-
exports.reobserveCacheFirst = reobserveCacheFirst;
|
|
9
8
|
exports.logMissingFieldErrors = logMissingFieldErrors;
|
|
10
9
|
const equality_1 = require("@wry/equality");
|
|
10
|
+
const optimism_1 = require("optimism");
|
|
11
11
|
const rxjs_1 = require("rxjs");
|
|
12
12
|
const utilities_1 = require("@apollo/client/utilities");
|
|
13
13
|
const environment_1 = require("@apollo/client/utilities/environment");
|
|
14
|
+
const internal_1 = require("@apollo/client/utilities/internal");
|
|
14
15
|
const invariant_1 = require("@apollo/client/utilities/invariant");
|
|
15
16
|
const equalByQuery_js_1 = require("./equalByQuery.cjs");
|
|
16
17
|
const networkStatus_js_1 = require("./networkStatus.cjs");
|
|
17
18
|
const { assign, hasOwnProperty } = Object;
|
|
19
|
+
const newNetworkStatusSymbol = Symbol();
|
|
20
|
+
const uninitialized = {};
|
|
18
21
|
class ObservableQuery {
|
|
22
|
+
/**
|
|
23
|
+
* @internal
|
|
24
|
+
* A slot used by the `useQuery` hook to indicate that `client.watchQuery`
|
|
25
|
+
* should not register the query immediately, but instead wait for the query to
|
|
26
|
+
* be started registered with the `QueryManager` when `useSyncExternalStore`
|
|
27
|
+
* actively subscribes to it.
|
|
28
|
+
*/
|
|
29
|
+
static inactiveOnCreation = new optimism_1.Slot();
|
|
19
30
|
options;
|
|
20
31
|
queryId;
|
|
21
32
|
queryName;
|
|
@@ -24,10 +35,8 @@ class ObservableQuery {
|
|
|
24
35
|
// untransformed query to ensure document transforms with runtime conditionals
|
|
25
36
|
// are run on the original document.
|
|
26
37
|
get query() {
|
|
27
|
-
return this.lastQuery
|
|
38
|
+
return this.lastQuery;
|
|
28
39
|
}
|
|
29
|
-
// Computed shorthand for this.options.variables, preserved for
|
|
30
|
-
// backwards compatibility.
|
|
31
40
|
/**
|
|
32
41
|
* An object containing the variables that were provided for the query.
|
|
33
42
|
*/
|
|
@@ -36,7 +45,6 @@ class ObservableQuery {
|
|
|
36
45
|
}
|
|
37
46
|
subject;
|
|
38
47
|
observable;
|
|
39
|
-
initialResult;
|
|
40
48
|
isTornDown;
|
|
41
49
|
queryManager;
|
|
42
50
|
subscriptions = new Set();
|
|
@@ -50,16 +58,31 @@ class ObservableQuery {
|
|
|
50
58
|
networkStatus;
|
|
51
59
|
constructor({ queryManager, queryInfo, options, }) {
|
|
52
60
|
this.networkStatus = networkStatus_js_1.NetworkStatus.loading;
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
loading: true,
|
|
56
|
-
networkStatus: this.networkStatus,
|
|
57
|
-
partial: true,
|
|
58
|
-
};
|
|
59
|
-
this.subject = new rxjs_1.BehaviorSubject(this.initialResult);
|
|
61
|
+
let startedInactive = ObservableQuery.inactiveOnCreation.getValue();
|
|
62
|
+
this.subject = new rxjs_1.BehaviorSubject(uninitialized);
|
|
60
63
|
this.observable = this.subject.pipe((0, rxjs_1.tap)({
|
|
61
64
|
subscribe: () => {
|
|
65
|
+
if (startedInactive) {
|
|
66
|
+
queryManager["queries"].set(this.queryId, queryInfo);
|
|
67
|
+
startedInactive = false;
|
|
68
|
+
}
|
|
62
69
|
if (!this.subject.observed) {
|
|
70
|
+
if (this.subject.value === uninitialized) {
|
|
71
|
+
// Emitting a value in the `subscribe` callback of `tap` gives
|
|
72
|
+
// the subject a chance to save this initial result without
|
|
73
|
+
// emitting the placeholder value since this callback is executed
|
|
74
|
+
// before `tap` subscribes to the source observable (the subject).
|
|
75
|
+
// `reobserve` also has the chance to update this value if it
|
|
76
|
+
// synchronously emits one (usually due to reporting a cache
|
|
77
|
+
// value).
|
|
78
|
+
//
|
|
79
|
+
// We don't initialize the `BehaviorSubject` with
|
|
80
|
+
// `getInitialResult` because its possible the cache might have
|
|
81
|
+
// updated between when the `ObservableQuery` was instantiated and
|
|
82
|
+
// when it is subscribed to. Updating the value here ensures we
|
|
83
|
+
// report the most up-to-date result from the cache.
|
|
84
|
+
this.subject.next(this.getInitialResult());
|
|
85
|
+
}
|
|
63
86
|
this.reobserve();
|
|
64
87
|
// TODO: See if we can rework updatePolling to better handle this.
|
|
65
88
|
// reobserve calls updatePolling but this `subscribe` callback is
|
|
@@ -74,18 +97,14 @@ class ObservableQuery {
|
|
|
74
97
|
this.tearDownQuery();
|
|
75
98
|
}
|
|
76
99
|
},
|
|
77
|
-
}),
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
// TODO: Remove this behavior when unifying loading state for notifyOnNetworkStatusChange
|
|
86
|
-
(this.options.fetchPolicy === "network-only" &&
|
|
87
|
-
this.queryInfo.getDiff().complete) ||
|
|
88
|
-
result !== this.initialResult));
|
|
100
|
+
}), (0, rxjs_1.filter)((result) => {
|
|
101
|
+
return (this.options.fetchPolicy !== "standby" &&
|
|
102
|
+
(this.options.notifyOnNetworkStatusChange ||
|
|
103
|
+
!result.loading ||
|
|
104
|
+
// data could be defined for cache-and-network fetch policies
|
|
105
|
+
// when emitting the cache result while loading the network result
|
|
106
|
+
!!result.data));
|
|
107
|
+
}));
|
|
89
108
|
this["@@observable"] = () => this;
|
|
90
109
|
if (Symbol.observable) {
|
|
91
110
|
this[Symbol.observable] = () => this;
|
|
@@ -105,6 +124,7 @@ class ObservableQuery {
|
|
|
105
124
|
const { fetchPolicy = defaultFetchPolicy,
|
|
106
125
|
// Make sure we don't store "standby" as the initialFetchPolicy.
|
|
107
126
|
initialFetchPolicy = fetchPolicy === "standby" ? defaultFetchPolicy : (fetchPolicy), } = options;
|
|
127
|
+
this.lastQuery = options.query;
|
|
108
128
|
this.options = {
|
|
109
129
|
...options,
|
|
110
130
|
// Remember the initial options.fetchPolicy so we can revert back to this
|
|
@@ -114,6 +134,7 @@ class ObservableQuery {
|
|
|
114
134
|
// This ensures this.options.fetchPolicy always has a string value, in
|
|
115
135
|
// case options.fetchPolicy was not provided.
|
|
116
136
|
fetchPolicy,
|
|
137
|
+
variables: this.getVariablesWithDefaults(options.variables),
|
|
117
138
|
};
|
|
118
139
|
this.queryId = queryInfo.queryId || queryManager.generateQueryId();
|
|
119
140
|
const opDef = (0, utilities_1.getOperationDefinition)(this.query);
|
|
@@ -130,6 +151,50 @@ class ObservableQuery {
|
|
|
130
151
|
resetDiff() {
|
|
131
152
|
this.queryInfo.resetDiff();
|
|
132
153
|
}
|
|
154
|
+
getInitialResult() {
|
|
155
|
+
const fetchPolicy = this.queryManager.prioritizeCacheValues ?
|
|
156
|
+
"cache-first"
|
|
157
|
+
: this.options.fetchPolicy;
|
|
158
|
+
const defaultResult = {
|
|
159
|
+
data: undefined,
|
|
160
|
+
loading: true,
|
|
161
|
+
networkStatus: networkStatus_js_1.NetworkStatus.loading,
|
|
162
|
+
partial: true,
|
|
163
|
+
};
|
|
164
|
+
const cacheResult = () => {
|
|
165
|
+
const diff = this.queryInfo.getDiff();
|
|
166
|
+
return this.maskResult({
|
|
167
|
+
data:
|
|
168
|
+
// TODO: queryInfo.getDiff should handle this since cache.diff returns a
|
|
169
|
+
// null when returnPartialData is false
|
|
170
|
+
this.options.returnPartialData || diff.complete ?
|
|
171
|
+
diff.result ?? undefined
|
|
172
|
+
: undefined,
|
|
173
|
+
loading: !diff.complete,
|
|
174
|
+
networkStatus: diff.complete ? networkStatus_js_1.NetworkStatus.ready : networkStatus_js_1.NetworkStatus.loading,
|
|
175
|
+
partial: !diff.complete,
|
|
176
|
+
});
|
|
177
|
+
};
|
|
178
|
+
switch (fetchPolicy) {
|
|
179
|
+
case "cache-only":
|
|
180
|
+
case "cache-first":
|
|
181
|
+
return cacheResult();
|
|
182
|
+
case "cache-and-network":
|
|
183
|
+
return {
|
|
184
|
+
...cacheResult(),
|
|
185
|
+
loading: true,
|
|
186
|
+
networkStatus: networkStatus_js_1.NetworkStatus.loading,
|
|
187
|
+
};
|
|
188
|
+
case "standby":
|
|
189
|
+
return {
|
|
190
|
+
...defaultResult,
|
|
191
|
+
loading: false,
|
|
192
|
+
networkStatus: networkStatus_js_1.NetworkStatus.ready,
|
|
193
|
+
};
|
|
194
|
+
default:
|
|
195
|
+
return defaultResult;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
133
198
|
getCurrentFullResult(saveAsLastResult = true) {
|
|
134
199
|
// Use the last result as long as the variables match this.variables.
|
|
135
200
|
const lastResult = this.getLastResult(true);
|
|
@@ -141,7 +206,11 @@ class ObservableQuery {
|
|
|
141
206
|
loading: (0, networkStatus_js_1.isNetworkRequestInFlight)(networkStatus),
|
|
142
207
|
networkStatus,
|
|
143
208
|
};
|
|
144
|
-
|
|
209
|
+
let { fetchPolicy = "cache-first" } = this.options;
|
|
210
|
+
const { prioritizeCacheValues } = this.queryManager;
|
|
211
|
+
if (prioritizeCacheValues) {
|
|
212
|
+
fetchPolicy = "cache-first";
|
|
213
|
+
}
|
|
145
214
|
if (
|
|
146
215
|
// These fetch policies should never deliver data from the cache, unless
|
|
147
216
|
// redelivering a previously delivered result.
|
|
@@ -153,7 +222,7 @@ class ObservableQuery {
|
|
|
153
222
|
this.queryManager.getDocumentInfo(this.query).hasForcedResolvers) {
|
|
154
223
|
// Fall through.
|
|
155
224
|
}
|
|
156
|
-
else if (this.waitForOwnResult) {
|
|
225
|
+
else if (this.waitForOwnResult && !prioritizeCacheValues) {
|
|
157
226
|
// This would usually be a part of `QueryInfo.getDiff()`.
|
|
158
227
|
// which we skip in the waitForOwnResult case since we are not
|
|
159
228
|
// interested in the diff.
|
|
@@ -265,18 +334,19 @@ class ObservableQuery {
|
|
|
265
334
|
const queryDef = (0, utilities_1.getQueryDefinition)(this.query);
|
|
266
335
|
const vars = queryDef.variableDefinitions;
|
|
267
336
|
if (!vars || !vars.some((v) => v.variable.name.value === "variables")) {
|
|
268
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
337
|
+
__DEV__ && invariant_1.invariant.warn(69, variables, queryDef.name?.value || queryDef);
|
|
269
338
|
}
|
|
270
339
|
}
|
|
271
|
-
if (variables && !(0, equality_1.equal)(this.
|
|
340
|
+
if (variables && !(0, equality_1.equal)(this.variables, variables)) {
|
|
272
341
|
// Update the existing options with new variables
|
|
273
|
-
reobserveOptions.variables = this.options.variables =
|
|
274
|
-
...this.
|
|
275
|
-
...variables,
|
|
276
|
-
};
|
|
342
|
+
reobserveOptions.variables = this.options.variables =
|
|
343
|
+
this.getVariablesWithDefaults({ ...this.variables, ...variables });
|
|
277
344
|
}
|
|
278
345
|
this.queryInfo.resetLastWrite();
|
|
279
|
-
return this.reobserve(
|
|
346
|
+
return this.reobserve({
|
|
347
|
+
...reobserveOptions,
|
|
348
|
+
[newNetworkStatusSymbol]: networkStatus_js_1.NetworkStatus.refetch,
|
|
349
|
+
});
|
|
280
350
|
}
|
|
281
351
|
/**
|
|
282
352
|
* A function that helps you fetch the next set of results for a [paginated list field](https://www.apollographql.com/docs/react/pagination/core-api/).
|
|
@@ -288,7 +358,7 @@ class ObservableQuery {
|
|
|
288
358
|
query: this.options.query,
|
|
289
359
|
...fetchMoreOptions,
|
|
290
360
|
variables: {
|
|
291
|
-
...this.
|
|
361
|
+
...this.variables,
|
|
292
362
|
...fetchMoreOptions.variables,
|
|
293
363
|
},
|
|
294
364
|
})),
|
|
@@ -298,6 +368,7 @@ class ObservableQuery {
|
|
|
298
368
|
// fetchMore to provide an updateQuery callback that determines how
|
|
299
369
|
// the data gets written to the cache.
|
|
300
370
|
fetchPolicy: "no-cache",
|
|
371
|
+
notifyOnNetworkStatusChange: this.options.notifyOnNetworkStatusChange,
|
|
301
372
|
};
|
|
302
373
|
combinedOptions.query = this.transformDocument(combinedOptions.query);
|
|
303
374
|
const qid = this.queryManager.generateQueryId();
|
|
@@ -321,7 +392,7 @@ class ObservableQuery {
|
|
|
321
392
|
const updateQuery = fetchMoreOptions?.updateQuery;
|
|
322
393
|
const isCached = this.options.fetchPolicy !== "no-cache";
|
|
323
394
|
if (!isCached) {
|
|
324
|
-
(0, invariant_1.invariant)(updateQuery,
|
|
395
|
+
(0, invariant_1.invariant)(updateQuery, 70);
|
|
325
396
|
}
|
|
326
397
|
return this.queryManager
|
|
327
398
|
.fetchQuery(qid, combinedOptions, networkStatus_js_1.NetworkStatus.fetchMore)
|
|
@@ -406,7 +477,7 @@ class ObservableQuery {
|
|
|
406
477
|
// the cache, we still want fetchMore to deliver its final loading:false
|
|
407
478
|
// result with the unchanged data.
|
|
408
479
|
if (isCached && !updatedQuerySet.has(this.query)) {
|
|
409
|
-
reobserveCacheFirst(
|
|
480
|
+
this.reobserveCacheFirst();
|
|
410
481
|
}
|
|
411
482
|
});
|
|
412
483
|
}
|
|
@@ -427,7 +498,17 @@ class ObservableQuery {
|
|
|
427
498
|
})
|
|
428
499
|
.subscribe({
|
|
429
500
|
next: (subscriptionData) => {
|
|
430
|
-
const { updateQuery } = options;
|
|
501
|
+
const { updateQuery, onError } = options;
|
|
502
|
+
const { error } = subscriptionData;
|
|
503
|
+
if (error) {
|
|
504
|
+
if (onError) {
|
|
505
|
+
onError(error);
|
|
506
|
+
}
|
|
507
|
+
else {
|
|
508
|
+
__DEV__ && invariant_1.invariant.error(71, error);
|
|
509
|
+
}
|
|
510
|
+
return;
|
|
511
|
+
}
|
|
431
512
|
if (updateQuery) {
|
|
432
513
|
this.updateQuery((previous, updateOptions) => updateQuery(previous, {
|
|
433
514
|
subscriptionData: subscriptionData,
|
|
@@ -435,13 +516,6 @@ class ObservableQuery {
|
|
|
435
516
|
}));
|
|
436
517
|
}
|
|
437
518
|
},
|
|
438
|
-
error: (err) => {
|
|
439
|
-
if (options.onError) {
|
|
440
|
-
options.onError(err);
|
|
441
|
-
return;
|
|
442
|
-
}
|
|
443
|
-
__DEV__ && invariant_1.invariant.error(69, err);
|
|
444
|
-
},
|
|
445
519
|
});
|
|
446
520
|
this.subscriptions.add(subscription);
|
|
447
521
|
return () => {
|
|
@@ -450,9 +524,7 @@ class ObservableQuery {
|
|
|
450
524
|
}
|
|
451
525
|
};
|
|
452
526
|
}
|
|
453
|
-
|
|
454
|
-
return this.reobserve(newOptions);
|
|
455
|
-
}
|
|
527
|
+
/** @internal */
|
|
456
528
|
silentSetOptions(newOptions) {
|
|
457
529
|
const mergedOptions = (0, utilities_1.compact)(this.options, newOptions || {});
|
|
458
530
|
assign(this.options, mergedOptions);
|
|
@@ -476,22 +548,24 @@ class ObservableQuery {
|
|
|
476
548
|
* the previous values of those variables will be used.
|
|
477
549
|
*/
|
|
478
550
|
async setVariables(variables) {
|
|
551
|
+
variables = this.getVariablesWithDefaults(variables);
|
|
479
552
|
if ((0, equality_1.equal)(this.variables, variables)) {
|
|
480
553
|
// If we have no observers, then we don't actually want to make a network
|
|
481
554
|
// request. As soon as someone observes the query, the request will kick
|
|
482
555
|
// off. For now, we just store any changes. (See #1077)
|
|
483
|
-
return this.subject.getValue();
|
|
556
|
+
return (0, internal_1.toQueryResult)(this.subject.getValue());
|
|
484
557
|
}
|
|
485
558
|
this.options.variables = variables;
|
|
486
559
|
// See comment above
|
|
487
560
|
if (!this.hasObservers()) {
|
|
488
|
-
return this.subject.getValue();
|
|
561
|
+
return (0, internal_1.toQueryResult)(this.subject.getValue());
|
|
489
562
|
}
|
|
490
563
|
return this.reobserve({
|
|
491
564
|
// Reset options.fetchPolicy to its original value.
|
|
492
565
|
fetchPolicy: this.options.initialFetchPolicy,
|
|
493
566
|
variables,
|
|
494
|
-
|
|
567
|
+
[newNetworkStatusSymbol]: networkStatus_js_1.NetworkStatus.setVariables,
|
|
568
|
+
});
|
|
495
569
|
}
|
|
496
570
|
/**
|
|
497
571
|
* A function that enables you to update the query's cached result without executing a followup GraphQL operation.
|
|
@@ -556,13 +630,8 @@ class ObservableQuery {
|
|
|
556
630
|
// requests to be triggered only if the cache result is incomplete. To
|
|
557
631
|
// that end, the options.nextFetchPolicy option provides an easy way to
|
|
558
632
|
// update options.fetchPolicy after the initial network request, without
|
|
559
|
-
// having to call observableQuery.
|
|
560
|
-
options.fetchPolicy = options.nextFetchPolicy(fetchPolicy, {
|
|
561
|
-
reason,
|
|
562
|
-
options,
|
|
563
|
-
observable: this,
|
|
564
|
-
initialFetchPolicy,
|
|
565
|
-
});
|
|
633
|
+
// having to call observableQuery.reobserve.
|
|
634
|
+
options.fetchPolicy = options.nextFetchPolicy.call(options, fetchPolicy, { reason, options, observable: this, initialFetchPolicy });
|
|
566
635
|
}
|
|
567
636
|
else if (reason === "variables-changed") {
|
|
568
637
|
options.fetchPolicy = initialFetchPolicy;
|
|
@@ -576,8 +645,9 @@ class ObservableQuery {
|
|
|
576
645
|
fetch(options, newNetworkStatus, emitLoadingState, query) {
|
|
577
646
|
// TODO Make sure we update the networkStatus (and infer fetchVariables)
|
|
578
647
|
// before actually committing to the fetch.
|
|
579
|
-
this.queryManager.
|
|
580
|
-
|
|
648
|
+
const queryInfo = this.queryManager.getOrCreateQuery(this.queryId);
|
|
649
|
+
queryInfo.setObservableQuery(this);
|
|
650
|
+
return this.queryManager.fetchObservableWithInfo(queryInfo, options, newNetworkStatus, query, emitLoadingState);
|
|
581
651
|
}
|
|
582
652
|
// Turns polling on or off based on this.options.pollInterval.
|
|
583
653
|
updatePolling() {
|
|
@@ -587,16 +657,13 @@ class ObservableQuery {
|
|
|
587
657
|
}
|
|
588
658
|
const { pollingInfo, options: { pollInterval }, } = this;
|
|
589
659
|
if (!pollInterval || !this.hasObservers()) {
|
|
590
|
-
|
|
591
|
-
clearTimeout(pollingInfo.timeout);
|
|
592
|
-
delete this.pollingInfo;
|
|
593
|
-
}
|
|
660
|
+
this.cancelPolling();
|
|
594
661
|
return;
|
|
595
662
|
}
|
|
596
663
|
if (pollingInfo && pollingInfo.interval === pollInterval) {
|
|
597
664
|
return;
|
|
598
665
|
}
|
|
599
|
-
(0, invariant_1.invariant)(pollInterval,
|
|
666
|
+
(0, invariant_1.invariant)(pollInterval, 72);
|
|
600
667
|
const info = pollingInfo || (this.pollingInfo = {});
|
|
601
668
|
info.interval = pollInterval;
|
|
602
669
|
const maybeFetch = () => {
|
|
@@ -611,7 +678,8 @@ class ObservableQuery {
|
|
|
611
678
|
fetchPolicy: this.options.initialFetchPolicy === "no-cache" ?
|
|
612
679
|
"no-cache"
|
|
613
680
|
: "network-only",
|
|
614
|
-
|
|
681
|
+
[newNetworkStatusSymbol]: networkStatus_js_1.NetworkStatus.poll,
|
|
682
|
+
}).then(poll, poll);
|
|
615
683
|
}
|
|
616
684
|
else {
|
|
617
685
|
poll();
|
|
@@ -627,6 +695,13 @@ class ObservableQuery {
|
|
|
627
695
|
};
|
|
628
696
|
poll();
|
|
629
697
|
}
|
|
698
|
+
// This differs from stopPolling in that it does not set pollInterval to 0
|
|
699
|
+
cancelPolling() {
|
|
700
|
+
if (this.pollingInfo) {
|
|
701
|
+
clearTimeout(this.pollingInfo.timeout);
|
|
702
|
+
delete this.pollingInfo;
|
|
703
|
+
}
|
|
704
|
+
}
|
|
630
705
|
updateLastResult(newResult, variables = this.variables) {
|
|
631
706
|
let error = this.getLastError();
|
|
632
707
|
// Preserve this.last.error unless the variables have changed.
|
|
@@ -641,10 +716,18 @@ class ObservableQuery {
|
|
|
641
716
|
...(error ? { error } : null),
|
|
642
717
|
});
|
|
643
718
|
}
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
719
|
+
/**
|
|
720
|
+
* Reevaluate the query, optionally against new options. New options will be
|
|
721
|
+
* merged with the current options when given.
|
|
722
|
+
*/
|
|
723
|
+
reobserve(newOptions) {
|
|
647
724
|
this.isTornDown = false;
|
|
725
|
+
let newNetworkStatus;
|
|
726
|
+
if (newOptions) {
|
|
727
|
+
newNetworkStatus = newOptions[newNetworkStatusSymbol];
|
|
728
|
+
// Avoid setting the symbol option in this.options
|
|
729
|
+
delete newOptions[newNetworkStatusSymbol];
|
|
730
|
+
}
|
|
648
731
|
const useDisposableObservable =
|
|
649
732
|
// Refetching uses a disposable Observable to allow refetches using different
|
|
650
733
|
// options/variables, without permanently altering the options of the
|
|
@@ -657,7 +740,7 @@ class ObservableQuery {
|
|
|
657
740
|
// fetchPolicy to be "network-only" or "no-cache") won't override the original options.
|
|
658
741
|
newNetworkStatus === networkStatus_js_1.NetworkStatus.poll;
|
|
659
742
|
// Save the old variables, since Object.assign may modify them below.
|
|
660
|
-
const oldVariables = this.
|
|
743
|
+
const oldVariables = this.variables;
|
|
661
744
|
const oldFetchPolicy = this.options.fetchPolicy;
|
|
662
745
|
const mergedOptions = (0, utilities_1.compact)(this.options, newOptions || {});
|
|
663
746
|
const options = useDisposableObservable ?
|
|
@@ -671,6 +754,16 @@ class ObservableQuery {
|
|
|
671
754
|
// time a request is made against the original query.
|
|
672
755
|
const query = this.transformDocument(options.query);
|
|
673
756
|
this.lastQuery = query;
|
|
757
|
+
// Reevaluate variables to allow resetting variables with variables: undefined,
|
|
758
|
+
// otherwise `compact` will ignore the `variables` key in `newOptions`. We
|
|
759
|
+
// do this after we run the query transform to ensure we get default
|
|
760
|
+
// variables from the transformed query.
|
|
761
|
+
//
|
|
762
|
+
// Note: updating options.variables may mutate this.options.variables
|
|
763
|
+
// in the case of a non-disposable query. This is intentional.
|
|
764
|
+
if (newOptions && "variables" in newOptions) {
|
|
765
|
+
options.variables = this.getVariablesWithDefaults(newOptions.variables);
|
|
766
|
+
}
|
|
674
767
|
if (!useDisposableObservable) {
|
|
675
768
|
// We can skip calling updatePolling if we're not changing this.options.
|
|
676
769
|
this.updatePolling();
|
|
@@ -687,6 +780,7 @@ class ObservableQuery {
|
|
|
687
780
|
// A `nextFetchPolicy` function has even higher priority, though,
|
|
688
781
|
// so in that case `applyNextFetchPolicy` must be called.
|
|
689
782
|
typeof options.nextFetchPolicy === "function")) {
|
|
783
|
+
// This might mutate options.fetchPolicy
|
|
690
784
|
this.applyNextFetchPolicy("variables-changed", options);
|
|
691
785
|
if (newNetworkStatus === void 0) {
|
|
692
786
|
newNetworkStatus = networkStatus_js_1.NetworkStatus.setVariables;
|
|
@@ -701,6 +795,14 @@ class ObservableQuery {
|
|
|
701
795
|
!(0, equality_1.equal)(newOptions.variables, oldVariables)) {
|
|
702
796
|
newNetworkStatus = networkStatus_js_1.NetworkStatus.setVariables;
|
|
703
797
|
}
|
|
798
|
+
// QueryManager does not emit any values for standby fetch policies so we
|
|
799
|
+
// want ensure that the networkStatus remains ready.
|
|
800
|
+
if (options.fetchPolicy === "standby") {
|
|
801
|
+
newNetworkStatus = networkStatus_js_1.NetworkStatus.ready;
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
if (options.fetchPolicy === "standby") {
|
|
805
|
+
this.cancelPolling();
|
|
704
806
|
}
|
|
705
807
|
this.networkStatus = newNetworkStatus;
|
|
706
808
|
this.waitForOwnResult &&= skipCacheDataFor(options.fetchPolicy);
|
|
@@ -709,8 +811,8 @@ class ObservableQuery {
|
|
|
709
811
|
this.waitForOwnResult = false;
|
|
710
812
|
}
|
|
711
813
|
};
|
|
712
|
-
const variables =
|
|
713
|
-
const { notifyOnNetworkStatusChange =
|
|
814
|
+
const variables = { ...options.variables };
|
|
815
|
+
const { notifyOnNetworkStatusChange = true } = options;
|
|
714
816
|
const { observable, fromLink } = this.fetch(options, newNetworkStatus, notifyOnNetworkStatusChange &&
|
|
715
817
|
oldNetworkStatus !== newNetworkStatus &&
|
|
716
818
|
(0, networkStatus_js_1.isNetworkRequestInFlight)(newNetworkStatus), query);
|
|
@@ -742,7 +844,13 @@ class ObservableQuery {
|
|
|
742
844
|
// Note: lastValueFrom will create a separate subscription to the
|
|
743
845
|
// observable which means that terminating this ObservableQuery will not
|
|
744
846
|
// cancel the request from the link chain.
|
|
745
|
-
(0, rxjs_1.lastValueFrom)(observable
|
|
847
|
+
(0, rxjs_1.lastValueFrom)(observable, {
|
|
848
|
+
// This default value should only be used when using a `fetchPolicy` of
|
|
849
|
+
// `standby` since that fetch policy completes without emitting a
|
|
850
|
+
// result. Since we are converting this to a QueryResult type, we
|
|
851
|
+
// omit the extra fields from ApolloQueryResult in the default value.
|
|
852
|
+
defaultValue: { data: undefined },
|
|
853
|
+
}).then((result) => (0, internal_1.toQueryResult)(this.maskResult(result))));
|
|
746
854
|
}
|
|
747
855
|
// (Re)deliver the current result to this.observers without applying fetch
|
|
748
856
|
// policies or making network requests.
|
|
@@ -798,7 +906,7 @@ class ObservableQuery {
|
|
|
798
906
|
// stop all active GraphQL subscriptions
|
|
799
907
|
this.subscriptions.forEach((sub) => sub.unsubscribe());
|
|
800
908
|
this.subscriptions.clear();
|
|
801
|
-
this.queryManager.
|
|
909
|
+
this.queryManager.removeQuery(this.queryId);
|
|
802
910
|
this.isTornDown = true;
|
|
803
911
|
}
|
|
804
912
|
transformDocument(document) {
|
|
@@ -817,41 +925,97 @@ class ObservableQuery {
|
|
|
817
925
|
}
|
|
818
926
|
: result;
|
|
819
927
|
}
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
928
|
+
dirty = false;
|
|
929
|
+
notifyTimeout;
|
|
930
|
+
/** @internal */
|
|
931
|
+
resetNotifications() {
|
|
932
|
+
this.cancelNotifyTimeout();
|
|
933
|
+
this.dirty = false;
|
|
934
|
+
}
|
|
935
|
+
cancelNotifyTimeout() {
|
|
936
|
+
if (this.notifyTimeout) {
|
|
937
|
+
clearTimeout(this.notifyTimeout);
|
|
938
|
+
this.notifyTimeout = void 0;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
/** @internal */
|
|
942
|
+
scheduleNotify() {
|
|
943
|
+
if (this.dirty)
|
|
944
|
+
return;
|
|
945
|
+
this.dirty = true;
|
|
946
|
+
if (!this.notifyTimeout) {
|
|
947
|
+
this.notifyTimeout = setTimeout(() => this.notify(), 0);
|
|
948
|
+
}
|
|
949
|
+
}
|
|
950
|
+
/** @internal */
|
|
951
|
+
notify() {
|
|
952
|
+
this.cancelNotifyTimeout();
|
|
953
|
+
if (this.dirty) {
|
|
954
|
+
if (this.options.fetchPolicy == "cache-only" ||
|
|
955
|
+
this.options.fetchPolicy == "cache-and-network" ||
|
|
956
|
+
!(0, networkStatus_js_1.isNetworkRequestInFlight)(this.networkStatus)) {
|
|
957
|
+
const diff = this.queryInfo.getDiff();
|
|
958
|
+
if (diff.fromOptimisticTransaction) {
|
|
959
|
+
// If this diff came from an optimistic transaction, deliver the
|
|
960
|
+
// current cache data to the ObservableQuery, but don't perform a
|
|
961
|
+
// reobservation, since oq.reobserveCacheFirst might make a network
|
|
962
|
+
// request, and we never want to trigger network requests in the
|
|
963
|
+
// middle of optimistic updates.
|
|
964
|
+
this.observe();
|
|
844
965
|
}
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
966
|
+
else {
|
|
967
|
+
// Otherwise, make the ObservableQuery "reobserve" the latest data
|
|
968
|
+
// using a temporary fetch policy of "cache-first", so complete cache
|
|
969
|
+
// results have a chance to be delivered without triggering additional
|
|
970
|
+
// network requests, even when options.fetchPolicy is "network-only"
|
|
971
|
+
// or "cache-and-network". All other fetch policies are preserved by
|
|
972
|
+
// this method, and are handled by calling oq.reobserve(). If this
|
|
973
|
+
// reobservation is spurious, isDifferentFromLastResult still has a
|
|
974
|
+
// chance to catch it before delivery to ObservableQuery subscribers.
|
|
975
|
+
this.reobserveCacheFirst();
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
this.dirty = false;
|
|
980
|
+
}
|
|
981
|
+
// Reobserve with fetchPolicy effectively set to "cache-first", triggering
|
|
982
|
+
// delivery of any new data from the cache, possibly falling back to the network
|
|
983
|
+
// if any cache data are missing. This allows _complete_ cache results to be
|
|
984
|
+
// delivered without also kicking off unnecessary network requests when
|
|
985
|
+
// this.options.fetchPolicy is "cache-and-network" or "network-only". When
|
|
986
|
+
// this.options.fetchPolicy is any other policy ("cache-first", "cache-only",
|
|
987
|
+
// "standby", or "no-cache"), we call this.reobserve() as usual.
|
|
988
|
+
reobserveCacheFirst() {
|
|
989
|
+
const { fetchPolicy, nextFetchPolicy } = this.options;
|
|
990
|
+
if (fetchPolicy === "cache-and-network" || fetchPolicy === "network-only") {
|
|
991
|
+
return this.reobserve({
|
|
992
|
+
fetchPolicy: "cache-first",
|
|
993
|
+
// Use a temporary nextFetchPolicy function that replaces itself with the
|
|
994
|
+
// previous nextFetchPolicy value and returns the original fetchPolicy.
|
|
995
|
+
nextFetchPolicy(currentFetchPolicy, context) {
|
|
996
|
+
// Replace this nextFetchPolicy function in the options object with the
|
|
997
|
+
// original this.options.nextFetchPolicy value.
|
|
998
|
+
this.nextFetchPolicy = nextFetchPolicy;
|
|
999
|
+
// If the original nextFetchPolicy value was a function, give it a
|
|
1000
|
+
// chance to decide what happens here.
|
|
1001
|
+
if (typeof this.nextFetchPolicy === "function") {
|
|
1002
|
+
return this.nextFetchPolicy(currentFetchPolicy, context);
|
|
1003
|
+
}
|
|
1004
|
+
// Otherwise go back to the original this.options.fetchPolicy.
|
|
1005
|
+
return fetchPolicy;
|
|
1006
|
+
},
|
|
1007
|
+
});
|
|
1008
|
+
}
|
|
1009
|
+
return this.reobserve();
|
|
1010
|
+
}
|
|
1011
|
+
getVariablesWithDefaults(variables) {
|
|
1012
|
+
return this.queryManager.getVariables(this.query, variables);
|
|
849
1013
|
}
|
|
850
|
-
return obsQuery.reobserve();
|
|
851
1014
|
}
|
|
1015
|
+
exports.ObservableQuery = ObservableQuery;
|
|
852
1016
|
function logMissingFieldErrors(missing) {
|
|
853
1017
|
if (environment_1.__DEV__ && missing) {
|
|
854
|
-
__DEV__ && invariant_1.invariant.debug(
|
|
1018
|
+
__DEV__ && invariant_1.invariant.debug(73, missing);
|
|
855
1019
|
}
|
|
856
1020
|
}
|
|
857
1021
|
function skipCacheDataFor(fetchPolicy /* `undefined` would mean `"cache-first"` */) {
|