@apollo/client 4.0.9 → 4.1.2
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/CHANGELOG.md +445 -0
- package/__cjs/cache/core/cache.cjs +217 -52
- package/__cjs/cache/core/cache.cjs.map +1 -1
- package/__cjs/cache/core/cache.d.cts +141 -25
- package/__cjs/cache/core/types/Cache.d.cts +78 -17
- package/__cjs/cache/index.cjs.map +1 -1
- package/__cjs/cache/index.d.cts +1 -1
- package/__cjs/cache/inmemory/entityStore.cjs +6 -4
- package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/fragmentRegistry.cjs +5 -0
- package/__cjs/cache/inmemory/fragmentRegistry.cjs.map +1 -1
- package/__cjs/cache/inmemory/helpers.d.cts +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.cjs +62 -1
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.d.cts +48 -0
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/key-extractor.cjs.map +1 -1
- package/__cjs/cache/inmemory/policies.cjs +76 -17
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/policies.d.cts +33 -6
- package/__cjs/cache/inmemory/readFromStore.cjs +9 -8
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/types.d.cts +3 -0
- package/__cjs/cache/inmemory/writeToStore.cjs +25 -10
- package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/writeToStore.d.cts +1 -1
- package/__cjs/core/ApolloClient.cjs +31 -49
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +159 -18
- package/__cjs/core/ObservableQuery.cjs +178 -131
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +2 -0
- package/__cjs/core/QueryInfo.cjs +9 -1
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +4 -3
- package/__cjs/core/QueryManager.cjs +47 -25
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +19 -2
- package/__cjs/incremental/handlers/defer20220824.cjs +44 -19
- package/__cjs/incremental/handlers/defer20220824.cjs.map +1 -1
- package/__cjs/incremental/handlers/defer20220824.d.cts +15 -7
- package/__cjs/incremental/handlers/graphql17Alpha9.cjs +227 -0
- package/__cjs/incremental/handlers/graphql17Alpha9.cjs.map +1 -0
- package/__cjs/incremental/handlers/graphql17Alpha9.d.cts +98 -0
- package/__cjs/incremental/handlers/notImplemented.cjs +1 -1
- package/__cjs/incremental/handlers/notImplemented.cjs.map +1 -1
- package/__cjs/incremental/index.cjs +3 -1
- package/__cjs/incremental/index.cjs.map +1 -1
- package/__cjs/incremental/index.d.cts +1 -0
- package/__cjs/incremental/types.d.cts +9 -0
- package/__cjs/invariantErrorCodes.cjs +83 -61
- package/__cjs/link/client-awareness/ClientAwarenessLink.cjs +13 -1
- package/__cjs/link/client-awareness/ClientAwarenessLink.cjs.map +1 -1
- package/__cjs/link/client-awareness/ClientAwarenessLink.d.cts +1 -1
- package/__cjs/link/core/ApolloLink.cjs +3 -3
- package/__cjs/link/error/index.cjs +1 -1
- package/__cjs/link/error/index.cjs.map +1 -1
- package/__cjs/link/error/index.d.cts +1 -1
- package/__cjs/link/http/checkFetcher.cjs +1 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs +2 -2
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs.map +1 -1
- package/__cjs/link/persisted-queries/index.cjs +2 -2
- package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs +51 -50
- package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs.map +1 -1
- package/__cjs/link/remove-typename/removeTypenameFromVariables.d.cts +3 -0
- package/__cjs/link/schema/index.cjs +1 -1
- package/__cjs/link/schema/index.cjs.map +1 -1
- package/__cjs/link/schema/index.d.cts +1 -1
- package/__cjs/link/ws/index.cjs +1 -1
- package/__cjs/local-state/LocalState.cjs +29 -15
- package/__cjs/local-state/LocalState.cjs.map +1 -1
- package/__cjs/local-state/LocalState.d.cts +3 -2
- package/__cjs/masking/types.d.cts +2 -1
- package/__cjs/react/hooks/internal/useDeepMemo.cjs +2 -0
- package/__cjs/react/hooks/internal/useDeepMemo.cjs.map +1 -1
- package/__cjs/react/hooks/useApolloClient.cjs +1 -1
- package/__cjs/react/hooks/useApolloClient.cjs.map +1 -1
- package/__cjs/react/hooks/useApolloClient.d.cts +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.cjs +1 -3
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useFragment.cjs +38 -87
- package/__cjs/react/hooks/useFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useFragment.d.cts +65 -6
- package/__cjs/react/hooks/useLazyQuery.cjs +3 -0
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.cjs +7 -1
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +13 -1
- package/__cjs/react/hooks/useQuery.cjs +8 -8
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +1 -1
- package/__cjs/react/hooks/useQueryRefHandlers.cjs +1 -3
- package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
- package/__cjs/react/hooks/useReadQuery.cjs +1 -3
- package/__cjs/react/hooks/useReadQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSubscription.cjs +1 -1
- package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseFragment.cjs +16 -16
- package/__cjs/react/hooks/useSuspenseFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseFragment.d.cts +33 -7
- package/__cjs/react/hooks/useSuspenseQuery.cjs +6 -4
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/internal/cache/FragmentReference.cjs +3 -22
- package/__cjs/react/internal/cache/FragmentReference.cjs.map +1 -1
- package/__cjs/react/internal/cache/FragmentReference.d.cts +2 -4
- package/__cjs/react/internal/cache/QueryReference.cjs +16 -0
- package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
- package/__cjs/react/internal/cache/QueryReference.d.cts +5 -0
- package/__cjs/react/internal/cache/SuspenseCache.cjs.map +1 -1
- package/__cjs/react/internal/cache/SuspenseCache.d.cts +1 -1
- package/__cjs/react/internal/cache/types.d.cts +2 -2
- package/__cjs/react/query-preloader/createQueryPreloader.cjs +41 -1
- package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
- package/__cjs/react/ssr/prerenderStatic.cjs +17 -4
- package/__cjs/react/ssr/prerenderStatic.cjs.map +1 -1
- package/__cjs/react/ssr/prerenderStatic.d.cts +23 -4
- package/__cjs/react/ssr/useSSRQuery.cjs +7 -4
- package/__cjs/react/ssr/useSSRQuery.cjs.map +1 -1
- package/__cjs/react/ssr/useSSRQuery.d.cts +2 -1
- package/__cjs/utilities/DeepPartial.cjs.map +1 -1
- package/__cjs/utilities/DeepPartial.d.cts +1 -1
- package/__cjs/utilities/internal/DeepMerger.cjs +36 -4
- package/__cjs/utilities/internal/DeepMerger.cjs.map +1 -1
- package/__cjs/utilities/internal/DeepMerger.d.cts +20 -4
- package/__cjs/utilities/internal/bindCacheKey.cjs +21 -0
- package/__cjs/utilities/internal/bindCacheKey.cjs.map +1 -0
- package/__cjs/utilities/internal/bindCacheKey.d.cts +15 -0
- package/__cjs/utilities/internal/checkDocument.cjs +2 -4
- package/__cjs/utilities/internal/checkDocument.cjs.map +1 -1
- package/__cjs/utilities/internal/combineLatestBatched.cjs +71 -0
- package/__cjs/utilities/internal/combineLatestBatched.cjs.map +1 -0
- package/__cjs/utilities/internal/combineLatestBatched.d.cts +14 -0
- package/__cjs/utilities/internal/compact.cjs +1 -1
- package/__cjs/utilities/internal/compact.cjs.map +1 -1
- package/__cjs/utilities/internal/constants.cjs +26 -0
- package/__cjs/utilities/internal/constants.cjs.map +1 -0
- package/__cjs/utilities/internal/constants.d.cts +23 -0
- package/__cjs/utilities/internal/getStoreKeyName.cjs +1 -0
- package/__cjs/utilities/internal/getStoreKeyName.cjs.map +1 -1
- package/__cjs/utilities/internal/index.cjs +12 -2
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +6 -0
- package/__cjs/utilities/internal/mapObservableFragment.cjs +27 -0
- package/__cjs/utilities/internal/mapObservableFragment.cjs.map +1 -0
- package/__cjs/utilities/internal/mapObservableFragment.d.cts +3 -0
- package/__cjs/utilities/internal/memoize.cjs +31 -0
- package/__cjs/utilities/internal/memoize.cjs.map +1 -0
- package/__cjs/utilities/internal/memoize.d.cts +8 -0
- package/__cjs/utilities/internal/ponyfills/FinalizationRegistry.cjs +61 -0
- package/__cjs/utilities/internal/ponyfills/FinalizationRegistry.cjs.map +1 -0
- package/__cjs/utilities/internal/ponyfills/FinalizationRegistry.d.cts +11 -0
- package/__cjs/utilities/internal/ponyfills/index.cjs +6 -0
- package/__cjs/utilities/internal/ponyfills/index.cjs.map +1 -0
- package/__cjs/utilities/internal/ponyfills/index.d.cts +3 -0
- package/__cjs/utilities/internal/ponyfills/index.react-native.cjs +6 -0
- package/__cjs/utilities/internal/ponyfills/index.react-native.cjs.map +1 -0
- package/__cjs/utilities/internal/ponyfills/index.react-native.d.cts +2 -0
- package/__cjs/utilities/internal/types/ExtensionsWithStreamDetails.cjs +3 -0
- package/__cjs/utilities/internal/types/ExtensionsWithStreamDetails.cjs.map +1 -0
- package/__cjs/utilities/internal/types/ExtensionsWithStreamDetails.d.cts +12 -0
- package/__cjs/utilities/internal/types/StreamInfoTrie.cjs +3 -0
- package/__cjs/utilities/internal/types/StreamInfoTrie.cjs.map +1 -0
- package/__cjs/utilities/internal/types/StreamInfoTrie.d.cts +16 -0
- package/__cjs/version.cjs +1 -1
- package/cache/core/cache.d.ts +141 -25
- package/cache/core/cache.js +220 -55
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +78 -17
- package/cache/core/types/Cache.js.map +1 -1
- package/cache/index.d.ts +1 -1
- package/cache/index.js.map +1 -1
- package/cache/inmemory/entityStore.js +6 -4
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/fragmentRegistry.js +6 -1
- package/cache/inmemory/fragmentRegistry.js.map +1 -1
- package/cache/inmemory/helpers.d.ts +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +48 -0
- package/cache/inmemory/inMemoryCache.js +62 -1
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/key-extractor.js.map +1 -1
- package/cache/inmemory/policies.d.ts +33 -6
- package/cache/inmemory/policies.js +65 -7
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.js +9 -8
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +3 -0
- package/cache/inmemory/types.js.map +1 -1
- package/cache/inmemory/writeToStore.d.ts +1 -1
- package/cache/inmemory/writeToStore.js +27 -12
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.d.ts +159 -18
- package/core/ApolloClient.js +32 -50
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +2 -0
- package/core/ObservableQuery.js +181 -134
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +4 -3
- package/core/QueryInfo.js +10 -2
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +19 -2
- package/core/QueryManager.js +48 -26
- package/core/QueryManager.js.map +1 -1
- package/incremental/handlers/defer20220824.d.ts +15 -7
- package/incremental/handlers/defer20220824.js +44 -19
- package/incremental/handlers/defer20220824.js.map +1 -1
- package/incremental/handlers/graphql17Alpha9.d.ts +98 -0
- package/incremental/handlers/graphql17Alpha9.js +223 -0
- package/incremental/handlers/graphql17Alpha9.js.map +1 -0
- package/incremental/handlers/notImplemented.js +1 -1
- package/incremental/handlers/notImplemented.js.map +1 -1
- package/incremental/index.d.ts +1 -0
- package/incremental/index.js +3 -2
- package/incremental/index.js.map +1 -1
- package/incremental/types.d.ts +9 -0
- package/incremental/types.js.map +1 -1
- package/invariantErrorCodes.js +83 -61
- package/legacyEntryPoints/utilities/internal/ponyfills/index.d.ts +1 -0
- package/legacyEntryPoints/utilities/internal/ponyfills/index.js +1 -0
- package/legacyEntryPoints/utilities/internal/ponyfills/ponyfills.cjs +1 -0
- package/legacyEntryPoints/utilities/internal/ponyfills/ponyfills.d.cts +1 -0
- package/link/client-awareness/ClientAwarenessLink.d.ts +1 -1
- package/link/client-awareness/ClientAwarenessLink.js +13 -1
- package/link/client-awareness/ClientAwarenessLink.js.map +1 -1
- package/link/core/ApolloLink.js +3 -3
- package/link/error/index.d.ts +1 -1
- package/link/error/index.js +1 -1
- package/link/error/index.js.map +1 -1
- package/link/http/checkFetcher.js +1 -1
- package/link/http/parseAndCheckHttpResponse.js +2 -2
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/persisted-queries/index.js +2 -2
- package/link/remove-typename/removeTypenameFromVariables.d.ts +3 -0
- package/link/remove-typename/removeTypenameFromVariables.js +51 -50
- package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
- package/link/schema/index.d.ts +1 -1
- package/link/schema/index.js +1 -1
- package/link/schema/index.js.map +1 -1
- package/link/ws/index.js +1 -1
- package/local-state/LocalState.d.ts +3 -2
- package/local-state/LocalState.js +29 -15
- package/local-state/LocalState.js.map +1 -1
- package/masking/types.d.ts +2 -1
- package/masking/types.js.map +1 -1
- package/package.json +15 -1
- package/react/hooks/internal/useDeepMemo.js +2 -0
- package/react/hooks/internal/useDeepMemo.js.map +1 -1
- package/react/hooks/useApolloClient.d.ts +1 -1
- package/react/hooks/useApolloClient.js +1 -1
- package/react/hooks/useApolloClient.js.map +1 -1
- package/react/hooks/useBackgroundQuery.js +1 -3
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useFragment.d.ts +65 -6
- package/react/hooks/useFragment.js +38 -87
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.js +4 -1
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +13 -1
- package/react/hooks/useMutation.js +7 -1
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.js +9 -9
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.js +1 -3
- package/react/hooks/useQueryRefHandlers.js.map +1 -1
- package/react/hooks/useReadQuery.js +1 -3
- package/react/hooks/useReadQuery.js.map +1 -1
- package/react/hooks/useSubscription.js +1 -1
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseFragment.d.ts +33 -7
- package/react/hooks/useSuspenseFragment.js +17 -17
- package/react/hooks/useSuspenseFragment.js.map +1 -1
- package/react/hooks/useSuspenseQuery.js +6 -4
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/internal/useDeepMemo.js +2 -0
- package/react/hooks-compiled/internal/useDeepMemo.js.map +1 -1
- package/react/hooks-compiled/internal/useSuspenseHookCacheKey.js +0 -2
- package/react/hooks-compiled/internal/useSuspenseHookCacheKey.js.map +1 -1
- package/react/hooks-compiled/useApolloClient.d.ts +1 -1
- package/react/hooks-compiled/useApolloClient.js +1 -1
- package/react/hooks-compiled/useApolloClient.js.map +1 -1
- package/react/hooks-compiled/useBackgroundQuery.js +1 -3
- package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
- package/react/hooks-compiled/useFragment.d.ts +65 -6
- package/react/hooks-compiled/useFragment.js +110 -88
- package/react/hooks-compiled/useFragment.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.js +4 -1
- package/react/hooks-compiled/useLazyQuery.js.map +1 -1
- package/react/hooks-compiled/useLoadableQuery.js +69 -75
- package/react/hooks-compiled/useMutation.d.ts +13 -1
- package/react/hooks-compiled/useMutation.js +5 -13
- package/react/hooks-compiled/useMutation.js.map +1 -1
- package/react/hooks-compiled/useQuery.js +53 -61
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/hooks-compiled/useQueryRefHandlers.js +1 -5
- package/react/hooks-compiled/useQueryRefHandlers.js.map +1 -1
- package/react/hooks-compiled/useReadQuery.js +77 -14
- package/react/hooks-compiled/useReadQuery.js.map +1 -1
- package/react/hooks-compiled/useSubscription.js +237 -93
- package/react/hooks-compiled/useSubscription.js.map +1 -1
- package/react/hooks-compiled/useSuspenseFragment.d.ts +33 -7
- package/react/hooks-compiled/useSuspenseFragment.js +17 -17
- package/react/hooks-compiled/useSuspenseFragment.js.map +1 -1
- package/react/hooks-compiled/useSuspenseQuery.js +7 -9
- package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
- package/react/index.compiled.d.ts +1 -1
- package/react/index.compiled.js +1 -1
- package/react/index.compiled.js.map +1 -1
- package/react/internal/cache/FragmentReference.d.ts +2 -4
- package/react/internal/cache/FragmentReference.js +3 -22
- package/react/internal/cache/FragmentReference.js.map +1 -1
- package/react/internal/cache/QueryReference.d.ts +5 -0
- package/react/internal/cache/QueryReference.js +16 -0
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/internal/cache/SuspenseCache.d.ts +1 -1
- package/react/internal/cache/SuspenseCache.js.map +1 -1
- package/react/internal/cache/types.d.ts +2 -2
- package/react/internal/cache/types.js.map +1 -1
- package/react/query-preloader/createQueryPreloader.js +41 -1
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/ssr/prerenderStatic.d.ts +24 -5
- package/react/ssr/prerenderStatic.js +17 -4
- package/react/ssr/prerenderStatic.js.map +1 -1
- package/react/ssr/useSSRQuery.d.ts +2 -1
- package/react/ssr/useSSRQuery.js +8 -5
- package/react/ssr/useSSRQuery.js.map +1 -1
- package/utilities/DeepPartial.d.ts +1 -1
- package/utilities/DeepPartial.js.map +1 -1
- package/utilities/internal/DeepMerger.d.ts +20 -4
- package/utilities/internal/DeepMerger.js +36 -4
- package/utilities/internal/DeepMerger.js.map +1 -1
- package/utilities/internal/bindCacheKey.d.ts +15 -0
- package/utilities/internal/bindCacheKey.js +18 -0
- package/utilities/internal/bindCacheKey.js.map +1 -0
- package/utilities/internal/checkDocument.js +2 -4
- package/utilities/internal/checkDocument.js.map +1 -1
- package/utilities/internal/combineLatestBatched.d.ts +14 -0
- package/utilities/internal/combineLatestBatched.js +68 -0
- package/utilities/internal/combineLatestBatched.js.map +1 -0
- package/utilities/internal/compact.js +1 -1
- package/utilities/internal/compact.js.map +1 -1
- package/utilities/internal/constants.d.ts +23 -0
- package/utilities/internal/constants.js +23 -0
- package/utilities/internal/constants.js.map +1 -0
- package/utilities/internal/getStoreKeyName.js +1 -0
- package/utilities/internal/getStoreKeyName.js.map +1 -1
- package/utilities/internal/index.d.ts +6 -0
- package/utilities/internal/index.js +4 -0
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/mapObservableFragment.d.ts +3 -0
- package/utilities/internal/mapObservableFragment.js +24 -0
- package/utilities/internal/mapObservableFragment.js.map +1 -0
- package/utilities/internal/memoize.d.ts +8 -0
- package/utilities/internal/memoize.js +28 -0
- package/utilities/internal/memoize.js.map +1 -0
- package/utilities/internal/ponyfills/FinalizationRegistry.d.ts +11 -0
- package/utilities/internal/ponyfills/FinalizationRegistry.js +57 -0
- package/utilities/internal/ponyfills/FinalizationRegistry.js.map +1 -0
- package/utilities/internal/ponyfills/index.d.ts +3 -0
- package/utilities/internal/ponyfills/index.js +3 -0
- package/utilities/internal/ponyfills/index.js.map +1 -0
- package/utilities/internal/ponyfills/index.react-native.d.ts +2 -0
- package/utilities/internal/ponyfills/index.react-native.js +2 -0
- package/utilities/internal/ponyfills/index.react-native.js.map +1 -0
- package/utilities/internal/types/ExtensionsWithStreamDetails.d.ts +12 -0
- package/utilities/internal/types/ExtensionsWithStreamDetails.js +2 -0
- package/utilities/internal/types/ExtensionsWithStreamDetails.js.map +1 -0
- package/utilities/internal/types/StreamInfoTrie.d.ts +16 -0
- package/utilities/internal/types/StreamInfoTrie.js +2 -0
- package/utilities/internal/types/StreamInfoTrie.js.map +1 -0
- package/version.js +1 -1
package/core/ObservableQuery.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { equal } from "@wry/equality";
|
|
2
|
-
import { BehaviorSubject, Observable, share, Subject, tap } from "rxjs";
|
|
3
|
-
import { isNetworkRequestInFlight } from "@apollo/client/utilities";
|
|
2
|
+
import { BehaviorSubject, filter, Observable, share, Subject, tap } from "rxjs";
|
|
3
|
+
import { isNetworkRequestInFlight, isNetworkRequestSettled, } from "@apollo/client/utilities";
|
|
4
4
|
import { __DEV__ } from "@apollo/client/utilities/environment";
|
|
5
|
-
import { compact, equalByQuery, filterMap, getOperationDefinition, getOperationName, getQueryDefinition, preventUnhandledRejection, toQueryResult, } from "@apollo/client/utilities/internal";
|
|
5
|
+
import { compact, equalByQuery, extensionsSymbol, filterMap, getOperationDefinition, getOperationName, getQueryDefinition, preventUnhandledRejection, toQueryResult, variablesUnknownSymbol, } from "@apollo/client/utilities/internal";
|
|
6
6
|
import { invariant } from "@apollo/client/utilities/invariant";
|
|
7
7
|
import { NetworkStatus } from "./networkStatus.js";
|
|
8
8
|
const { assign, hasOwnProperty } = Object;
|
|
@@ -23,6 +23,7 @@ const empty = {
|
|
|
23
23
|
export class ObservableQuery {
|
|
24
24
|
options;
|
|
25
25
|
queryName;
|
|
26
|
+
variablesUnknown = false;
|
|
26
27
|
/**
|
|
27
28
|
* @internal will be read and written from `QueryInfo`
|
|
28
29
|
*
|
|
@@ -60,6 +61,9 @@ export class ObservableQuery {
|
|
|
60
61
|
get networkStatus() {
|
|
61
62
|
return this.subject.getValue().result.networkStatus;
|
|
62
63
|
}
|
|
64
|
+
get cache() {
|
|
65
|
+
return this.queryManager.cache;
|
|
66
|
+
}
|
|
63
67
|
constructor({ queryManager, options, transformedQuery = queryManager.transform(options.query), }) {
|
|
64
68
|
this.queryManager = queryManager;
|
|
65
69
|
// active state
|
|
@@ -71,6 +75,10 @@ export class ObservableQuery {
|
|
|
71
75
|
const { fetchPolicy = defaultFetchPolicy,
|
|
72
76
|
// Make sure we don't store "standby" as the initialFetchPolicy.
|
|
73
77
|
initialFetchPolicy = fetchPolicy === "standby" ? defaultFetchPolicy : (fetchPolicy), } = options;
|
|
78
|
+
if (options[variablesUnknownSymbol]) {
|
|
79
|
+
invariant(fetchPolicy === "standby", 80);
|
|
80
|
+
this.variablesUnknown = true;
|
|
81
|
+
}
|
|
74
82
|
this.lastQuery = transformedQuery;
|
|
75
83
|
this.options = {
|
|
76
84
|
...options,
|
|
@@ -197,7 +205,7 @@ export class ObservableQuery {
|
|
|
197
205
|
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
198
206
|
*/
|
|
199
207
|
getCacheDiff({ optimistic = true } = {}) {
|
|
200
|
-
return this.
|
|
208
|
+
return this.cache.diff({
|
|
201
209
|
query: this.query,
|
|
202
210
|
variables: this.variables,
|
|
203
211
|
returnPartialData: true,
|
|
@@ -205,9 +213,11 @@ export class ObservableQuery {
|
|
|
205
213
|
});
|
|
206
214
|
}
|
|
207
215
|
getInitialResult(initialFetchPolicy) {
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
216
|
+
let fetchPolicy = initialFetchPolicy || this.options.fetchPolicy;
|
|
217
|
+
if (this.queryManager.prioritizeCacheValues &&
|
|
218
|
+
(fetchPolicy === "network-only" || fetchPolicy === "cache-and-network")) {
|
|
219
|
+
fetchPolicy = "cache-first";
|
|
220
|
+
}
|
|
211
221
|
const cacheResult = () => {
|
|
212
222
|
const diff = this.getCacheDiff();
|
|
213
223
|
// TODO: queryInfo.getDiff should handle this since cache.diff returns a
|
|
@@ -308,7 +318,7 @@ export class ObservableQuery {
|
|
|
308
318
|
}
|
|
309
319
|
},
|
|
310
320
|
};
|
|
311
|
-
const cancelWatch = this.
|
|
321
|
+
const cancelWatch = this.cache.watch(watch);
|
|
312
322
|
this.unsubscribeFromCache = Object.assign(() => {
|
|
313
323
|
this.unsubscribeFromCache = undefined;
|
|
314
324
|
cancelWatch();
|
|
@@ -372,7 +382,7 @@ export class ObservableQuery {
|
|
|
372
382
|
const queryDef = getQueryDefinition(this.query);
|
|
373
383
|
const vars = queryDef.variableDefinitions;
|
|
374
384
|
if (!vars || !vars.some((v) => v.variable.name.value === "variables")) {
|
|
375
|
-
__DEV__ && invariant.warn(
|
|
385
|
+
__DEV__ && invariant.warn(81, variables, queryDef.name?.value || queryDef);
|
|
376
386
|
}
|
|
377
387
|
}
|
|
378
388
|
if (variables && !equal(this.variables, variables)) {
|
|
@@ -388,7 +398,7 @@ export class ObservableQuery {
|
|
|
388
398
|
fetchMore({ query, variables, context, errorPolicy, updateQuery, }) {
|
|
389
399
|
invariant(
|
|
390
400
|
this.options.fetchPolicy !== "cache-only",
|
|
391
|
-
|
|
401
|
+
82,
|
|
392
402
|
getOperationName(this.query, "(anonymous)")
|
|
393
403
|
);
|
|
394
404
|
const combinedOptions = {
|
|
@@ -422,7 +432,7 @@ export class ObservableQuery {
|
|
|
422
432
|
let wasUpdated = false;
|
|
423
433
|
const isCached = this.options.fetchPolicy !== "no-cache";
|
|
424
434
|
if (!isCached) {
|
|
425
|
-
invariant(updateQuery,
|
|
435
|
+
invariant(updateQuery, 83);
|
|
426
436
|
}
|
|
427
437
|
const { finalize, pushNotification } = this.pushOperation(NetworkStatus.fetchMore);
|
|
428
438
|
pushNotification({
|
|
@@ -430,109 +440,149 @@ export class ObservableQuery {
|
|
|
430
440
|
kind: "N",
|
|
431
441
|
value: {},
|
|
432
442
|
}, { shouldEmit: 3 /* EmitBehavior.networkStatusChange */ });
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
443
|
+
const { promise, operator } = getTrackingOperatorPromise();
|
|
444
|
+
const { observable } = this.queryManager.fetchObservableWithInfo(combinedOptions, { networkStatus: NetworkStatus.fetchMore, exposeExtensions: true });
|
|
445
|
+
const subscription = observable
|
|
446
|
+
.pipe(operator, filter((notification) => notification.kind === "N" && notification.source === "network"))
|
|
447
|
+
.subscribe({
|
|
448
|
+
next: (notification) => {
|
|
449
|
+
wasUpdated = false;
|
|
450
|
+
const fetchMoreResult = notification.value;
|
|
451
|
+
const extensions = fetchMoreResult[extensionsSymbol];
|
|
452
|
+
if (isNetworkRequestSettled(notification.value.networkStatus)) {
|
|
453
|
+
finalize();
|
|
454
|
+
}
|
|
455
|
+
if (isCached) {
|
|
456
|
+
// Separately getting a diff here before the batch - `onWatchUpdated` might be
|
|
457
|
+
// called with an `undefined` `lastDiff` on the watcher if the cache was just subscribed to.
|
|
458
|
+
const lastDiff = this.getCacheDiff();
|
|
459
|
+
// Performing this cache update inside a cache.batch transaction ensures
|
|
460
|
+
// any affected cache.watch watchers are notified at most once about any
|
|
461
|
+
// updates. Most watchers will be using the QueryInfo class, which
|
|
462
|
+
// responds to notifications by calling reobserveCacheFirst to deliver
|
|
463
|
+
// fetchMore cache results back to this ObservableQuery.
|
|
464
|
+
this.cache.batch({
|
|
465
|
+
update: (cache) => {
|
|
466
|
+
if (updateQuery) {
|
|
467
|
+
cache.updateQuery({
|
|
468
|
+
query: this.query,
|
|
469
|
+
variables: this.variables,
|
|
470
|
+
returnPartialData: true,
|
|
471
|
+
optimistic: false,
|
|
472
|
+
extensions,
|
|
473
|
+
}, (previous) => updateQuery(previous, {
|
|
474
|
+
fetchMoreResult: fetchMoreResult.data,
|
|
475
|
+
variables: combinedOptions.variables,
|
|
476
|
+
}));
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
// If we're using a field policy instead of updateQuery, the only
|
|
480
|
+
// thing we need to do is write the new data to the cache using
|
|
481
|
+
// combinedOptions.variables (instead of this.variables, which is
|
|
482
|
+
// what this.updateQuery uses, because it works by abusing the
|
|
483
|
+
// original field value, keyed by the original variables).
|
|
484
|
+
cache.writeQuery({
|
|
485
|
+
query: combinedOptions.query,
|
|
486
|
+
variables: combinedOptions.variables,
|
|
487
|
+
data: fetchMoreResult.data,
|
|
488
|
+
extensions,
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
},
|
|
492
|
+
onWatchUpdated: (watch, diff) => {
|
|
493
|
+
if (watch.watcher === this &&
|
|
494
|
+
!equal(diff.result, lastDiff.result)) {
|
|
495
|
+
wasUpdated = true;
|
|
496
|
+
const lastResult = this.getCurrentResult();
|
|
497
|
+
// Let the cache watch from resubscribeCache handle the final
|
|
498
|
+
// result
|
|
499
|
+
if (isNetworkRequestInFlight(fetchMoreResult.networkStatus)) {
|
|
500
|
+
pushNotification({
|
|
501
|
+
kind: "N",
|
|
502
|
+
source: "network",
|
|
503
|
+
value: {
|
|
504
|
+
...lastResult,
|
|
505
|
+
networkStatus: (fetchMoreResult.networkStatus ===
|
|
506
|
+
NetworkStatus.error) ?
|
|
507
|
+
NetworkStatus.ready
|
|
508
|
+
: fetchMoreResult.networkStatus,
|
|
509
|
+
// will be overwritten anyways, just here for types sake
|
|
510
|
+
loading: false,
|
|
511
|
+
data: diff.result,
|
|
512
|
+
dataState: fetchMoreResult.dataState === "streaming" ?
|
|
513
|
+
"streaming"
|
|
514
|
+
: "complete",
|
|
515
|
+
},
|
|
516
|
+
});
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
},
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
else {
|
|
523
|
+
// There is a possibility `lastResult` may not be set when
|
|
524
|
+
// `fetchMore` is called which would cause this to crash. This should
|
|
525
|
+
// only happen if we haven't previously reported a result. We don't
|
|
526
|
+
// quite know what the right behavior should be here since this block
|
|
527
|
+
// of code runs after the fetch result has executed on the network.
|
|
528
|
+
// We plan to let it crash in the meantime.
|
|
529
|
+
//
|
|
530
|
+
// If we get bug reports due to the `data` property access on
|
|
531
|
+
// undefined, this should give us a real-world scenario that we can
|
|
532
|
+
// use to test against and determine the right behavior. If we do end
|
|
533
|
+
// up changing this behavior, this may require, for example, an
|
|
534
|
+
// adjustment to the types on `updateQuery` since that function
|
|
535
|
+
// expects that the first argument always contains previous result
|
|
536
|
+
// data, but not `undefined`.
|
|
537
|
+
const lastResult = this.getCurrentResult();
|
|
538
|
+
const data = updateQuery(lastResult.data, {
|
|
539
|
+
fetchMoreResult: fetchMoreResult.data,
|
|
540
|
+
variables: combinedOptions.variables,
|
|
541
|
+
});
|
|
542
|
+
pushNotification({
|
|
543
|
+
kind: "N",
|
|
544
|
+
value: {
|
|
545
|
+
...lastResult,
|
|
546
|
+
networkStatus: NetworkStatus.ready,
|
|
547
|
+
// will be overwritten anyways, just here for types sake
|
|
548
|
+
loading: false,
|
|
549
|
+
data: data,
|
|
550
|
+
dataState: lastResult.dataState === "streaming" ?
|
|
551
|
+
"streaming"
|
|
552
|
+
: "complete",
|
|
553
|
+
},
|
|
554
|
+
source: "network",
|
|
555
|
+
});
|
|
556
|
+
}
|
|
557
|
+
},
|
|
558
|
+
});
|
|
559
|
+
return preventUnhandledRejection(promise
|
|
560
|
+
.then((result) => toQueryResult(this.maskResult(result)))
|
|
520
561
|
.finally(() => {
|
|
521
|
-
|
|
562
|
+
subscription.unsubscribe();
|
|
522
563
|
finalize();
|
|
523
|
-
// In case the cache writes above did not generate a broadcast
|
|
524
|
-
// notification (which would have been intercepted by onWatchUpdated),
|
|
525
|
-
// likely because the written data were the same as what was already in
|
|
526
|
-
// the cache, we still want fetchMore to deliver its final loading:false
|
|
527
|
-
// result with the unchanged data.
|
|
528
564
|
if (isCached && !wasUpdated) {
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
565
|
+
const lastResult = this.getCurrentResult();
|
|
566
|
+
if (lastResult.dataState === "streaming") {
|
|
567
|
+
pushNotification({
|
|
568
|
+
kind: "N",
|
|
569
|
+
source: "network",
|
|
570
|
+
value: {
|
|
571
|
+
...lastResult,
|
|
572
|
+
dataState: "complete",
|
|
573
|
+
networkStatus: NetworkStatus.ready,
|
|
574
|
+
},
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
else {
|
|
578
|
+
pushNotification({
|
|
579
|
+
kind: "N",
|
|
580
|
+
source: "newNetworkStatus",
|
|
581
|
+
value: {},
|
|
582
|
+
}, { shouldEmit: 1 /* EmitBehavior.force */ });
|
|
583
|
+
}
|
|
534
584
|
}
|
|
535
|
-
});
|
|
585
|
+
}));
|
|
536
586
|
}
|
|
537
587
|
// XXX the subscription variables are separate from the query variables.
|
|
538
588
|
// if you want to update subscription variables, right now you have to do that separately,
|
|
@@ -558,7 +608,7 @@ export class ObservableQuery {
|
|
|
558
608
|
onError(error);
|
|
559
609
|
}
|
|
560
610
|
else {
|
|
561
|
-
invariant.error(
|
|
611
|
+
invariant.error(84, error);
|
|
562
612
|
}
|
|
563
613
|
return;
|
|
564
614
|
}
|
|
@@ -636,7 +686,7 @@ export class ObservableQuery {
|
|
|
636
686
|
previousData: result,
|
|
637
687
|
});
|
|
638
688
|
if (newResult) {
|
|
639
|
-
|
|
689
|
+
this.cache.writeQuery({
|
|
640
690
|
query: this.options.query,
|
|
641
691
|
data: newResult,
|
|
642
692
|
variables: this.variables,
|
|
@@ -802,7 +852,7 @@ export class ObservableQuery {
|
|
|
802
852
|
if (!this.didWarnCacheOnlyPolling &&
|
|
803
853
|
pollInterval &&
|
|
804
854
|
fetchPolicy === "cache-only") {
|
|
805
|
-
__DEV__ && invariant.warn(
|
|
855
|
+
__DEV__ && invariant.warn(85, getOperationName(this.query, "(anonymous)"));
|
|
806
856
|
this.didWarnCacheOnlyPolling = true;
|
|
807
857
|
}
|
|
808
858
|
}
|
|
@@ -877,6 +927,10 @@ export class ObservableQuery {
|
|
|
877
927
|
const oldVariables = this.variables;
|
|
878
928
|
const oldFetchPolicy = this.options.fetchPolicy;
|
|
879
929
|
const mergedOptions = compact(this.options, newOptions || {});
|
|
930
|
+
// This request will hit the network, so even if there are no variables,
|
|
931
|
+
// we now know that's intentional. (see #12996)
|
|
932
|
+
// Even if that happens only once, we want `variablesUnknown` to stay false permanently.
|
|
933
|
+
this.variablesUnknown &&= mergedOptions.fetchPolicy === "standby";
|
|
880
934
|
const options = useDisposableObservable ?
|
|
881
935
|
// Disposable Observable fetches receive a shallow copy of this.options
|
|
882
936
|
// (merged with newOptions), leaving this.options unmodified.
|
|
@@ -939,15 +993,7 @@ export class ObservableQuery {
|
|
|
939
993
|
this.cancelPolling();
|
|
940
994
|
}
|
|
941
995
|
this.resubscribeCache();
|
|
942
|
-
const { promise, operator: promiseOperator } = getTrackingOperatorPromise(
|
|
943
|
-
switch (value.kind) {
|
|
944
|
-
case "E":
|
|
945
|
-
throw value.error;
|
|
946
|
-
case "N":
|
|
947
|
-
if (value.source !== "newNetworkStatus" && !value.value.loading)
|
|
948
|
-
return value.value;
|
|
949
|
-
}
|
|
950
|
-
},
|
|
996
|
+
const { promise, operator: promiseOperator } = getTrackingOperatorPromise(
|
|
951
997
|
// This default value should only be used when using a `fetchPolicy` of
|
|
952
998
|
// `standby` since that fetch policy completes without emitting a
|
|
953
999
|
// result. Since we are converting this to a QueryResult type, we
|
|
@@ -1069,8 +1115,8 @@ export class ObservableQuery {
|
|
|
1069
1115
|
const { dirty } = this;
|
|
1070
1116
|
this.resetNotifications();
|
|
1071
1117
|
if (dirty &&
|
|
1072
|
-
(this.options.fetchPolicy
|
|
1073
|
-
this.options.fetchPolicy
|
|
1118
|
+
(this.options.fetchPolicy === "cache-only" ||
|
|
1119
|
+
this.options.fetchPolicy === "cache-and-network" ||
|
|
1074
1120
|
!this.activeOperations.size)) {
|
|
1075
1121
|
const diff = this.getCacheDiff();
|
|
1076
1122
|
if (
|
|
@@ -1154,7 +1200,9 @@ export class ObservableQuery {
|
|
|
1154
1200
|
// "fetchMore" having priority over "polling" or "loading" network statuses
|
|
1155
1201
|
// as for now we just take the "latest" operation that is still active,
|
|
1156
1202
|
// as that lines up best with previous behavior[]
|
|
1157
|
-
const operation = Array.from(this.activeOperations.values())
|
|
1203
|
+
const operation = Array.from(this.activeOperations.values())
|
|
1204
|
+
.reverse()
|
|
1205
|
+
.find((operation) => isEqualQuery(operation, this) && operation.override !== undefined);
|
|
1158
1206
|
return operation?.override ?? baseNetworkStatus;
|
|
1159
1207
|
}
|
|
1160
1208
|
abortActiveOperations() {
|
|
@@ -1298,13 +1346,13 @@ export class ObservableQuery {
|
|
|
1298
1346
|
}
|
|
1299
1347
|
export function logMissingFieldErrors(missing) {
|
|
1300
1348
|
if (__DEV__ && missing) {
|
|
1301
|
-
__DEV__ && invariant.debug(
|
|
1349
|
+
__DEV__ && invariant.debug(86, missing);
|
|
1302
1350
|
}
|
|
1303
1351
|
}
|
|
1304
1352
|
function isEqualQuery(a, b) {
|
|
1305
1353
|
return !!(a && b && a.query === b.query && equal(a.variables, b.variables));
|
|
1306
1354
|
}
|
|
1307
|
-
function getTrackingOperatorPromise(
|
|
1355
|
+
function getTrackingOperatorPromise(defaultValue) {
|
|
1308
1356
|
let lastValue = defaultValue, resolve, reject;
|
|
1309
1357
|
const promise = new Promise((res, rej) => {
|
|
1310
1358
|
resolve = res;
|
|
@@ -1312,14 +1360,13 @@ function getTrackingOperatorPromise(filterMapCb, defaultValue) {
|
|
|
1312
1360
|
});
|
|
1313
1361
|
const operator = tap({
|
|
1314
1362
|
next(value) {
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
if (newValue !== undefined) {
|
|
1318
|
-
lastValue = newValue;
|
|
1319
|
-
}
|
|
1363
|
+
if (value.kind === "E") {
|
|
1364
|
+
return reject(value.error);
|
|
1320
1365
|
}
|
|
1321
|
-
|
|
1322
|
-
|
|
1366
|
+
if (value.kind === "N" &&
|
|
1367
|
+
value.source !== "newNetworkStatus" &&
|
|
1368
|
+
!value.value.loading) {
|
|
1369
|
+
lastValue = value.value;
|
|
1323
1370
|
}
|
|
1324
1371
|
},
|
|
1325
1372
|
finalize: () => {
|