@apollo/client 4.0.0-alpha.0 → 4.0.0-alpha.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.changeset/afraid-moons-arrive.md +5 -0
- package/.changeset/beige-mirrors-talk.md +15 -0
- package/.changeset/clean-sheep-hide.md +6 -0
- package/.changeset/cool-bikes-shake.md +12 -0
- package/.changeset/cool-kiwis-hunt.md +15 -0
- package/.changeset/cuddly-spiders-tie.md +5 -0
- package/.changeset/dirty-eagles-poke.md +5 -0
- package/.changeset/early-eggs-develop.md +22 -0
- package/.changeset/eighty-squids-fix.md +15 -0
- package/.changeset/eleven-kangaroos-jump.md +5 -0
- package/.changeset/forty-shrimps-fry.md +5 -0
- package/.changeset/forty-tomatoes-punch.md +5 -0
- package/.changeset/four-countries-clean.md +24 -0
- package/.changeset/four-ghosts-watch.md +5 -0
- package/.changeset/funny-jeans-invent.md +16 -0
- package/.changeset/funny-terms-deny.md +5 -0
- package/.changeset/fuzzy-tips-sit.md +5 -0
- package/.changeset/gentle-badgers-train.md +5 -0
- package/.changeset/giant-apes-thank.md +5 -0
- package/.changeset/giant-bags-share.md +5 -0
- package/.changeset/gorgeous-chefs-tap.md +5 -0
- package/.changeset/great-roses-jog.md +15 -0
- package/.changeset/grumpy-vans-type.md +5 -0
- package/.changeset/hip-vans-act.md +5 -0
- package/.changeset/hungry-bikes-cough.md +5 -0
- package/.changeset/itchy-chefs-run.md +23 -0
- package/.changeset/khaki-keys-deliver.md +5 -0
- package/.changeset/khaki-spies-work.md +11 -0
- package/.changeset/large-plants-know.md +5 -0
- package/.changeset/light-apes-rescue.md +5 -0
- package/.changeset/little-spoons-kick.md +7 -0
- package/.changeset/loud-cows-raise.md +7 -0
- package/.changeset/many-buses-allow.md +5 -0
- package/.changeset/mean-lizards-think.md +5 -0
- package/.changeset/nervous-fireants-bow.md +5 -0
- package/.changeset/nervous-goats-allow.md +5 -0
- package/.changeset/nice-dots-matter.md +5 -0
- package/.changeset/ninety-bags-bake.md +17 -0
- package/.changeset/odd-chicken-hide.md +17 -0
- package/.changeset/odd-lemons-relax.md +5 -0
- package/.changeset/perfect-vans-give.md +7 -0
- package/.changeset/poor-eels-punch.md +5 -0
- package/.changeset/pre.json +67 -0
- package/.changeset/purple-bears-flash.md +5 -0
- package/.changeset/rare-houses-prove.md +5 -0
- package/.changeset/real-teachers-peel.md +5 -0
- package/.changeset/serious-moons-juggle.md +5 -0
- package/.changeset/seven-dragons-repair.md +14 -0
- package/.changeset/shaggy-pugs-add.md +52 -0
- package/.changeset/short-months-complain.md +5 -0
- package/.changeset/slimy-chicken-melt.md +5 -0
- package/.changeset/slimy-maps-press.md +5 -0
- package/.changeset/small-buttons-rhyme.md +5 -0
- package/.changeset/swift-rivers-share.md +13 -0
- package/.changeset/tall-bikes-develop.md +5 -0
- package/.changeset/tame-doors-shop.md +14 -0
- package/.changeset/tame-points-work.md +11 -0
- package/.changeset/tender-swans-flash.md +16 -0
- package/.changeset/thick-books-grin.md +5 -0
- package/.changeset/thin-peas-hear.md +16 -0
- package/.changeset/tidy-pandas-punch.md +5 -0
- package/.changeset/tough-rockets-allow.md +5 -0
- package/.changeset/tricky-tables-shave.md +5 -0
- package/.changeset/unlucky-kiwis-sell.md +5 -0
- package/.changeset/warm-ties-sit.md +7 -0
- package/.changeset/wicked-forks-double.md +33 -0
- package/.changeset/young-phones-fold.md +5 -0
- package/.changeset/young-snails-grin.md +5 -0
- package/CHANGELOG.md +507 -0
- package/__cjs/cache/core/cache.cjs +3 -3
- package/__cjs/cache/core/cache.cjs.map +1 -1
- package/__cjs/cache/core/cache.d.cts +19 -19
- package/__cjs/cache/core/types/Cache.cjs.map +1 -1
- package/__cjs/cache/core/types/Cache.d.cts +9 -16
- package/__cjs/cache/core/types/DataProxy.d.cts +8 -23
- package/__cjs/cache/core/types/common.cjs +1 -0
- package/__cjs/cache/core/types/common.cjs.map +1 -1
- package/__cjs/cache/index.cjs +4 -4
- package/__cjs/cache/index.cjs.map +1 -1
- package/__cjs/cache/index.d.cts +3 -3
- package/__cjs/cache/inmemory/entityStore.cjs +6 -5
- package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/entityStore.d.cts +3 -2
- package/__cjs/cache/inmemory/fragmentRegistry.cjs +3 -3
- package/__cjs/cache/inmemory/fragmentRegistry.cjs.map +1 -1
- package/__cjs/cache/inmemory/helpers.cjs +0 -8
- package/__cjs/cache/inmemory/helpers.cjs.map +1 -1
- package/__cjs/cache/inmemory/helpers.d.cts +3 -4
- package/__cjs/cache/inmemory/inMemoryCache.cjs +6 -18
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.d.cts +9 -11
- package/__cjs/cache/inmemory/policies.cjs +5 -5
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/policies.d.cts +1 -1
- package/__cjs/cache/inmemory/reactiveVars.cjs.map +1 -1
- package/__cjs/cache/inmemory/reactiveVars.d.cts +7 -7
- package/__cjs/cache/inmemory/readFromStore.cjs +12 -54
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/readFromStore.d.cts +1 -6
- package/__cjs/cache/inmemory/types.d.cts +3 -17
- package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
- package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/writeToStore.d.cts +2 -2
- package/__cjs/config/jest/areCombinedGraphQLErrorsEqual.cjs +6 -4
- package/__cjs/config/jest/areCombinedGraphQLErrorsEqual.cjs.map +1 -1
- package/__cjs/config/jest/areCombinedProtocolErrorsEqual.cjs +3 -3
- package/__cjs/config/jest/areCombinedProtocolErrorsEqual.cjs.map +1 -1
- package/__cjs/config/jest/areMissingFieldErrorsEqual.cjs +2 -3
- package/__cjs/config/jest/areMissingFieldErrorsEqual.cjs.map +1 -1
- package/__cjs/config/jest/areServerErrorsEqual.cjs +22 -0
- package/__cjs/config/jest/areServerErrorsEqual.cjs.map +1 -0
- package/__cjs/config/jest/areServerErrorsEqual.d.cts +3 -0
- package/__cjs/config/jest/resolver.cjs +11 -0
- package/__cjs/config/jest/resolver.cjs.map +1 -1
- package/__cjs/config/jest/setup.cjs +18 -1
- package/__cjs/config/jest/setup.cjs.map +1 -1
- package/__cjs/core/ApolloClient.cjs +36 -19
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +36 -26
- package/__cjs/core/LocalState.cjs +2 -2
- package/__cjs/core/LocalState.cjs.map +1 -1
- package/__cjs/core/LocalState.d.cts +8 -8
- package/__cjs/core/ObservableQuery.cjs +268 -104
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +156 -17
- package/__cjs/core/QueryInfo.cjs +12 -86
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +2 -11
- package/__cjs/core/QueryManager.cjs +148 -104
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +45 -24
- package/__cjs/core/index.cjs +42 -21
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +12 -11
- package/__cjs/core/types.d.cts +60 -7
- package/__cjs/core/watchQueryOptions.d.cts +32 -119
- package/__cjs/errors/CombinedGraphQLErrors.cjs +30 -11
- package/__cjs/errors/CombinedGraphQLErrors.cjs.map +1 -1
- package/__cjs/errors/CombinedGraphQLErrors.d.cts +21 -2
- package/__cjs/errors/CombinedProtocolErrors.cjs +13 -6
- package/__cjs/errors/CombinedProtocolErrors.cjs.map +1 -1
- package/__cjs/errors/CombinedProtocolErrors.d.cts +9 -0
- package/__cjs/errors/LinkError.cjs +20 -0
- package/__cjs/errors/LinkError.cjs.map +1 -0
- package/__cjs/errors/LinkError.d.cts +14 -0
- package/__cjs/errors/ServerError.cjs +6 -0
- package/__cjs/errors/ServerError.cjs.map +1 -1
- package/__cjs/errors/ServerError.d.cts +2 -0
- package/__cjs/errors/ServerParseError.cjs +6 -0
- package/__cjs/errors/ServerParseError.cjs.map +1 -1
- package/__cjs/errors/ServerParseError.d.cts +2 -0
- package/__cjs/errors/UnconventionalError.cjs +6 -0
- package/__cjs/errors/UnconventionalError.cjs.map +1 -1
- package/__cjs/errors/UnconventionalError.d.cts +2 -0
- package/__cjs/errors/index.cjs +19 -4
- package/__cjs/errors/index.cjs.map +1 -1
- package/__cjs/errors/index.d.cts +2 -3
- package/__cjs/errors/isErrorLike.cjs +12 -0
- package/__cjs/errors/isErrorLike.cjs.map +1 -0
- package/__cjs/errors/isErrorLike.d.cts +3 -0
- package/__cjs/errors/utils.cjs +18 -0
- package/__cjs/errors/utils.cjs.map +1 -0
- package/__cjs/errors/utils.d.cts +3 -0
- package/__cjs/invariantErrorCodes.cjs +121 -122
- package/__cjs/link/batch/batching.cjs.map +1 -1
- package/__cjs/link/batch/index.cjs +4 -2
- package/__cjs/link/batch/index.cjs.map +1 -1
- package/__cjs/link/batch/index.d.cts +2 -1
- package/__cjs/link/batch-http/index.cjs +3 -2
- package/__cjs/link/batch-http/index.cjs.map +1 -1
- package/__cjs/link/batch-http/index.d.cts +1 -1
- package/__cjs/link/context/index.cjs.map +1 -1
- package/__cjs/link/context/index.d.cts +1 -1
- package/__cjs/link/core/ApolloLink.cjs +2 -20
- package/__cjs/link/core/ApolloLink.cjs.map +1 -1
- package/__cjs/link/core/ApolloLink.d.cts +1 -3
- package/__cjs/link/core/index.cjs.map +1 -1
- package/__cjs/link/core/index.d.cts +1 -1
- package/__cjs/link/core/types.d.cts +1 -1
- package/__cjs/link/error/index.cjs +13 -28
- package/__cjs/link/error/index.cjs.map +1 -1
- package/__cjs/link/error/index.d.cts +4 -15
- package/__cjs/link/http/checkFetcher.cjs +1 -1
- package/__cjs/link/http/createHttpLink.cjs +1 -1
- package/__cjs/link/http/createHttpLink.d.cts +2 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs +4 -3
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs.map +1 -1
- package/__cjs/link/http/serializeFetchParameter.cjs +1 -1
- package/__cjs/link/persisted-queries/index.cjs +3 -3
- package/__cjs/link/persisted-queries/index.cjs.map +1 -1
- package/__cjs/link/persisted-queries/index.d.cts +14 -3
- package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs +1 -1
- package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs.map +1 -1
- package/__cjs/link/remove-typename/removeTypenameFromVariables.d.cts +10 -1
- package/__cjs/link/retry/index.cjs +3 -2
- package/__cjs/link/retry/index.cjs.map +1 -1
- package/__cjs/link/retry/index.d.cts +1 -1
- package/__cjs/link/subscriptions/index.cjs +3 -1
- package/__cjs/link/subscriptions/index.cjs.map +1 -1
- package/__cjs/link/utils/validateOperation.cjs +1 -1
- package/__cjs/masking/maskDefinition.cjs +2 -2
- package/__cjs/masking/maskDefinition.cjs.map +1 -1
- package/__cjs/masking/maskDefinition.d.cts +1 -1
- package/__cjs/masking/maskFragment.cjs +2 -2
- package/__cjs/masking/maskFragment.cjs.map +1 -1
- package/__cjs/masking/maskFragment.d.cts +2 -2
- package/__cjs/masking/maskOperation.cjs +1 -1
- package/__cjs/masking/maskOperation.cjs.map +1 -1
- package/__cjs/masking/maskOperation.d.cts +2 -2
- package/__cjs/masking/utils.cjs +1 -1
- package/__cjs/react/context/ApolloConsumer.cjs +2 -2
- package/__cjs/react/context/ApolloConsumer.cjs.map +1 -1
- package/__cjs/react/context/ApolloConsumer.d.cts +7 -4
- package/__cjs/react/context/ApolloContext.cjs +2 -2
- package/__cjs/react/context/ApolloContext.cjs.map +1 -1
- package/__cjs/react/context/ApolloContext.d.cts +4 -4
- package/__cjs/react/context/ApolloProvider.cjs +2 -2
- package/__cjs/react/context/ApolloProvider.cjs.map +1 -1
- package/__cjs/react/context/ApolloProvider.d.cts +7 -5
- package/__cjs/react/hooks/internal/__use.cjs +1 -1
- package/__cjs/react/hooks/internal/__use.cjs.map +1 -1
- package/__cjs/react/hooks/internal/__use.d.cts +3 -1
- package/__cjs/react/hooks/internal/useDeepMemo.cjs +3 -1
- package/__cjs/react/hooks/internal/useDeepMemo.cjs.map +1 -1
- package/__cjs/react/hooks/internal/useIsomorphicLayoutEffect.cjs +1 -1
- package/__cjs/react/hooks/internal/useIsomorphicLayoutEffect.cjs.map +1 -1
- package/__cjs/react/hooks/internal/useIsomorphicLayoutEffect.d.cts +2 -2
- package/__cjs/react/hooks/internal/useRenderGuard.cjs +1 -1
- package/__cjs/react/hooks/internal/useRenderGuard.cjs.map +1 -1
- package/__cjs/react/hooks/internal/validateSuspenseHookOptions.cjs +28 -0
- package/__cjs/react/hooks/internal/validateSuspenseHookOptions.cjs.map +1 -0
- package/__cjs/react/hooks/internal/validateSuspenseHookOptions.d.cts +3 -0
- package/__cjs/react/hooks/internal/wrapHook.cjs +26 -5
- package/__cjs/react/hooks/internal/wrapHook.cjs.map +1 -1
- package/__cjs/react/hooks/internal/wrapHook.d.cts +7 -5
- package/__cjs/react/hooks/useApolloClient.cjs +3 -3
- package/__cjs/react/hooks/useApolloClient.cjs.map +1 -1
- package/__cjs/react/hooks/useApolloClient.d.cts +2 -2
- package/__cjs/react/hooks/useBackgroundQuery.cjs +3 -3
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +143 -46
- package/__cjs/react/hooks/useFragment.cjs +1 -1
- package/__cjs/react/hooks/useFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useFragment.d.cts +51 -26
- package/__cjs/react/hooks/useLazyQuery.cjs +33 -32
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +278 -276
- package/__cjs/react/hooks/useLoadableQuery.cjs +22 -3
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +106 -34
- package/__cjs/react/hooks/useMutation.cjs +15 -23
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +198 -4
- package/__cjs/react/hooks/useQuery.cjs +88 -207
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +274 -4
- package/__cjs/react/hooks/useQueryRefHandlers.cjs +1 -1
- package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
- package/__cjs/react/hooks/useQueryRefHandlers.d.cts +23 -22
- package/__cjs/react/hooks/useReactiveVar.cjs +1 -1
- package/__cjs/react/hooks/useReactiveVar.cjs.map +1 -1
- package/__cjs/react/hooks/useReactiveVar.d.cts +1 -1
- package/__cjs/react/hooks/useReadQuery.cjs +1 -1
- package/__cjs/react/hooks/useReadQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useReadQuery.d.cts +27 -25
- package/__cjs/react/hooks/useSubscription.cjs +10 -60
- package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
- package/__cjs/react/hooks/useSubscription.d.cts +94 -3
- package/__cjs/react/hooks/useSuspenseFragment.cjs +1 -1
- package/__cjs/react/hooks/useSuspenseFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseFragment.d.cts +40 -38
- package/__cjs/react/hooks/useSuspenseQuery.cjs +8 -33
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +199 -38
- package/__cjs/react/hooks/useSyncExternalStore.cjs +2 -2
- package/__cjs/react/hooks/useSyncExternalStore.cjs.map +1 -1
- package/__cjs/react/index.cjs +35 -11
- package/__cjs/react/index.cjs.map +1 -1
- package/__cjs/react/index.d.cts +21 -6
- package/__cjs/react/index.react-server.cjs +48 -0
- package/__cjs/react/index.react-server.cjs.map +1 -0
- package/__cjs/react/index.react-server.d.cts +19 -0
- package/__cjs/react/internal/cache/FragmentReference.cjs.map +1 -1
- package/__cjs/react/internal/cache/FragmentReference.d.cts +3 -3
- package/__cjs/react/internal/cache/QueryReference.cjs +3 -14
- package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
- package/__cjs/react/internal/cache/QueryReference.d.cts +7 -7
- package/__cjs/react/internal/cache/SuspenseCache.cjs.map +1 -1
- package/__cjs/react/internal/cache/SuspenseCache.d.cts +3 -3
- package/__cjs/react/internal/cache/getSuspenseCache.cjs.map +1 -1
- package/__cjs/react/internal/cache/getSuspenseCache.d.cts +4 -4
- package/__cjs/react/internal/index.cjs +3 -1
- package/__cjs/react/internal/index.cjs.map +1 -1
- package/__cjs/react/internal/index.d.cts +2 -0
- package/__cjs/react/internal/types.d.cts +9 -0
- package/__cjs/react/query-preloader/createQueryPreloader.cjs +1 -0
- package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.d.cts +6 -45
- package/__cjs/react/ssr/getDataFromTree.cjs +24 -30
- package/__cjs/react/ssr/getDataFromTree.cjs.map +1 -1
- package/__cjs/react/ssr/getDataFromTree.d.cts +12 -1
- package/__cjs/react/ssr/index.cjs +3 -3
- package/__cjs/react/ssr/index.cjs.map +1 -1
- package/__cjs/react/ssr/index.d.cts +1 -1
- package/__cjs/react/ssr/prerenderStatic.cjs +151 -0
- package/__cjs/react/ssr/prerenderStatic.cjs.map +1 -0
- package/__cjs/react/ssr/prerenderStatic.d.cts +122 -0
- package/__cjs/react/ssr/renderToStringWithData.cjs +11 -5
- package/__cjs/react/ssr/renderToStringWithData.cjs.map +1 -1
- package/__cjs/react/ssr/renderToStringWithData.d.cts +5 -0
- package/__cjs/react/ssr/useSSRQuery.cjs +60 -0
- package/__cjs/react/ssr/useSSRQuery.cjs.map +1 -0
- package/__cjs/react/ssr/useSSRQuery.d.cts +5 -0
- package/__cjs/{utilities/types/TODO.cjs → react/types/deprecated.cjs} +1 -1
- package/__cjs/react/types/deprecated.cjs.map +1 -0
- package/__cjs/react/types/deprecated.d.cts +75 -0
- package/__cjs/react/types/types.documentation.d.cts +6 -34
- package/__cjs/testing/core/index.cjs +6 -3
- package/__cjs/testing/core/index.cjs.map +1 -1
- package/__cjs/testing/core/index.d.cts +3 -3
- package/__cjs/testing/core/mocking/mockClient.cjs +3 -4
- package/__cjs/testing/core/mocking/mockClient.cjs.map +1 -1
- package/__cjs/testing/core/mocking/mockClient.d.cts +2 -3
- package/__cjs/testing/core/mocking/mockLink.cjs +118 -112
- package/__cjs/testing/core/mocking/mockLink.cjs.map +1 -1
- package/__cjs/testing/core/mocking/mockLink.d.cts +26 -7
- package/__cjs/testing/experimental/createSchemaFetch.cjs +4 -4
- package/__cjs/testing/experimental/createSchemaFetch.cjs.map +1 -1
- package/__cjs/testing/experimental/createTestSchema.cjs.map +1 -1
- package/__cjs/testing/experimental/createTestSchema.d.cts +1 -1
- package/__cjs/testing/index.cjs +13 -2
- package/__cjs/testing/index.cjs.map +1 -1
- package/__cjs/testing/index.d.cts +2 -1
- package/__cjs/testing/internal/disposables/spyOnConsole.cjs +0 -1
- package/__cjs/testing/internal/disposables/spyOnConsole.cjs.map +1 -1
- package/__cjs/testing/internal/disposables/spyOnConsole.d.cts +0 -1
- package/__cjs/testing/internal/disposables/withProdMode.d.cts +1 -1
- package/__cjs/testing/internal/incremental.cjs.map +1 -1
- package/__cjs/testing/internal/incremental.d.cts +4 -3
- package/__cjs/testing/internal/index.cjs +14 -8
- package/__cjs/testing/internal/index.cjs.map +1 -1
- package/__cjs/testing/internal/index.d.cts +4 -3
- package/__cjs/testing/internal/renderHelpers.cjs.map +1 -1
- package/__cjs/testing/internal/renderHelpers.d.cts +3 -3
- package/__cjs/testing/internal/resetApolloContext.cjs +24 -0
- package/__cjs/testing/internal/resetApolloContext.cjs.map +1 -0
- package/__cjs/testing/internal/resetApolloContext.d.cts +10 -0
- package/__cjs/testing/internal/scenarios/index.cjs +9 -7
- package/__cjs/testing/internal/scenarios/index.cjs.map +1 -1
- package/__cjs/testing/internal/scenarios/index.d.cts +14 -5
- package/__cjs/testing/matchers/arrayWithLength.cjs +15 -0
- package/__cjs/testing/matchers/arrayWithLength.cjs.map +1 -0
- package/__cjs/testing/matchers/arrayWithLength.d.cts +3 -0
- package/__cjs/testing/matchers/index.cjs +6 -18
- package/__cjs/testing/matchers/index.cjs.map +1 -1
- package/__cjs/testing/matchers/toComplete.cjs.map +1 -1
- package/__cjs/testing/matchers/toEmitAnything.cjs.map +1 -1
- package/__cjs/testing/matchers/toEmitError.cjs.map +1 -1
- package/__cjs/testing/matchers/toEmitNext.cjs.map +1 -1
- package/__cjs/testing/matchers/{toEmitFetchResult.cjs → toEmitTypedValue.cjs} +9 -7
- package/__cjs/testing/matchers/toEmitTypedValue.cjs.map +1 -0
- package/__cjs/testing/matchers/{toEmitValueStrict.d.cts → toEmitTypedValue.d.cts} +2 -2
- package/__cjs/testing/matchers/toHaveSuspenseCacheEntryUsing.cjs +2 -2
- package/__cjs/testing/matchers/toHaveSuspenseCacheEntryUsing.cjs.map +1 -1
- package/__cjs/testing/matchers/toHaveSuspenseCacheEntryUsing.d.cts +1 -1
- package/__cjs/testing/matchers/toMatchDocument.cjs.map +1 -1
- package/__cjs/testing/matchers/toMatchDocument.d.cts +1 -1
- package/__cjs/testing/matchers/toStrictEqualTyped.cjs +26 -0
- package/__cjs/testing/matchers/toStrictEqualTyped.cjs.map +1 -0
- package/__cjs/testing/matchers/toStrictEqualTyped.d.cts +3 -0
- package/__cjs/testing/matchers/utils/getSerializableProperties.cjs +23 -0
- package/__cjs/testing/matchers/utils/getSerializableProperties.cjs.map +1 -0
- package/__cjs/testing/matchers/utils/getSerializableProperties.d.cts +2 -0
- package/__cjs/testing/react/MockedProvider.cjs +11 -7
- package/__cjs/testing/react/MockedProvider.cjs.map +1 -1
- package/__cjs/testing/react/MockedProvider.d.cts +8 -6
- package/__cjs/utilities/caching/sizes.cjs +2 -2
- package/__cjs/utilities/caching/sizes.cjs.map +1 -1
- package/__cjs/utilities/caching/sizes.d.cts +2 -20
- package/__cjs/utilities/common/canonicalStringify.cjs +2 -2
- package/__cjs/utilities/common/canonicalStringify.cjs.map +1 -1
- package/__cjs/utilities/common/errorHandling.d.cts +1 -1
- package/__cjs/utilities/common/maybeDeepFreeze.cjs +1 -0
- package/__cjs/utilities/common/maybeDeepFreeze.cjs.map +1 -1
- package/__cjs/utilities/common/maybeDeepFreeze.d.cts +1 -0
- package/__cjs/utilities/common/mergeOptions.cjs.map +1 -1
- package/__cjs/utilities/common/mergeOptions.d.cts +1 -1
- package/__cjs/utilities/graphql/getFromAST.cjs +15 -6
- package/__cjs/utilities/graphql/getFromAST.cjs.map +1 -1
- package/__cjs/utilities/graphql/getFromAST.d.cts +2 -2
- package/__cjs/utilities/graphql/operations.cjs.map +1 -1
- package/__cjs/utilities/graphql/operations.d.cts +1 -1
- package/__cjs/utilities/graphql/print.cjs +2 -2
- package/__cjs/utilities/graphql/print.cjs.map +1 -1
- package/__cjs/utilities/graphql/storeUtils.cjs +1 -1
- package/__cjs/utilities/graphql/transform.cjs +2 -2
- package/__cjs/utilities/index.cjs +39 -19
- package/__cjs/utilities/index.cjs.map +1 -1
- package/__cjs/utilities/index.d.cts +16 -15
- package/__cjs/utilities/{caching → internal}/getMemoryInternals.cjs +1 -3
- package/__cjs/utilities/internal/getMemoryInternals.cjs.map +1 -0
- package/__cjs/utilities/{caching → internal}/getMemoryInternals.d.cts +1 -2
- package/__cjs/utilities/internal/index.cjs +8 -1
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +2 -0
- package/__cjs/utilities/internal/index.production.cjs +11 -0
- package/__cjs/utilities/internal/index.production.cjs.map +1 -0
- package/__cjs/utilities/internal/index.production.d.cts +3 -0
- package/__cjs/utilities/internal/toQueryResult.cjs +13 -0
- package/__cjs/utilities/internal/toQueryResult.cjs.map +1 -0
- package/__cjs/utilities/internal/toQueryResult.d.cts +3 -0
- package/__cjs/utilities/invariant/index.development.cjs +1 -0
- package/__cjs/utilities/invariant/index.development.cjs.map +1 -1
- package/__cjs/utilities/subscriptions/relay/index.cjs +2 -2
- package/__cjs/utilities/subscriptions/relay/index.cjs.map +1 -1
- package/__cjs/utilities/subscriptions/relay/index.d.cts +1 -1
- package/__cjs/utilities/types/NoInfer.d.cts +1 -1
- package/__cjs/utilities/types/{OnlyRequiredProperties.cjs → VariablesOption.cjs} +1 -1
- package/__cjs/utilities/types/VariablesOption.cjs.map +1 -0
- package/__cjs/utilities/types/VariablesOption.d.cts +25 -0
- package/__cjs/version.cjs +1 -1
- package/__cjs/version.cjs.map +1 -1
- package/__cjs/version.d.cts +1 -1
- package/cache/core/cache.d.ts +19 -19
- package/cache/core/cache.js +1 -1
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +9 -16
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/core/types/DataProxy.d.ts +8 -23
- package/cache/core/types/common.js +1 -0
- package/cache/core/types/common.js.map +1 -1
- package/cache/index.d.ts +3 -3
- package/cache/index.js +1 -1
- package/cache/index.js.map +1 -1
- package/cache/inmemory/entityStore.d.ts +3 -2
- package/cache/inmemory/entityStore.js +6 -5
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/fragmentRegistry.js +1 -1
- package/cache/inmemory/fragmentRegistry.js.map +1 -1
- package/cache/inmemory/helpers.d.ts +0 -1
- package/cache/inmemory/helpers.js +0 -7
- package/cache/inmemory/helpers.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +9 -11
- package/cache/inmemory/inMemoryCache.js +5 -17
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/policies.d.ts +1 -1
- package/cache/inmemory/policies.js +5 -5
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/reactiveVars.d.ts +7 -7
- package/cache/inmemory/reactiveVars.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +1 -6
- package/cache/inmemory/readFromStore.js +12 -54
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +3 -17
- package/cache/inmemory/writeToStore.d.ts +2 -2
- package/cache/inmemory/writeToStore.js +4 -4
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/config/jest/areCombinedGraphQLErrorsEqual.js +6 -4
- package/config/jest/areCombinedGraphQLErrorsEqual.js.map +1 -1
- package/config/jest/areCombinedProtocolErrorsEqual.js +3 -3
- package/config/jest/areCombinedProtocolErrorsEqual.js.map +1 -1
- package/config/jest/areMissingFieldErrorsEqual.js +2 -3
- package/config/jest/areMissingFieldErrorsEqual.js.map +1 -1
- package/config/jest/areServerErrorsEqual.d.ts +3 -0
- package/config/jest/areServerErrorsEqual.js +18 -0
- package/config/jest/areServerErrorsEqual.js.map +1 -0
- package/config/jest/resolver.js +12 -1
- package/config/jest/resolver.js.map +1 -1
- package/config/jest/setup.js +19 -2
- package/config/jest/setup.js.map +1 -1
- package/core/ApolloClient.d.ts +36 -26
- package/core/ApolloClient.js +36 -19
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.d.ts +6 -6
- package/core/LocalState.js +2 -2
- package/core/LocalState.js.map +1 -1
- package/core/ObservableQuery.d.ts +156 -17
- package/core/ObservableQuery.js +267 -102
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +2 -11
- package/core/QueryInfo.js +12 -86
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +32 -21
- package/core/QueryManager.js +151 -107
- package/core/QueryManager.js.map +1 -1
- package/core/index.d.ts +12 -11
- package/core/index.js +9 -6
- package/core/index.js.map +1 -1
- package/core/types.d.ts +60 -7
- package/core/watchQueryOptions.d.ts +32 -119
- package/errors/CombinedGraphQLErrors.d.ts +21 -2
- package/errors/CombinedGraphQLErrors.js +30 -11
- package/errors/CombinedGraphQLErrors.js.map +1 -1
- package/errors/CombinedProtocolErrors.d.ts +9 -0
- package/errors/CombinedProtocolErrors.js +13 -6
- package/errors/CombinedProtocolErrors.js.map +1 -1
- package/errors/LinkError.d.ts +14 -0
- package/errors/LinkError.js +16 -0
- package/errors/LinkError.js.map +1 -0
- package/errors/ServerError.d.ts +2 -0
- package/errors/ServerError.js +6 -0
- package/errors/ServerError.js.map +1 -1
- package/errors/ServerParseError.d.ts +2 -0
- package/errors/ServerParseError.js +6 -0
- package/errors/ServerParseError.js.map +1 -1
- package/errors/UnconventionalError.d.ts +2 -0
- package/errors/UnconventionalError.js +6 -0
- package/errors/UnconventionalError.js.map +1 -1
- package/errors/index.d.ts +2 -3
- package/errors/index.js +13 -1
- package/errors/index.js.map +1 -1
- package/errors/isErrorLike.d.ts +3 -0
- package/errors/isErrorLike.js +9 -0
- package/errors/isErrorLike.js.map +1 -0
- package/errors/utils.d.ts +3 -0
- package/errors/utils.js +14 -0
- package/errors/utils.js.map +1 -0
- package/invariantErrorCodes.js +121 -122
- package/legacyEntryPoints/testing/internal/index.d.ts +1 -0
- package/legacyEntryPoints/testing/internal/index.js +1 -0
- package/legacyEntryPoints/testing/internal/internal.cjs +1 -0
- package/legacyEntryPoints/testing/internal/internal.d.cts +1 -0
- package/link/batch/batching.js +1 -1
- package/link/batch/batching.js.map +1 -1
- package/link/batch/index.d.ts +2 -1
- package/link/batch/index.js +1 -1
- package/link/batch/index.js.map +1 -1
- package/link/batch-http/index.d.ts +1 -1
- package/link/batch-http/index.js +1 -1
- package/link/batch-http/index.js.map +1 -1
- package/link/context/index.d.ts +1 -1
- package/link/context/index.js.map +1 -1
- package/link/core/ApolloLink.d.ts +1 -3
- package/link/core/ApolloLink.js +2 -20
- package/link/core/ApolloLink.js.map +1 -1
- package/link/core/index.d.ts +1 -1
- package/link/core/index.js.map +1 -1
- package/link/core/types.d.ts +1 -1
- package/link/error/index.d.ts +4 -15
- package/link/error/index.js +14 -29
- package/link/error/index.js.map +1 -1
- package/link/http/checkFetcher.js +1 -1
- package/link/http/createHttpLink.js +1 -1
- package/link/http/parseAndCheckHttpResponse.js +4 -3
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/http/serializeFetchParameter.js +1 -1
- package/link/persisted-queries/index.d.ts +2 -2
- package/link/persisted-queries/index.js +3 -3
- package/link/persisted-queries/index.js.map +1 -1
- package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
- package/link/retry/index.d.ts +1 -1
- package/link/retry/index.js +1 -1
- package/link/retry/index.js.map +1 -1
- package/link/subscriptions/index.js +3 -1
- package/link/subscriptions/index.js.map +1 -1
- package/link/utils/validateOperation.js +1 -1
- package/masking/maskDefinition.d.ts +1 -1
- package/masking/maskDefinition.js +2 -2
- package/masking/maskDefinition.js.map +1 -1
- package/masking/maskFragment.d.ts +2 -2
- package/masking/maskFragment.js +2 -2
- package/masking/maskFragment.js.map +1 -1
- package/masking/maskOperation.d.ts +2 -2
- package/masking/maskOperation.js +1 -1
- package/masking/maskOperation.js.map +1 -1
- package/masking/utils.js +1 -1
- package/package.json +58 -56
- package/react/context/ApolloConsumer.d.ts +7 -4
- package/react/context/ApolloConsumer.js +2 -2
- package/react/context/ApolloConsumer.js.map +1 -1
- package/react/context/ApolloContext.d.ts +4 -4
- package/react/context/ApolloContext.js +2 -2
- package/react/context/ApolloContext.js.map +1 -1
- package/react/context/ApolloProvider.d.ts +7 -5
- package/react/context/ApolloProvider.js +2 -2
- package/react/context/ApolloProvider.js.map +1 -1
- package/react/hooks/internal/__use.js +1 -1
- package/react/hooks/internal/__use.js.map +1 -1
- package/react/hooks/internal/useDeepMemo.js +3 -1
- package/react/hooks/internal/useDeepMemo.js.map +1 -1
- package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts +1 -1
- package/react/hooks/internal/useIsomorphicLayoutEffect.js +1 -1
- package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -1
- package/react/hooks/internal/useRenderGuard.js +1 -1
- package/react/hooks/internal/useRenderGuard.js.map +1 -1
- package/react/hooks/internal/validateSuspenseHookOptions.d.ts +3 -0
- package/react/hooks/internal/validateSuspenseHookOptions.js +22 -0
- package/react/hooks/internal/validateSuspenseHookOptions.js.map +1 -0
- package/react/hooks/internal/wrapHook.d.ts +7 -5
- package/react/hooks/internal/wrapHook.js +24 -5
- package/react/hooks/internal/wrapHook.js.map +1 -1
- package/react/hooks/useApolloClient.d.ts +2 -2
- package/react/hooks/useApolloClient.js +2 -2
- package/react/hooks/useApolloClient.js.map +1 -1
- package/react/hooks/useBackgroundQuery.d.ts +143 -46
- package/react/hooks/useBackgroundQuery.js +3 -3
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useFragment.d.ts +51 -26
- package/react/hooks/useFragment.js +1 -1
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +278 -276
- package/react/hooks/useLazyQuery.js +32 -31
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +106 -34
- package/react/hooks/useLoadableQuery.js +22 -3
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +198 -4
- package/react/hooks/useMutation.js +15 -23
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +274 -4
- package/react/hooks/useQuery.js +87 -206
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.d.ts +23 -22
- package/react/hooks/useQueryRefHandlers.js +1 -1
- package/react/hooks/useQueryRefHandlers.js.map +1 -1
- package/react/hooks/useReactiveVar.d.ts +1 -1
- package/react/hooks/useReactiveVar.js +1 -1
- package/react/hooks/useReactiveVar.js.map +1 -1
- package/react/hooks/useReadQuery.d.ts +27 -25
- package/react/hooks/useReadQuery.js +1 -1
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +94 -9
- package/react/hooks/useSubscription.js +9 -56
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseFragment.d.ts +40 -38
- package/react/hooks/useSuspenseFragment.js +1 -1
- package/react/hooks/useSuspenseFragment.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +199 -38
- package/react/hooks/useSuspenseQuery.js +6 -27
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.js +2 -2
- package/react/hooks/useSyncExternalStore.js.map +1 -1
- package/react/index.d.ts +21 -6
- package/react/index.js +17 -3
- package/react/index.js.map +1 -1
- package/react/index.react-server.d.ts +19 -0
- package/react/index.react-server.js +45 -0
- package/react/index.react-server.js.map +1 -0
- package/react/internal/cache/FragmentReference.d.ts +3 -3
- package/react/internal/cache/FragmentReference.js.map +1 -1
- package/react/internal/cache/QueryReference.d.ts +5 -5
- package/react/internal/cache/QueryReference.js +3 -14
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/internal/cache/SuspenseCache.d.ts +3 -3
- package/react/internal/cache/SuspenseCache.js.map +1 -1
- package/react/internal/cache/getSuspenseCache.d.ts +3 -3
- package/react/internal/cache/getSuspenseCache.js.map +1 -1
- package/react/internal/index.d.ts +2 -0
- package/react/internal/index.js +2 -1
- package/react/internal/index.js.map +1 -1
- package/react/internal/types.d.ts +9 -0
- package/react/query-preloader/createQueryPreloader.d.ts +6 -45
- package/react/query-preloader/createQueryPreloader.js +1 -0
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/ssr/getDataFromTree.d.ts +12 -1
- package/react/ssr/getDataFromTree.js +24 -29
- package/react/ssr/getDataFromTree.js.map +1 -1
- package/react/ssr/index.d.ts +1 -1
- package/react/ssr/index.js +1 -1
- package/react/ssr/index.js.map +1 -1
- package/react/ssr/prerenderStatic.d.ts +122 -0
- package/react/ssr/prerenderStatic.js +147 -0
- package/react/ssr/prerenderStatic.js.map +1 -0
- package/react/ssr/renderToStringWithData.d.ts +5 -0
- package/react/ssr/renderToStringWithData.js +11 -5
- package/react/ssr/renderToStringWithData.js.map +1 -1
- package/react/ssr/useSSRQuery.d.ts +5 -0
- package/react/ssr/useSSRQuery.js +56 -0
- package/react/ssr/useSSRQuery.js.map +1 -0
- package/react/types/deprecated.d.ts +75 -0
- package/react/types/deprecated.js +2 -0
- package/react/types/deprecated.js.map +1 -0
- package/react/types/types.documentation.d.ts +6 -34
- package/testing/core/index.d.ts +3 -3
- package/testing/core/index.js +2 -2
- package/testing/core/index.js.map +1 -1
- package/testing/core/mocking/mockClient.d.ts +2 -3
- package/testing/core/mocking/mockClient.js +2 -3
- package/testing/core/mocking/mockClient.js.map +1 -1
- package/testing/core/mocking/mockLink.d.ts +26 -7
- package/testing/core/mocking/mockLink.js +117 -113
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/experimental/createSchemaFetch.js +2 -2
- package/testing/experimental/createSchemaFetch.js.map +1 -1
- package/testing/experimental/createTestSchema.d.ts +1 -1
- package/testing/experimental/createTestSchema.js.map +1 -1
- package/testing/index.d.ts +2 -1
- package/testing/index.js +1 -1
- package/testing/index.js.map +1 -1
- package/testing/internal/disposables/spyOnConsole.d.ts +0 -1
- package/testing/internal/disposables/spyOnConsole.js +0 -1
- package/testing/internal/disposables/spyOnConsole.js.map +1 -1
- package/testing/internal/incremental.d.ts +1 -1
- package/testing/internal/incremental.js.map +1 -1
- package/testing/internal/index.d.ts +4 -3
- package/testing/internal/index.js +4 -3
- package/testing/internal/index.js.map +1 -1
- package/testing/internal/renderHelpers.d.ts +3 -3
- package/testing/internal/renderHelpers.js.map +1 -1
- package/testing/internal/resetApolloContext.d.ts +10 -0
- package/testing/internal/resetApolloContext.js +20 -0
- package/testing/internal/resetApolloContext.js.map +1 -0
- package/testing/internal/scenarios/index.d.ts +6 -8
- package/testing/internal/scenarios/index.js +4 -2
- package/testing/internal/scenarios/index.js.map +1 -1
- package/testing/matchers/arrayWithLength.d.ts +3 -0
- package/testing/matchers/arrayWithLength.js +11 -0
- package/testing/matchers/arrayWithLength.js.map +1 -0
- package/testing/matchers/index.js +6 -18
- package/testing/matchers/index.js.map +1 -1
- package/testing/matchers/toComplete.js.map +1 -1
- package/testing/matchers/toEmitAnything.js.map +1 -1
- package/testing/matchers/toEmitError.js.map +1 -1
- package/testing/matchers/toEmitNext.js.map +1 -1
- package/testing/matchers/{toEmitValueStrict.d.ts → toEmitTypedValue.d.ts} +2 -2
- package/testing/matchers/{toEmitFetchResult.js → toEmitTypedValue.js} +7 -5
- package/testing/matchers/toEmitTypedValue.js.map +1 -0
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.d.ts +1 -1
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.js +1 -1
- package/testing/matchers/toHaveSuspenseCacheEntryUsing.js.map +1 -1
- package/testing/matchers/toMatchDocument.d.ts +1 -1
- package/testing/matchers/toMatchDocument.js.map +1 -1
- package/testing/matchers/toStrictEqualTyped.d.ts +3 -0
- package/testing/matchers/toStrictEqualTyped.js +22 -0
- package/testing/matchers/toStrictEqualTyped.js.map +1 -0
- package/testing/matchers/utils/getSerializableProperties.d.ts +2 -0
- package/testing/matchers/utils/getSerializableProperties.js +20 -0
- package/testing/matchers/utils/getSerializableProperties.js.map +1 -0
- package/testing/react/MockedProvider.d.ts +8 -6
- package/testing/react/MockedProvider.js +8 -4
- package/testing/react/MockedProvider.js.map +1 -1
- package/utilities/caching/sizes.d.ts +2 -20
- package/utilities/caching/sizes.js +2 -2
- package/utilities/caching/sizes.js.map +1 -1
- package/utilities/common/canonicalStringify.js +1 -1
- package/utilities/common/canonicalStringify.js.map +1 -1
- package/utilities/common/maybeDeepFreeze.d.ts +1 -0
- package/utilities/common/maybeDeepFreeze.js +1 -0
- package/utilities/common/maybeDeepFreeze.js.map +1 -1
- package/utilities/common/mergeOptions.d.ts +1 -1
- package/utilities/common/mergeOptions.js.map +1 -1
- package/utilities/graphql/getFromAST.d.ts +2 -2
- package/utilities/graphql/getFromAST.js +15 -6
- package/utilities/graphql/getFromAST.js.map +1 -1
- package/utilities/graphql/operations.d.ts +1 -1
- package/utilities/graphql/operations.js.map +1 -1
- package/utilities/graphql/print.js +1 -1
- package/utilities/graphql/print.js.map +1 -1
- package/utilities/graphql/storeUtils.js +1 -1
- package/utilities/graphql/transform.js +2 -2
- package/utilities/index.d.ts +16 -15
- package/utilities/index.js +12 -12
- package/utilities/index.js.map +1 -1
- package/utilities/{caching → internal}/getMemoryInternals.d.ts +0 -1
- package/utilities/{caching → internal}/getMemoryInternals.js +1 -3
- package/utilities/internal/getMemoryInternals.js.map +1 -0
- package/utilities/internal/index.d.ts +2 -0
- package/utilities/internal/index.js +2 -0
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/index.production.d.ts +3 -0
- package/utilities/internal/index.production.js +7 -0
- package/utilities/internal/index.production.js.map +1 -0
- package/utilities/internal/toQueryResult.d.ts +3 -0
- package/utilities/internal/toQueryResult.js +10 -0
- package/utilities/internal/toQueryResult.js.map +1 -0
- package/utilities/invariant/index.development.js +1 -0
- package/utilities/invariant/index.development.js.map +1 -1
- package/utilities/subscriptions/relay/index.d.ts +1 -1
- package/utilities/subscriptions/relay/index.js +1 -1
- package/utilities/subscriptions/relay/index.js.map +1 -1
- package/utilities/types/NoInfer.d.ts +1 -1
- package/utilities/types/VariablesOption.d.ts +25 -0
- package/utilities/types/VariablesOption.js +2 -0
- package/utilities/types/VariablesOption.js.map +1 -0
- package/version.d.ts +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/__cjs/cache/inmemory/fixPolyfills.cjs +0 -10
- package/__cjs/cache/inmemory/fixPolyfills.cjs.map +0 -1
- package/__cjs/cache/inmemory/fixPolyfills.d.cts +0 -2
- package/__cjs/cache/inmemory/fixPolyfills.native.cjs +0 -53
- package/__cjs/cache/inmemory/fixPolyfills.native.cjs.map +0 -1
- package/__cjs/cache/inmemory/fixPolyfills.native.d.cts +0 -2
- package/__cjs/cache/inmemory/object-canon.cjs +0 -180
- package/__cjs/cache/inmemory/object-canon.cjs.map +0 -1
- package/__cjs/cache/inmemory/object-canon.d.cts +0 -12
- package/__cjs/index.cjs +0 -8
- package/__cjs/index.cjs.map +0 -1
- package/__cjs/index.d.cts +0 -3
- package/__cjs/link/http/iterators/async.cjs +0 -19
- package/__cjs/link/http/iterators/async.cjs.map +0 -1
- package/__cjs/link/http/iterators/async.d.cts +0 -6
- package/__cjs/link/http/iterators/nodeStream.cjs +0 -75
- package/__cjs/link/http/iterators/nodeStream.cjs.map +0 -1
- package/__cjs/link/http/iterators/nodeStream.d.cts +0 -7
- package/__cjs/link/http/iterators/promise.cjs +0 -32
- package/__cjs/link/http/iterators/promise.cjs.map +0 -1
- package/__cjs/link/http/iterators/promise.d.cts +0 -6
- package/__cjs/link/http/iterators/reader.cjs +0 -19
- package/__cjs/link/http/iterators/reader.cjs.map +0 -1
- package/__cjs/link/http/iterators/reader.d.cts +0 -6
- package/__cjs/link/http/responseIterator.cjs +0 -50
- package/__cjs/link/http/responseIterator.cjs.map +0 -1
- package/__cjs/link/http/responseIterator.d.cts +0 -7
- package/__cjs/react/context/index.cjs +0 -10
- package/__cjs/react/context/index.cjs.map +0 -1
- package/__cjs/react/context/index.d.cts +0 -7
- package/__cjs/react/hooks/index.cjs +0 -27
- package/__cjs/react/hooks/index.cjs.map +0 -1
- package/__cjs/react/hooks/index.d.cts +0 -22
- package/__cjs/react/parser/index.cjs +0 -115
- package/__cjs/react/parser/index.cjs.map +0 -1
- package/__cjs/react/parser/index.d.cts +0 -18
- package/__cjs/react/ssr/RenderPromises.cjs +0 -104
- package/__cjs/react/ssr/RenderPromises.cjs.map +0 -1
- package/__cjs/react/ssr/RenderPromises.d.cts +0 -22
- package/__cjs/react/types/types.d.cts +0 -689
- package/__cjs/testing/matchers/toEmitApolloQueryResult.cjs +0 -40
- package/__cjs/testing/matchers/toEmitApolloQueryResult.cjs.map +0 -1
- package/__cjs/testing/matchers/toEmitApolloQueryResult.d.cts +0 -8
- package/__cjs/testing/matchers/toEmitFetchResult.cjs.map +0 -1
- package/__cjs/testing/matchers/toEmitFetchResult.d.cts +0 -8
- package/__cjs/testing/matchers/toEmitMatchedValue.cjs +0 -40
- package/__cjs/testing/matchers/toEmitMatchedValue.cjs.map +0 -1
- package/__cjs/testing/matchers/toEmitMatchedValue.d.cts +0 -7
- package/__cjs/testing/matchers/toEmitValue.cjs +0 -41
- package/__cjs/testing/matchers/toEmitValue.cjs.map +0 -1
- package/__cjs/testing/matchers/toEmitValue.d.cts +0 -4
- package/__cjs/testing/matchers/toEmitValueStrict.cjs +0 -46
- package/__cjs/testing/matchers/toEmitValueStrict.cjs.map +0 -1
- package/__cjs/testing/matchers/toEqualApolloQueryResult.cjs +0 -24
- package/__cjs/testing/matchers/toEqualApolloQueryResult.cjs.map +0 -1
- package/__cjs/testing/matchers/toEqualApolloQueryResult.d.cts +0 -6
- package/__cjs/testing/matchers/toEqualFetchResult.cjs +0 -24
- package/__cjs/testing/matchers/toEqualFetchResult.cjs.map +0 -1
- package/__cjs/testing/matchers/toEqualFetchResult.d.cts +0 -4
- package/__cjs/testing/matchers/toEqualLazyQueryResult.cjs +0 -40
- package/__cjs/testing/matchers/toEqualLazyQueryResult.cjs.map +0 -1
- package/__cjs/testing/matchers/toEqualLazyQueryResult.d.cts +0 -10
- package/__cjs/testing/matchers/toEqualQueryResult.cjs +0 -40
- package/__cjs/testing/matchers/toEqualQueryResult.cjs.map +0 -1
- package/__cjs/testing/matchers/toEqualQueryResult.d.cts +0 -9
- package/__cjs/utilities/caching/getMemoryInternals.cjs.map +0 -1
- package/__cjs/utilities/types/OnlyRequiredProperties.cjs.map +0 -1
- package/__cjs/utilities/types/OnlyRequiredProperties.d.cts +0 -7
- package/__cjs/utilities/types/TODO.cjs.map +0 -1
- package/__cjs/utilities/types/TODO.d.cts +0 -3
- package/cache/inmemory/fixPolyfills.d.ts +0 -2
- package/cache/inmemory/fixPolyfills.js +0 -10
- package/cache/inmemory/fixPolyfills.js.map +0 -1
- package/cache/inmemory/fixPolyfills.native.d.ts +0 -2
- package/cache/inmemory/fixPolyfills.native.js +0 -53
- package/cache/inmemory/fixPolyfills.native.js.map +0 -1
- package/cache/inmemory/object-canon.d.ts +0 -12
- package/cache/inmemory/object-canon.js +0 -176
- package/cache/inmemory/object-canon.js.map +0 -1
- package/index.d.ts +0 -3
- package/index.js +0 -3
- package/index.js.map +0 -1
- package/legacyEntryPoints/react/context/context.cjs +0 -1
- package/legacyEntryPoints/react/context/context.d.cts +0 -1
- package/legacyEntryPoints/react/context/index.d.ts +0 -1
- package/legacyEntryPoints/react/context/index.js +0 -1
- package/legacyEntryPoints/react/hooks/hooks.cjs +0 -1
- package/legacyEntryPoints/react/hooks/hooks.d.cts +0 -1
- package/legacyEntryPoints/react/hooks/index.d.ts +0 -1
- package/legacyEntryPoints/react/hooks/index.js +0 -1
- package/legacyEntryPoints/react/parser/index.d.ts +0 -1
- package/legacyEntryPoints/react/parser/index.js +0 -1
- package/legacyEntryPoints/react/parser/parser.cjs +0 -1
- package/legacyEntryPoints/react/parser/parser.d.cts +0 -1
- package/link/http/iterators/async.d.ts +0 -6
- package/link/http/iterators/async.js +0 -16
- package/link/http/iterators/async.js.map +0 -1
- package/link/http/iterators/nodeStream.d.ts +0 -7
- package/link/http/iterators/nodeStream.js +0 -72
- package/link/http/iterators/nodeStream.js.map +0 -1
- package/link/http/iterators/promise.d.ts +0 -6
- package/link/http/iterators/promise.js +0 -29
- package/link/http/iterators/promise.js.map +0 -1
- package/link/http/iterators/reader.d.ts +0 -6
- package/link/http/iterators/reader.js +0 -16
- package/link/http/iterators/reader.js.map +0 -1
- package/link/http/responseIterator.d.ts +0 -7
- package/link/http/responseIterator.js +0 -46
- package/link/http/responseIterator.js.map +0 -1
- package/react/context/index.d.ts +0 -7
- package/react/context/index.js +0 -4
- package/react/context/index.js.map +0 -1
- package/react/hooks/index.d.ts +0 -22
- package/react/hooks/index.js +0 -15
- package/react/hooks/index.js.map +0 -1
- package/react/parser/index.d.ts +0 -18
- package/react/parser/index.js +0 -109
- package/react/parser/index.js.map +0 -1
- package/react/ssr/RenderPromises.d.ts +0 -22
- package/react/ssr/RenderPromises.js +0 -100
- package/react/ssr/RenderPromises.js.map +0 -1
- package/react/types/types.d.ts +0 -689
- package/testing/matchers/toEmitApolloQueryResult.d.ts +0 -8
- package/testing/matchers/toEmitApolloQueryResult.js +0 -36
- package/testing/matchers/toEmitApolloQueryResult.js.map +0 -1
- package/testing/matchers/toEmitFetchResult.d.ts +0 -8
- package/testing/matchers/toEmitFetchResult.js.map +0 -1
- package/testing/matchers/toEmitMatchedValue.d.ts +0 -7
- package/testing/matchers/toEmitMatchedValue.js +0 -36
- package/testing/matchers/toEmitMatchedValue.js.map +0 -1
- package/testing/matchers/toEmitValue.d.ts +0 -4
- package/testing/matchers/toEmitValue.js +0 -37
- package/testing/matchers/toEmitValue.js.map +0 -1
- package/testing/matchers/toEmitValueStrict.js +0 -42
- package/testing/matchers/toEmitValueStrict.js.map +0 -1
- package/testing/matchers/toEqualApolloQueryResult.d.ts +0 -6
- package/testing/matchers/toEqualApolloQueryResult.js +0 -20
- package/testing/matchers/toEqualApolloQueryResult.js.map +0 -1
- package/testing/matchers/toEqualFetchResult.d.ts +0 -4
- package/testing/matchers/toEqualFetchResult.js +0 -20
- package/testing/matchers/toEqualFetchResult.js.map +0 -1
- package/testing/matchers/toEqualLazyQueryResult.d.ts +0 -10
- package/testing/matchers/toEqualLazyQueryResult.js +0 -36
- package/testing/matchers/toEqualLazyQueryResult.js.map +0 -1
- package/testing/matchers/toEqualQueryResult.d.ts +0 -9
- package/testing/matchers/toEqualQueryResult.js +0 -36
- package/testing/matchers/toEqualQueryResult.js.map +0 -1
- package/utilities/caching/getMemoryInternals.js.map +0 -1
- package/utilities/types/OnlyRequiredProperties.d.ts +0 -7
- package/utilities/types/OnlyRequiredProperties.js +0 -2
- package/utilities/types/OnlyRequiredProperties.js.map +0 -1
- package/utilities/types/TODO.d.ts +0 -3
- package/utilities/types/TODO.js +0 -2
- package/utilities/types/TODO.js.map +0 -1
- /package/__cjs/react/{types → internal}/types.cjs +0 -0
- /package/__cjs/react/{types → internal}/types.cjs.map +0 -0
- /package/react/{types → internal}/types.js +0 -0
- /package/react/{types → internal}/types.js.map +0 -0
package/core/ObservableQuery.js
CHANGED
|
@@ -1,12 +1,24 @@
|
|
|
1
1
|
import { equal } from "@wry/equality";
|
|
2
|
+
import { Slot } from "optimism";
|
|
2
3
|
import { BehaviorSubject, filter, lastValueFrom, tap } from "rxjs";
|
|
3
4
|
import { cloneDeep, compact, getOperationDefinition, getQueryDefinition, preventUnhandledRejection, } from "@apollo/client/utilities";
|
|
4
5
|
import { __DEV__ } from "@apollo/client/utilities/environment";
|
|
6
|
+
import { toQueryResult } from "@apollo/client/utilities/internal";
|
|
5
7
|
import { invariant } from "@apollo/client/utilities/invariant";
|
|
6
8
|
import { equalByQuery } from "./equalByQuery.js";
|
|
7
9
|
import { isNetworkRequestInFlight, NetworkStatus } from "./networkStatus.js";
|
|
8
10
|
const { assign, hasOwnProperty } = Object;
|
|
11
|
+
const newNetworkStatusSymbol = Symbol();
|
|
12
|
+
const uninitialized = {};
|
|
9
13
|
export class ObservableQuery {
|
|
14
|
+
/**
|
|
15
|
+
* @internal
|
|
16
|
+
* A slot used by the `useQuery` hook to indicate that `client.watchQuery`
|
|
17
|
+
* should not register the query immediately, but instead wait for the query to
|
|
18
|
+
* be started registered with the `QueryManager` when `useSyncExternalStore`
|
|
19
|
+
* actively subscribes to it.
|
|
20
|
+
*/
|
|
21
|
+
static inactiveOnCreation = new Slot();
|
|
10
22
|
options;
|
|
11
23
|
queryId;
|
|
12
24
|
queryName;
|
|
@@ -15,10 +27,8 @@ export class ObservableQuery {
|
|
|
15
27
|
// untransformed query to ensure document transforms with runtime conditionals
|
|
16
28
|
// are run on the original document.
|
|
17
29
|
get query() {
|
|
18
|
-
return this.lastQuery
|
|
30
|
+
return this.lastQuery;
|
|
19
31
|
}
|
|
20
|
-
// Computed shorthand for this.options.variables, preserved for
|
|
21
|
-
// backwards compatibility.
|
|
22
32
|
/**
|
|
23
33
|
* An object containing the variables that were provided for the query.
|
|
24
34
|
*/
|
|
@@ -27,7 +37,6 @@ export class ObservableQuery {
|
|
|
27
37
|
}
|
|
28
38
|
subject;
|
|
29
39
|
observable;
|
|
30
|
-
initialResult;
|
|
31
40
|
isTornDown;
|
|
32
41
|
queryManager;
|
|
33
42
|
subscriptions = new Set();
|
|
@@ -41,16 +50,31 @@ export class ObservableQuery {
|
|
|
41
50
|
networkStatus;
|
|
42
51
|
constructor({ queryManager, queryInfo, options, }) {
|
|
43
52
|
this.networkStatus = NetworkStatus.loading;
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
loading: true,
|
|
47
|
-
networkStatus: this.networkStatus,
|
|
48
|
-
partial: true,
|
|
49
|
-
};
|
|
50
|
-
this.subject = new BehaviorSubject(this.initialResult);
|
|
53
|
+
let startedInactive = ObservableQuery.inactiveOnCreation.getValue();
|
|
54
|
+
this.subject = new BehaviorSubject(uninitialized);
|
|
51
55
|
this.observable = this.subject.pipe(tap({
|
|
52
56
|
subscribe: () => {
|
|
57
|
+
if (startedInactive) {
|
|
58
|
+
queryManager["queries"].set(this.queryId, queryInfo);
|
|
59
|
+
startedInactive = false;
|
|
60
|
+
}
|
|
53
61
|
if (!this.subject.observed) {
|
|
62
|
+
if (this.subject.value === uninitialized) {
|
|
63
|
+
// Emitting a value in the `subscribe` callback of `tap` gives
|
|
64
|
+
// the subject a chance to save this initial result without
|
|
65
|
+
// emitting the placeholder value since this callback is executed
|
|
66
|
+
// before `tap` subscribes to the source observable (the subject).
|
|
67
|
+
// `reobserve` also has the chance to update this value if it
|
|
68
|
+
// synchronously emits one (usually due to reporting a cache
|
|
69
|
+
// value).
|
|
70
|
+
//
|
|
71
|
+
// We don't initialize the `BehaviorSubject` with
|
|
72
|
+
// `getInitialResult` because its possible the cache might have
|
|
73
|
+
// updated between when the `ObservableQuery` was instantiated and
|
|
74
|
+
// when it is subscribed to. Updating the value here ensures we
|
|
75
|
+
// report the most up-to-date result from the cache.
|
|
76
|
+
this.subject.next(this.getInitialResult());
|
|
77
|
+
}
|
|
54
78
|
this.reobserve();
|
|
55
79
|
// TODO: See if we can rework updatePolling to better handle this.
|
|
56
80
|
// reobserve calls updatePolling but this `subscribe` callback is
|
|
@@ -65,18 +89,14 @@ export class ObservableQuery {
|
|
|
65
89
|
this.tearDownQuery();
|
|
66
90
|
}
|
|
67
91
|
},
|
|
68
|
-
}),
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
// TODO: Remove this behavior when unifying loading state for notifyOnNetworkStatusChange
|
|
77
|
-
(this.options.fetchPolicy === "network-only" &&
|
|
78
|
-
this.queryInfo.getDiff().complete) ||
|
|
79
|
-
result !== this.initialResult));
|
|
92
|
+
}), filter((result) => {
|
|
93
|
+
return (this.options.fetchPolicy !== "standby" &&
|
|
94
|
+
(this.options.notifyOnNetworkStatusChange ||
|
|
95
|
+
!result.loading ||
|
|
96
|
+
// data could be defined for cache-and-network fetch policies
|
|
97
|
+
// when emitting the cache result while loading the network result
|
|
98
|
+
!!result.data));
|
|
99
|
+
}));
|
|
80
100
|
this["@@observable"] = () => this;
|
|
81
101
|
if (Symbol.observable) {
|
|
82
102
|
this[Symbol.observable] = () => this;
|
|
@@ -96,6 +116,7 @@ export class ObservableQuery {
|
|
|
96
116
|
const { fetchPolicy = defaultFetchPolicy,
|
|
97
117
|
// Make sure we don't store "standby" as the initialFetchPolicy.
|
|
98
118
|
initialFetchPolicy = fetchPolicy === "standby" ? defaultFetchPolicy : (fetchPolicy), } = options;
|
|
119
|
+
this.lastQuery = options.query;
|
|
99
120
|
this.options = {
|
|
100
121
|
...options,
|
|
101
122
|
// Remember the initial options.fetchPolicy so we can revert back to this
|
|
@@ -105,6 +126,7 @@ export class ObservableQuery {
|
|
|
105
126
|
// This ensures this.options.fetchPolicy always has a string value, in
|
|
106
127
|
// case options.fetchPolicy was not provided.
|
|
107
128
|
fetchPolicy,
|
|
129
|
+
variables: this.getVariablesWithDefaults(options.variables),
|
|
108
130
|
};
|
|
109
131
|
this.queryId = queryInfo.queryId || queryManager.generateQueryId();
|
|
110
132
|
const opDef = getOperationDefinition(this.query);
|
|
@@ -121,6 +143,50 @@ export class ObservableQuery {
|
|
|
121
143
|
resetDiff() {
|
|
122
144
|
this.queryInfo.resetDiff();
|
|
123
145
|
}
|
|
146
|
+
getInitialResult() {
|
|
147
|
+
const fetchPolicy = this.queryManager.prioritizeCacheValues ?
|
|
148
|
+
"cache-first"
|
|
149
|
+
: this.options.fetchPolicy;
|
|
150
|
+
const defaultResult = {
|
|
151
|
+
data: undefined,
|
|
152
|
+
loading: true,
|
|
153
|
+
networkStatus: NetworkStatus.loading,
|
|
154
|
+
partial: true,
|
|
155
|
+
};
|
|
156
|
+
const cacheResult = () => {
|
|
157
|
+
const diff = this.queryInfo.getDiff();
|
|
158
|
+
return this.maskResult({
|
|
159
|
+
data:
|
|
160
|
+
// TODO: queryInfo.getDiff should handle this since cache.diff returns a
|
|
161
|
+
// null when returnPartialData is false
|
|
162
|
+
this.options.returnPartialData || diff.complete ?
|
|
163
|
+
diff.result ?? undefined
|
|
164
|
+
: undefined,
|
|
165
|
+
loading: !diff.complete,
|
|
166
|
+
networkStatus: diff.complete ? NetworkStatus.ready : NetworkStatus.loading,
|
|
167
|
+
partial: !diff.complete,
|
|
168
|
+
});
|
|
169
|
+
};
|
|
170
|
+
switch (fetchPolicy) {
|
|
171
|
+
case "cache-only":
|
|
172
|
+
case "cache-first":
|
|
173
|
+
return cacheResult();
|
|
174
|
+
case "cache-and-network":
|
|
175
|
+
return {
|
|
176
|
+
...cacheResult(),
|
|
177
|
+
loading: true,
|
|
178
|
+
networkStatus: NetworkStatus.loading,
|
|
179
|
+
};
|
|
180
|
+
case "standby":
|
|
181
|
+
return {
|
|
182
|
+
...defaultResult,
|
|
183
|
+
loading: false,
|
|
184
|
+
networkStatus: NetworkStatus.ready,
|
|
185
|
+
};
|
|
186
|
+
default:
|
|
187
|
+
return defaultResult;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
124
190
|
getCurrentFullResult(saveAsLastResult = true) {
|
|
125
191
|
// Use the last result as long as the variables match this.variables.
|
|
126
192
|
const lastResult = this.getLastResult(true);
|
|
@@ -132,7 +198,11 @@ export class ObservableQuery {
|
|
|
132
198
|
loading: isNetworkRequestInFlight(networkStatus),
|
|
133
199
|
networkStatus,
|
|
134
200
|
};
|
|
135
|
-
|
|
201
|
+
let { fetchPolicy = "cache-first" } = this.options;
|
|
202
|
+
const { prioritizeCacheValues } = this.queryManager;
|
|
203
|
+
if (prioritizeCacheValues) {
|
|
204
|
+
fetchPolicy = "cache-first";
|
|
205
|
+
}
|
|
136
206
|
if (
|
|
137
207
|
// These fetch policies should never deliver data from the cache, unless
|
|
138
208
|
// redelivering a previously delivered result.
|
|
@@ -144,7 +214,7 @@ export class ObservableQuery {
|
|
|
144
214
|
this.queryManager.getDocumentInfo(this.query).hasForcedResolvers) {
|
|
145
215
|
// Fall through.
|
|
146
216
|
}
|
|
147
|
-
else if (this.waitForOwnResult) {
|
|
217
|
+
else if (this.waitForOwnResult && !prioritizeCacheValues) {
|
|
148
218
|
// This would usually be a part of `QueryInfo.getDiff()`.
|
|
149
219
|
// which we skip in the waitForOwnResult case since we are not
|
|
150
220
|
// interested in the diff.
|
|
@@ -256,18 +326,19 @@ export class ObservableQuery {
|
|
|
256
326
|
const queryDef = getQueryDefinition(this.query);
|
|
257
327
|
const vars = queryDef.variableDefinitions;
|
|
258
328
|
if (!vars || !vars.some((v) => v.variable.name.value === "variables")) {
|
|
259
|
-
__DEV__ && invariant.warn(
|
|
329
|
+
__DEV__ && invariant.warn(69, variables, queryDef.name?.value || queryDef);
|
|
260
330
|
}
|
|
261
331
|
}
|
|
262
|
-
if (variables && !equal(this.
|
|
332
|
+
if (variables && !equal(this.variables, variables)) {
|
|
263
333
|
// Update the existing options with new variables
|
|
264
|
-
reobserveOptions.variables = this.options.variables =
|
|
265
|
-
...this.
|
|
266
|
-
...variables,
|
|
267
|
-
};
|
|
334
|
+
reobserveOptions.variables = this.options.variables =
|
|
335
|
+
this.getVariablesWithDefaults({ ...this.variables, ...variables });
|
|
268
336
|
}
|
|
269
337
|
this.queryInfo.resetLastWrite();
|
|
270
|
-
return this.reobserve(
|
|
338
|
+
return this.reobserve({
|
|
339
|
+
...reobserveOptions,
|
|
340
|
+
[newNetworkStatusSymbol]: NetworkStatus.refetch,
|
|
341
|
+
});
|
|
271
342
|
}
|
|
272
343
|
/**
|
|
273
344
|
* 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/).
|
|
@@ -279,7 +350,7 @@ export class ObservableQuery {
|
|
|
279
350
|
query: this.options.query,
|
|
280
351
|
...fetchMoreOptions,
|
|
281
352
|
variables: {
|
|
282
|
-
...this.
|
|
353
|
+
...this.variables,
|
|
283
354
|
...fetchMoreOptions.variables,
|
|
284
355
|
},
|
|
285
356
|
})),
|
|
@@ -289,6 +360,7 @@ export class ObservableQuery {
|
|
|
289
360
|
// fetchMore to provide an updateQuery callback that determines how
|
|
290
361
|
// the data gets written to the cache.
|
|
291
362
|
fetchPolicy: "no-cache",
|
|
363
|
+
notifyOnNetworkStatusChange: this.options.notifyOnNetworkStatusChange,
|
|
292
364
|
};
|
|
293
365
|
combinedOptions.query = this.transformDocument(combinedOptions.query);
|
|
294
366
|
const qid = this.queryManager.generateQueryId();
|
|
@@ -312,7 +384,7 @@ export class ObservableQuery {
|
|
|
312
384
|
const updateQuery = fetchMoreOptions?.updateQuery;
|
|
313
385
|
const isCached = this.options.fetchPolicy !== "no-cache";
|
|
314
386
|
if (!isCached) {
|
|
315
|
-
invariant(updateQuery,
|
|
387
|
+
invariant(updateQuery, 70);
|
|
316
388
|
}
|
|
317
389
|
return this.queryManager
|
|
318
390
|
.fetchQuery(qid, combinedOptions, NetworkStatus.fetchMore)
|
|
@@ -397,7 +469,7 @@ export class ObservableQuery {
|
|
|
397
469
|
// the cache, we still want fetchMore to deliver its final loading:false
|
|
398
470
|
// result with the unchanged data.
|
|
399
471
|
if (isCached && !updatedQuerySet.has(this.query)) {
|
|
400
|
-
reobserveCacheFirst(
|
|
472
|
+
this.reobserveCacheFirst();
|
|
401
473
|
}
|
|
402
474
|
});
|
|
403
475
|
}
|
|
@@ -418,7 +490,17 @@ export class ObservableQuery {
|
|
|
418
490
|
})
|
|
419
491
|
.subscribe({
|
|
420
492
|
next: (subscriptionData) => {
|
|
421
|
-
const { updateQuery } = options;
|
|
493
|
+
const { updateQuery, onError } = options;
|
|
494
|
+
const { error } = subscriptionData;
|
|
495
|
+
if (error) {
|
|
496
|
+
if (onError) {
|
|
497
|
+
onError(error);
|
|
498
|
+
}
|
|
499
|
+
else {
|
|
500
|
+
__DEV__ && invariant.error(71, error);
|
|
501
|
+
}
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
422
504
|
if (updateQuery) {
|
|
423
505
|
this.updateQuery((previous, updateOptions) => updateQuery(previous, {
|
|
424
506
|
subscriptionData: subscriptionData,
|
|
@@ -426,13 +508,6 @@ export class ObservableQuery {
|
|
|
426
508
|
}));
|
|
427
509
|
}
|
|
428
510
|
},
|
|
429
|
-
error: (err) => {
|
|
430
|
-
if (options.onError) {
|
|
431
|
-
options.onError(err);
|
|
432
|
-
return;
|
|
433
|
-
}
|
|
434
|
-
__DEV__ && invariant.error(68, err);
|
|
435
|
-
},
|
|
436
511
|
});
|
|
437
512
|
this.subscriptions.add(subscription);
|
|
438
513
|
return () => {
|
|
@@ -441,9 +516,7 @@ export class ObservableQuery {
|
|
|
441
516
|
}
|
|
442
517
|
};
|
|
443
518
|
}
|
|
444
|
-
|
|
445
|
-
return this.reobserve(newOptions);
|
|
446
|
-
}
|
|
519
|
+
/** @internal */
|
|
447
520
|
silentSetOptions(newOptions) {
|
|
448
521
|
const mergedOptions = compact(this.options, newOptions || {});
|
|
449
522
|
assign(this.options, mergedOptions);
|
|
@@ -467,22 +540,24 @@ export class ObservableQuery {
|
|
|
467
540
|
* the previous values of those variables will be used.
|
|
468
541
|
*/
|
|
469
542
|
async setVariables(variables) {
|
|
543
|
+
variables = this.getVariablesWithDefaults(variables);
|
|
470
544
|
if (equal(this.variables, variables)) {
|
|
471
545
|
// If we have no observers, then we don't actually want to make a network
|
|
472
546
|
// request. As soon as someone observes the query, the request will kick
|
|
473
547
|
// off. For now, we just store any changes. (See #1077)
|
|
474
|
-
return this.subject.getValue();
|
|
548
|
+
return toQueryResult(this.subject.getValue());
|
|
475
549
|
}
|
|
476
550
|
this.options.variables = variables;
|
|
477
551
|
// See comment above
|
|
478
552
|
if (!this.hasObservers()) {
|
|
479
|
-
return this.subject.getValue();
|
|
553
|
+
return toQueryResult(this.subject.getValue());
|
|
480
554
|
}
|
|
481
555
|
return this.reobserve({
|
|
482
556
|
// Reset options.fetchPolicy to its original value.
|
|
483
557
|
fetchPolicy: this.options.initialFetchPolicy,
|
|
484
558
|
variables,
|
|
485
|
-
|
|
559
|
+
[newNetworkStatusSymbol]: NetworkStatus.setVariables,
|
|
560
|
+
});
|
|
486
561
|
}
|
|
487
562
|
/**
|
|
488
563
|
* A function that enables you to update the query's cached result without executing a followup GraphQL operation.
|
|
@@ -547,13 +622,8 @@ export class ObservableQuery {
|
|
|
547
622
|
// requests to be triggered only if the cache result is incomplete. To
|
|
548
623
|
// that end, the options.nextFetchPolicy option provides an easy way to
|
|
549
624
|
// update options.fetchPolicy after the initial network request, without
|
|
550
|
-
// having to call observableQuery.
|
|
551
|
-
options.fetchPolicy = options.nextFetchPolicy(fetchPolicy, {
|
|
552
|
-
reason,
|
|
553
|
-
options,
|
|
554
|
-
observable: this,
|
|
555
|
-
initialFetchPolicy,
|
|
556
|
-
});
|
|
625
|
+
// having to call observableQuery.reobserve.
|
|
626
|
+
options.fetchPolicy = options.nextFetchPolicy.call(options, fetchPolicy, { reason, options, observable: this, initialFetchPolicy });
|
|
557
627
|
}
|
|
558
628
|
else if (reason === "variables-changed") {
|
|
559
629
|
options.fetchPolicy = initialFetchPolicy;
|
|
@@ -567,8 +637,9 @@ export class ObservableQuery {
|
|
|
567
637
|
fetch(options, newNetworkStatus, emitLoadingState, query) {
|
|
568
638
|
// TODO Make sure we update the networkStatus (and infer fetchVariables)
|
|
569
639
|
// before actually committing to the fetch.
|
|
570
|
-
this.queryManager.
|
|
571
|
-
|
|
640
|
+
const queryInfo = this.queryManager.getOrCreateQuery(this.queryId);
|
|
641
|
+
queryInfo.setObservableQuery(this);
|
|
642
|
+
return this.queryManager.fetchObservableWithInfo(queryInfo, options, newNetworkStatus, query, emitLoadingState);
|
|
572
643
|
}
|
|
573
644
|
// Turns polling on or off based on this.options.pollInterval.
|
|
574
645
|
updatePolling() {
|
|
@@ -578,16 +649,13 @@ export class ObservableQuery {
|
|
|
578
649
|
}
|
|
579
650
|
const { pollingInfo, options: { pollInterval }, } = this;
|
|
580
651
|
if (!pollInterval || !this.hasObservers()) {
|
|
581
|
-
|
|
582
|
-
clearTimeout(pollingInfo.timeout);
|
|
583
|
-
delete this.pollingInfo;
|
|
584
|
-
}
|
|
652
|
+
this.cancelPolling();
|
|
585
653
|
return;
|
|
586
654
|
}
|
|
587
655
|
if (pollingInfo && pollingInfo.interval === pollInterval) {
|
|
588
656
|
return;
|
|
589
657
|
}
|
|
590
|
-
invariant(pollInterval,
|
|
658
|
+
invariant(pollInterval, 72);
|
|
591
659
|
const info = pollingInfo || (this.pollingInfo = {});
|
|
592
660
|
info.interval = pollInterval;
|
|
593
661
|
const maybeFetch = () => {
|
|
@@ -602,7 +670,8 @@ export class ObservableQuery {
|
|
|
602
670
|
fetchPolicy: this.options.initialFetchPolicy === "no-cache" ?
|
|
603
671
|
"no-cache"
|
|
604
672
|
: "network-only",
|
|
605
|
-
|
|
673
|
+
[newNetworkStatusSymbol]: NetworkStatus.poll,
|
|
674
|
+
}).then(poll, poll);
|
|
606
675
|
}
|
|
607
676
|
else {
|
|
608
677
|
poll();
|
|
@@ -618,6 +687,13 @@ export class ObservableQuery {
|
|
|
618
687
|
};
|
|
619
688
|
poll();
|
|
620
689
|
}
|
|
690
|
+
// This differs from stopPolling in that it does not set pollInterval to 0
|
|
691
|
+
cancelPolling() {
|
|
692
|
+
if (this.pollingInfo) {
|
|
693
|
+
clearTimeout(this.pollingInfo.timeout);
|
|
694
|
+
delete this.pollingInfo;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
621
697
|
updateLastResult(newResult, variables = this.variables) {
|
|
622
698
|
let error = this.getLastError();
|
|
623
699
|
// Preserve this.last.error unless the variables have changed.
|
|
@@ -632,10 +708,18 @@ export class ObservableQuery {
|
|
|
632
708
|
...(error ? { error } : null),
|
|
633
709
|
});
|
|
634
710
|
}
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
711
|
+
/**
|
|
712
|
+
* Reevaluate the query, optionally against new options. New options will be
|
|
713
|
+
* merged with the current options when given.
|
|
714
|
+
*/
|
|
715
|
+
reobserve(newOptions) {
|
|
638
716
|
this.isTornDown = false;
|
|
717
|
+
let newNetworkStatus;
|
|
718
|
+
if (newOptions) {
|
|
719
|
+
newNetworkStatus = newOptions[newNetworkStatusSymbol];
|
|
720
|
+
// Avoid setting the symbol option in this.options
|
|
721
|
+
delete newOptions[newNetworkStatusSymbol];
|
|
722
|
+
}
|
|
639
723
|
const useDisposableObservable =
|
|
640
724
|
// Refetching uses a disposable Observable to allow refetches using different
|
|
641
725
|
// options/variables, without permanently altering the options of the
|
|
@@ -648,7 +732,7 @@ export class ObservableQuery {
|
|
|
648
732
|
// fetchPolicy to be "network-only" or "no-cache") won't override the original options.
|
|
649
733
|
newNetworkStatus === NetworkStatus.poll;
|
|
650
734
|
// Save the old variables, since Object.assign may modify them below.
|
|
651
|
-
const oldVariables = this.
|
|
735
|
+
const oldVariables = this.variables;
|
|
652
736
|
const oldFetchPolicy = this.options.fetchPolicy;
|
|
653
737
|
const mergedOptions = compact(this.options, newOptions || {});
|
|
654
738
|
const options = useDisposableObservable ?
|
|
@@ -661,7 +745,18 @@ export class ObservableQuery {
|
|
|
661
745
|
// We want to ensure we can re-run the custom document transforms the next
|
|
662
746
|
// time a request is made against the original query.
|
|
663
747
|
const query = this.transformDocument(options.query);
|
|
748
|
+
const { fetchPolicy } = options;
|
|
664
749
|
this.lastQuery = query;
|
|
750
|
+
// Reevaluate variables to allow resetting variables with variables: undefined,
|
|
751
|
+
// otherwise `compact` will ignore the `variables` key in `newOptions`. We
|
|
752
|
+
// do this after we run the query transform to ensure we get default
|
|
753
|
+
// variables from the transformed query.
|
|
754
|
+
//
|
|
755
|
+
// Note: updating options.variables may mutate this.options.variables
|
|
756
|
+
// in the case of a non-disposable query. This is intentional.
|
|
757
|
+
if (newOptions && "variables" in newOptions) {
|
|
758
|
+
options.variables = this.getVariablesWithDefaults(newOptions.variables);
|
|
759
|
+
}
|
|
665
760
|
if (!useDisposableObservable) {
|
|
666
761
|
// We can skip calling updatePolling if we're not changing this.options.
|
|
667
762
|
this.updatePolling();
|
|
@@ -671,10 +766,10 @@ export class ObservableQuery {
|
|
|
671
766
|
newOptions.variables &&
|
|
672
767
|
!equal(newOptions.variables, oldVariables) &&
|
|
673
768
|
// Don't mess with the fetchPolicy if it's currently "standby".
|
|
674
|
-
|
|
769
|
+
fetchPolicy !== "standby" &&
|
|
675
770
|
// If we're changing the fetchPolicy anyway, don't try to change it here
|
|
676
771
|
// using applyNextFetchPolicy. The explicit options.fetchPolicy wins.
|
|
677
|
-
(
|
|
772
|
+
(fetchPolicy === oldFetchPolicy ||
|
|
678
773
|
// A `nextFetchPolicy` function has even higher priority, though,
|
|
679
774
|
// so in that case `applyNextFetchPolicy` must be called.
|
|
680
775
|
typeof options.nextFetchPolicy === "function")) {
|
|
@@ -692,6 +787,14 @@ export class ObservableQuery {
|
|
|
692
787
|
!equal(newOptions.variables, oldVariables)) {
|
|
693
788
|
newNetworkStatus = NetworkStatus.setVariables;
|
|
694
789
|
}
|
|
790
|
+
// QueryManager does not emit any values for standby fetch policies so we
|
|
791
|
+
// want ensure that the networkStatus remains ready.
|
|
792
|
+
if (fetchPolicy === "standby") {
|
|
793
|
+
newNetworkStatus = NetworkStatus.ready;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
796
|
+
if (fetchPolicy === "standby") {
|
|
797
|
+
this.cancelPolling();
|
|
695
798
|
}
|
|
696
799
|
this.networkStatus = newNetworkStatus;
|
|
697
800
|
this.waitForOwnResult &&= skipCacheDataFor(options.fetchPolicy);
|
|
@@ -700,8 +803,8 @@ export class ObservableQuery {
|
|
|
700
803
|
this.waitForOwnResult = false;
|
|
701
804
|
}
|
|
702
805
|
};
|
|
703
|
-
const variables =
|
|
704
|
-
const { notifyOnNetworkStatusChange =
|
|
806
|
+
const variables = { ...options.variables };
|
|
807
|
+
const { notifyOnNetworkStatusChange = true } = options;
|
|
705
808
|
const { observable, fromLink } = this.fetch(options, newNetworkStatus, notifyOnNetworkStatusChange &&
|
|
706
809
|
oldNetworkStatus !== newNetworkStatus &&
|
|
707
810
|
isNetworkRequestInFlight(newNetworkStatus), query);
|
|
@@ -733,7 +836,13 @@ export class ObservableQuery {
|
|
|
733
836
|
// Note: lastValueFrom will create a separate subscription to the
|
|
734
837
|
// observable which means that terminating this ObservableQuery will not
|
|
735
838
|
// cancel the request from the link chain.
|
|
736
|
-
lastValueFrom(observable
|
|
839
|
+
lastValueFrom(observable, {
|
|
840
|
+
// This default value should only be used when using a `fetchPolicy` of
|
|
841
|
+
// `standby` since that fetch policy completes without emitting a
|
|
842
|
+
// result. Since we are converting this to a QueryResult type, we
|
|
843
|
+
// omit the extra fields from ApolloQueryResult in the default value.
|
|
844
|
+
defaultValue: { data: undefined },
|
|
845
|
+
}).then((result) => toQueryResult(this.maskResult(result))));
|
|
737
846
|
}
|
|
738
847
|
// (Re)deliver the current result to this.observers without applying fetch
|
|
739
848
|
// policies or making network requests.
|
|
@@ -808,40 +917,96 @@ export class ObservableQuery {
|
|
|
808
917
|
}
|
|
809
918
|
: result;
|
|
810
919
|
}
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
920
|
+
dirty = false;
|
|
921
|
+
notifyTimeout;
|
|
922
|
+
/** @internal */
|
|
923
|
+
resetNotifications() {
|
|
924
|
+
this.cancelNotifyTimeout();
|
|
925
|
+
this.dirty = false;
|
|
926
|
+
}
|
|
927
|
+
cancelNotifyTimeout() {
|
|
928
|
+
if (this.notifyTimeout) {
|
|
929
|
+
clearTimeout(this.notifyTimeout);
|
|
930
|
+
this.notifyTimeout = void 0;
|
|
931
|
+
}
|
|
932
|
+
}
|
|
933
|
+
/** @internal */
|
|
934
|
+
scheduleNotify() {
|
|
935
|
+
if (this.dirty)
|
|
936
|
+
return;
|
|
937
|
+
this.dirty = true;
|
|
938
|
+
if (!this.notifyTimeout) {
|
|
939
|
+
this.notifyTimeout = setTimeout(() => this.notify(), 0);
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
/** @internal */
|
|
943
|
+
notify() {
|
|
944
|
+
this.cancelNotifyTimeout();
|
|
945
|
+
if (this.dirty) {
|
|
946
|
+
if (this.options.fetchPolicy == "cache-only" ||
|
|
947
|
+
this.options.fetchPolicy == "cache-and-network" ||
|
|
948
|
+
!isNetworkRequestInFlight(this.networkStatus)) {
|
|
949
|
+
const diff = this.queryInfo.getDiff();
|
|
950
|
+
if (diff.fromOptimisticTransaction) {
|
|
951
|
+
// If this diff came from an optimistic transaction, deliver the
|
|
952
|
+
// current cache data to the ObservableQuery, but don't perform a
|
|
953
|
+
// reobservation, since oq.reobserveCacheFirst might make a network
|
|
954
|
+
// request, and we never want to trigger network requests in the
|
|
955
|
+
// middle of optimistic updates.
|
|
956
|
+
this.observe();
|
|
834
957
|
}
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
958
|
+
else {
|
|
959
|
+
// Otherwise, make the ObservableQuery "reobserve" the latest data
|
|
960
|
+
// using a temporary fetch policy of "cache-first", so complete cache
|
|
961
|
+
// results have a chance to be delivered without triggering additional
|
|
962
|
+
// network requests, even when options.fetchPolicy is "network-only"
|
|
963
|
+
// or "cache-and-network". All other fetch policies are preserved by
|
|
964
|
+
// this method, and are handled by calling oq.reobserve(). If this
|
|
965
|
+
// reobservation is spurious, isDifferentFromLastResult still has a
|
|
966
|
+
// chance to catch it before delivery to ObservableQuery subscribers.
|
|
967
|
+
this.reobserveCacheFirst();
|
|
968
|
+
}
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
this.dirty = false;
|
|
972
|
+
}
|
|
973
|
+
// Reobserve with fetchPolicy effectively set to "cache-first", triggering
|
|
974
|
+
// delivery of any new data from the cache, possibly falling back to the network
|
|
975
|
+
// if any cache data are missing. This allows _complete_ cache results to be
|
|
976
|
+
// delivered without also kicking off unnecessary network requests when
|
|
977
|
+
// this.options.fetchPolicy is "cache-and-network" or "network-only". When
|
|
978
|
+
// this.options.fetchPolicy is any other policy ("cache-first", "cache-only",
|
|
979
|
+
// "standby", or "no-cache"), we call this.reobserve() as usual.
|
|
980
|
+
reobserveCacheFirst() {
|
|
981
|
+
const { fetchPolicy, nextFetchPolicy } = this.options;
|
|
982
|
+
if (fetchPolicy === "cache-and-network" || fetchPolicy === "network-only") {
|
|
983
|
+
return this.reobserve({
|
|
984
|
+
fetchPolicy: "cache-first",
|
|
985
|
+
// Use a temporary nextFetchPolicy function that replaces itself with the
|
|
986
|
+
// previous nextFetchPolicy value and returns the original fetchPolicy.
|
|
987
|
+
nextFetchPolicy(currentFetchPolicy, context) {
|
|
988
|
+
// Replace this nextFetchPolicy function in the options object with the
|
|
989
|
+
// original this.options.nextFetchPolicy value.
|
|
990
|
+
this.nextFetchPolicy = nextFetchPolicy;
|
|
991
|
+
// If the original nextFetchPolicy value was a function, give it a
|
|
992
|
+
// chance to decide what happens here.
|
|
993
|
+
if (typeof this.nextFetchPolicy === "function") {
|
|
994
|
+
return this.nextFetchPolicy(currentFetchPolicy, context);
|
|
995
|
+
}
|
|
996
|
+
// Otherwise go back to the original this.options.fetchPolicy.
|
|
997
|
+
return fetchPolicy;
|
|
998
|
+
},
|
|
999
|
+
});
|
|
1000
|
+
}
|
|
1001
|
+
return this.reobserve();
|
|
1002
|
+
}
|
|
1003
|
+
getVariablesWithDefaults(variables) {
|
|
1004
|
+
return this.queryManager.getVariables(this.query, variables);
|
|
839
1005
|
}
|
|
840
|
-
return obsQuery.reobserve();
|
|
841
1006
|
}
|
|
842
1007
|
export function logMissingFieldErrors(missing) {
|
|
843
1008
|
if (__DEV__ && missing) {
|
|
844
|
-
__DEV__ && invariant.debug(
|
|
1009
|
+
__DEV__ && invariant.debug(73, missing);
|
|
845
1010
|
}
|
|
846
1011
|
}
|
|
847
1012
|
function skipCacheDataFor(fetchPolicy /* `undefined` would mean `"cache-first"` */) {
|