@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
|
@@ -31,6 +31,7 @@ const empty = {
|
|
|
31
31
|
class ObservableQuery {
|
|
32
32
|
options;
|
|
33
33
|
queryName;
|
|
34
|
+
variablesUnknown = false;
|
|
34
35
|
/**
|
|
35
36
|
* @internal will be read and written from `QueryInfo`
|
|
36
37
|
*
|
|
@@ -68,6 +69,9 @@ class ObservableQuery {
|
|
|
68
69
|
get networkStatus() {
|
|
69
70
|
return this.subject.getValue().result.networkStatus;
|
|
70
71
|
}
|
|
72
|
+
get cache() {
|
|
73
|
+
return this.queryManager.cache;
|
|
74
|
+
}
|
|
71
75
|
constructor({ queryManager, options, transformedQuery = queryManager.transform(options.query), }) {
|
|
72
76
|
this.queryManager = queryManager;
|
|
73
77
|
// active state
|
|
@@ -79,6 +83,10 @@ class ObservableQuery {
|
|
|
79
83
|
const { fetchPolicy = defaultFetchPolicy,
|
|
80
84
|
// Make sure we don't store "standby" as the initialFetchPolicy.
|
|
81
85
|
initialFetchPolicy = fetchPolicy === "standby" ? defaultFetchPolicy : (fetchPolicy), } = options;
|
|
86
|
+
if (options[internal_1.variablesUnknownSymbol]) {
|
|
87
|
+
(0, invariant_1.invariant)(fetchPolicy === "standby", 80);
|
|
88
|
+
this.variablesUnknown = true;
|
|
89
|
+
}
|
|
82
90
|
this.lastQuery = transformedQuery;
|
|
83
91
|
this.options = {
|
|
84
92
|
...options,
|
|
@@ -205,7 +213,7 @@ class ObservableQuery {
|
|
|
205
213
|
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
206
214
|
*/
|
|
207
215
|
getCacheDiff({ optimistic = true } = {}) {
|
|
208
|
-
return this.
|
|
216
|
+
return this.cache.diff({
|
|
209
217
|
query: this.query,
|
|
210
218
|
variables: this.variables,
|
|
211
219
|
returnPartialData: true,
|
|
@@ -213,9 +221,11 @@ class ObservableQuery {
|
|
|
213
221
|
});
|
|
214
222
|
}
|
|
215
223
|
getInitialResult(initialFetchPolicy) {
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
224
|
+
let fetchPolicy = initialFetchPolicy || this.options.fetchPolicy;
|
|
225
|
+
if (this.queryManager.prioritizeCacheValues &&
|
|
226
|
+
(fetchPolicy === "network-only" || fetchPolicy === "cache-and-network")) {
|
|
227
|
+
fetchPolicy = "cache-first";
|
|
228
|
+
}
|
|
219
229
|
const cacheResult = () => {
|
|
220
230
|
const diff = this.getCacheDiff();
|
|
221
231
|
// TODO: queryInfo.getDiff should handle this since cache.diff returns a
|
|
@@ -316,7 +326,7 @@ class ObservableQuery {
|
|
|
316
326
|
}
|
|
317
327
|
},
|
|
318
328
|
};
|
|
319
|
-
const cancelWatch = this.
|
|
329
|
+
const cancelWatch = this.cache.watch(watch);
|
|
320
330
|
this.unsubscribeFromCache = Object.assign(() => {
|
|
321
331
|
this.unsubscribeFromCache = undefined;
|
|
322
332
|
cancelWatch();
|
|
@@ -380,7 +390,7 @@ class ObservableQuery {
|
|
|
380
390
|
const queryDef = (0, internal_1.getQueryDefinition)(this.query);
|
|
381
391
|
const vars = queryDef.variableDefinitions;
|
|
382
392
|
if (!vars || !vars.some((v) => v.variable.name.value === "variables")) {
|
|
383
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
393
|
+
__DEV__ && invariant_1.invariant.warn(81, variables, queryDef.name?.value || queryDef);
|
|
384
394
|
}
|
|
385
395
|
}
|
|
386
396
|
if (variables && !(0, equality_1.equal)(this.variables, variables)) {
|
|
@@ -396,7 +406,7 @@ class ObservableQuery {
|
|
|
396
406
|
fetchMore({ query, variables, context, errorPolicy, updateQuery, }) {
|
|
397
407
|
(0, invariant_1.invariant)(
|
|
398
408
|
this.options.fetchPolicy !== "cache-only",
|
|
399
|
-
|
|
409
|
+
82,
|
|
400
410
|
(0, internal_1.getOperationName)(this.query, "(anonymous)")
|
|
401
411
|
);
|
|
402
412
|
const combinedOptions = {
|
|
@@ -430,7 +440,7 @@ class ObservableQuery {
|
|
|
430
440
|
let wasUpdated = false;
|
|
431
441
|
const isCached = this.options.fetchPolicy !== "no-cache";
|
|
432
442
|
if (!isCached) {
|
|
433
|
-
(0, invariant_1.invariant)(updateQuery,
|
|
443
|
+
(0, invariant_1.invariant)(updateQuery, 83);
|
|
434
444
|
}
|
|
435
445
|
const { finalize, pushNotification } = this.pushOperation(networkStatus_js_1.NetworkStatus.fetchMore);
|
|
436
446
|
pushNotification({
|
|
@@ -438,109 +448,149 @@ class ObservableQuery {
|
|
|
438
448
|
kind: "N",
|
|
439
449
|
value: {},
|
|
440
450
|
}, { shouldEmit: 3 /* EmitBehavior.networkStatusChange */ });
|
|
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
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
451
|
+
const { promise, operator } = getTrackingOperatorPromise();
|
|
452
|
+
const { observable } = this.queryManager.fetchObservableWithInfo(combinedOptions, { networkStatus: networkStatus_js_1.NetworkStatus.fetchMore, exposeExtensions: true });
|
|
453
|
+
const subscription = observable
|
|
454
|
+
.pipe(operator, (0, rxjs_1.filter)((notification) => notification.kind === "N" && notification.source === "network"))
|
|
455
|
+
.subscribe({
|
|
456
|
+
next: (notification) => {
|
|
457
|
+
wasUpdated = false;
|
|
458
|
+
const fetchMoreResult = notification.value;
|
|
459
|
+
const extensions = fetchMoreResult[internal_1.extensionsSymbol];
|
|
460
|
+
if ((0, utilities_1.isNetworkRequestSettled)(notification.value.networkStatus)) {
|
|
461
|
+
finalize();
|
|
462
|
+
}
|
|
463
|
+
if (isCached) {
|
|
464
|
+
// Separately getting a diff here before the batch - `onWatchUpdated` might be
|
|
465
|
+
// called with an `undefined` `lastDiff` on the watcher if the cache was just subscribed to.
|
|
466
|
+
const lastDiff = this.getCacheDiff();
|
|
467
|
+
// Performing this cache update inside a cache.batch transaction ensures
|
|
468
|
+
// any affected cache.watch watchers are notified at most once about any
|
|
469
|
+
// updates. Most watchers will be using the QueryInfo class, which
|
|
470
|
+
// responds to notifications by calling reobserveCacheFirst to deliver
|
|
471
|
+
// fetchMore cache results back to this ObservableQuery.
|
|
472
|
+
this.cache.batch({
|
|
473
|
+
update: (cache) => {
|
|
474
|
+
if (updateQuery) {
|
|
475
|
+
cache.updateQuery({
|
|
476
|
+
query: this.query,
|
|
477
|
+
variables: this.variables,
|
|
478
|
+
returnPartialData: true,
|
|
479
|
+
optimistic: false,
|
|
480
|
+
extensions,
|
|
481
|
+
}, (previous) => updateQuery(previous, {
|
|
482
|
+
fetchMoreResult: fetchMoreResult.data,
|
|
483
|
+
variables: combinedOptions.variables,
|
|
484
|
+
}));
|
|
485
|
+
}
|
|
486
|
+
else {
|
|
487
|
+
// If we're using a field policy instead of updateQuery, the only
|
|
488
|
+
// thing we need to do is write the new data to the cache using
|
|
489
|
+
// combinedOptions.variables (instead of this.variables, which is
|
|
490
|
+
// what this.updateQuery uses, because it works by abusing the
|
|
491
|
+
// original field value, keyed by the original variables).
|
|
492
|
+
cache.writeQuery({
|
|
493
|
+
query: combinedOptions.query,
|
|
494
|
+
variables: combinedOptions.variables,
|
|
495
|
+
data: fetchMoreResult.data,
|
|
496
|
+
extensions,
|
|
497
|
+
});
|
|
498
|
+
}
|
|
499
|
+
},
|
|
500
|
+
onWatchUpdated: (watch, diff) => {
|
|
501
|
+
if (watch.watcher === this &&
|
|
502
|
+
!(0, equality_1.equal)(diff.result, lastDiff.result)) {
|
|
503
|
+
wasUpdated = true;
|
|
504
|
+
const lastResult = this.getCurrentResult();
|
|
505
|
+
// Let the cache watch from resubscribeCache handle the final
|
|
506
|
+
// result
|
|
507
|
+
if ((0, utilities_1.isNetworkRequestInFlight)(fetchMoreResult.networkStatus)) {
|
|
508
|
+
pushNotification({
|
|
509
|
+
kind: "N",
|
|
510
|
+
source: "network",
|
|
511
|
+
value: {
|
|
512
|
+
...lastResult,
|
|
513
|
+
networkStatus: (fetchMoreResult.networkStatus ===
|
|
514
|
+
networkStatus_js_1.NetworkStatus.error) ?
|
|
515
|
+
networkStatus_js_1.NetworkStatus.ready
|
|
516
|
+
: fetchMoreResult.networkStatus,
|
|
517
|
+
// will be overwritten anyways, just here for types sake
|
|
518
|
+
loading: false,
|
|
519
|
+
data: diff.result,
|
|
520
|
+
dataState: fetchMoreResult.dataState === "streaming" ?
|
|
521
|
+
"streaming"
|
|
522
|
+
: "complete",
|
|
523
|
+
},
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
},
|
|
528
|
+
});
|
|
529
|
+
}
|
|
530
|
+
else {
|
|
531
|
+
// There is a possibility `lastResult` may not be set when
|
|
532
|
+
// `fetchMore` is called which would cause this to crash. This should
|
|
533
|
+
// only happen if we haven't previously reported a result. We don't
|
|
534
|
+
// quite know what the right behavior should be here since this block
|
|
535
|
+
// of code runs after the fetch result has executed on the network.
|
|
536
|
+
// We plan to let it crash in the meantime.
|
|
537
|
+
//
|
|
538
|
+
// If we get bug reports due to the `data` property access on
|
|
539
|
+
// undefined, this should give us a real-world scenario that we can
|
|
540
|
+
// use to test against and determine the right behavior. If we do end
|
|
541
|
+
// up changing this behavior, this may require, for example, an
|
|
542
|
+
// adjustment to the types on `updateQuery` since that function
|
|
543
|
+
// expects that the first argument always contains previous result
|
|
544
|
+
// data, but not `undefined`.
|
|
545
|
+
const lastResult = this.getCurrentResult();
|
|
546
|
+
const data = updateQuery(lastResult.data, {
|
|
547
|
+
fetchMoreResult: fetchMoreResult.data,
|
|
548
|
+
variables: combinedOptions.variables,
|
|
549
|
+
});
|
|
550
|
+
pushNotification({
|
|
551
|
+
kind: "N",
|
|
552
|
+
value: {
|
|
553
|
+
...lastResult,
|
|
554
|
+
networkStatus: networkStatus_js_1.NetworkStatus.ready,
|
|
555
|
+
// will be overwritten anyways, just here for types sake
|
|
556
|
+
loading: false,
|
|
557
|
+
data: data,
|
|
558
|
+
dataState: lastResult.dataState === "streaming" ?
|
|
559
|
+
"streaming"
|
|
560
|
+
: "complete",
|
|
561
|
+
},
|
|
562
|
+
source: "network",
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
},
|
|
566
|
+
});
|
|
567
|
+
return (0, internal_1.preventUnhandledRejection)(promise
|
|
568
|
+
.then((result) => (0, internal_1.toQueryResult)(this.maskResult(result)))
|
|
528
569
|
.finally(() => {
|
|
529
|
-
|
|
570
|
+
subscription.unsubscribe();
|
|
530
571
|
finalize();
|
|
531
|
-
// In case the cache writes above did not generate a broadcast
|
|
532
|
-
// notification (which would have been intercepted by onWatchUpdated),
|
|
533
|
-
// likely because the written data were the same as what was already in
|
|
534
|
-
// the cache, we still want fetchMore to deliver its final loading:false
|
|
535
|
-
// result with the unchanged data.
|
|
536
572
|
if (isCached && !wasUpdated) {
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
573
|
+
const lastResult = this.getCurrentResult();
|
|
574
|
+
if (lastResult.dataState === "streaming") {
|
|
575
|
+
pushNotification({
|
|
576
|
+
kind: "N",
|
|
577
|
+
source: "network",
|
|
578
|
+
value: {
|
|
579
|
+
...lastResult,
|
|
580
|
+
dataState: "complete",
|
|
581
|
+
networkStatus: networkStatus_js_1.NetworkStatus.ready,
|
|
582
|
+
},
|
|
583
|
+
});
|
|
584
|
+
}
|
|
585
|
+
else {
|
|
586
|
+
pushNotification({
|
|
587
|
+
kind: "N",
|
|
588
|
+
source: "newNetworkStatus",
|
|
589
|
+
value: {},
|
|
590
|
+
}, { shouldEmit: 1 /* EmitBehavior.force */ });
|
|
591
|
+
}
|
|
542
592
|
}
|
|
543
|
-
});
|
|
593
|
+
}));
|
|
544
594
|
}
|
|
545
595
|
// XXX the subscription variables are separate from the query variables.
|
|
546
596
|
// if you want to update subscription variables, right now you have to do that separately,
|
|
@@ -566,7 +616,7 @@ class ObservableQuery {
|
|
|
566
616
|
onError(error);
|
|
567
617
|
}
|
|
568
618
|
else {
|
|
569
|
-
invariant_1.invariant.error(
|
|
619
|
+
invariant_1.invariant.error(84, error);
|
|
570
620
|
}
|
|
571
621
|
return;
|
|
572
622
|
}
|
|
@@ -644,7 +694,7 @@ class ObservableQuery {
|
|
|
644
694
|
previousData: result,
|
|
645
695
|
});
|
|
646
696
|
if (newResult) {
|
|
647
|
-
|
|
697
|
+
this.cache.writeQuery({
|
|
648
698
|
query: this.options.query,
|
|
649
699
|
data: newResult,
|
|
650
700
|
variables: this.variables,
|
|
@@ -810,7 +860,7 @@ class ObservableQuery {
|
|
|
810
860
|
if (!this.didWarnCacheOnlyPolling &&
|
|
811
861
|
pollInterval &&
|
|
812
862
|
fetchPolicy === "cache-only") {
|
|
813
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
863
|
+
__DEV__ && invariant_1.invariant.warn(85, (0, internal_1.getOperationName)(this.query, "(anonymous)"));
|
|
814
864
|
this.didWarnCacheOnlyPolling = true;
|
|
815
865
|
}
|
|
816
866
|
}
|
|
@@ -885,6 +935,10 @@ class ObservableQuery {
|
|
|
885
935
|
const oldVariables = this.variables;
|
|
886
936
|
const oldFetchPolicy = this.options.fetchPolicy;
|
|
887
937
|
const mergedOptions = (0, internal_1.compact)(this.options, newOptions || {});
|
|
938
|
+
// This request will hit the network, so even if there are no variables,
|
|
939
|
+
// we now know that's intentional. (see #12996)
|
|
940
|
+
// Even if that happens only once, we want `variablesUnknown` to stay false permanently.
|
|
941
|
+
this.variablesUnknown &&= mergedOptions.fetchPolicy === "standby";
|
|
888
942
|
const options = useDisposableObservable ?
|
|
889
943
|
// Disposable Observable fetches receive a shallow copy of this.options
|
|
890
944
|
// (merged with newOptions), leaving this.options unmodified.
|
|
@@ -947,15 +1001,7 @@ class ObservableQuery {
|
|
|
947
1001
|
this.cancelPolling();
|
|
948
1002
|
}
|
|
949
1003
|
this.resubscribeCache();
|
|
950
|
-
const { promise, operator: promiseOperator } = getTrackingOperatorPromise(
|
|
951
|
-
switch (value.kind) {
|
|
952
|
-
case "E":
|
|
953
|
-
throw value.error;
|
|
954
|
-
case "N":
|
|
955
|
-
if (value.source !== "newNetworkStatus" && !value.value.loading)
|
|
956
|
-
return value.value;
|
|
957
|
-
}
|
|
958
|
-
},
|
|
1004
|
+
const { promise, operator: promiseOperator } = getTrackingOperatorPromise(
|
|
959
1005
|
// This default value should only be used when using a `fetchPolicy` of
|
|
960
1006
|
// `standby` since that fetch policy completes without emitting a
|
|
961
1007
|
// result. Since we are converting this to a QueryResult type, we
|
|
@@ -1077,8 +1123,8 @@ class ObservableQuery {
|
|
|
1077
1123
|
const { dirty } = this;
|
|
1078
1124
|
this.resetNotifications();
|
|
1079
1125
|
if (dirty &&
|
|
1080
|
-
(this.options.fetchPolicy
|
|
1081
|
-
this.options.fetchPolicy
|
|
1126
|
+
(this.options.fetchPolicy === "cache-only" ||
|
|
1127
|
+
this.options.fetchPolicy === "cache-and-network" ||
|
|
1082
1128
|
!this.activeOperations.size)) {
|
|
1083
1129
|
const diff = this.getCacheDiff();
|
|
1084
1130
|
if (
|
|
@@ -1162,7 +1208,9 @@ class ObservableQuery {
|
|
|
1162
1208
|
// "fetchMore" having priority over "polling" or "loading" network statuses
|
|
1163
1209
|
// as for now we just take the "latest" operation that is still active,
|
|
1164
1210
|
// as that lines up best with previous behavior[]
|
|
1165
|
-
const operation = Array.from(this.activeOperations.values())
|
|
1211
|
+
const operation = Array.from(this.activeOperations.values())
|
|
1212
|
+
.reverse()
|
|
1213
|
+
.find((operation) => isEqualQuery(operation, this) && operation.override !== undefined);
|
|
1166
1214
|
return operation?.override ?? baseNetworkStatus;
|
|
1167
1215
|
}
|
|
1168
1216
|
abortActiveOperations() {
|
|
@@ -1307,13 +1355,13 @@ class ObservableQuery {
|
|
|
1307
1355
|
exports.ObservableQuery = ObservableQuery;
|
|
1308
1356
|
function logMissingFieldErrors(missing) {
|
|
1309
1357
|
if (environment_1.__DEV__ && missing) {
|
|
1310
|
-
__DEV__ && invariant_1.invariant.debug(
|
|
1358
|
+
__DEV__ && invariant_1.invariant.debug(86, missing);
|
|
1311
1359
|
}
|
|
1312
1360
|
}
|
|
1313
1361
|
function isEqualQuery(a, b) {
|
|
1314
1362
|
return !!(a && b && a.query === b.query && (0, equality_1.equal)(a.variables, b.variables));
|
|
1315
1363
|
}
|
|
1316
|
-
function getTrackingOperatorPromise(
|
|
1364
|
+
function getTrackingOperatorPromise(defaultValue) {
|
|
1317
1365
|
let lastValue = defaultValue, resolve, reject;
|
|
1318
1366
|
const promise = new Promise((res, rej) => {
|
|
1319
1367
|
resolve = res;
|
|
@@ -1321,14 +1369,13 @@ function getTrackingOperatorPromise(filterMapCb, defaultValue) {
|
|
|
1321
1369
|
});
|
|
1322
1370
|
const operator = (0, rxjs_1.tap)({
|
|
1323
1371
|
next(value) {
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
if (newValue !== undefined) {
|
|
1327
|
-
lastValue = newValue;
|
|
1328
|
-
}
|
|
1372
|
+
if (value.kind === "E") {
|
|
1373
|
+
return reject(value.error);
|
|
1329
1374
|
}
|
|
1330
|
-
|
|
1331
|
-
|
|
1375
|
+
if (value.kind === "N" &&
|
|
1376
|
+
value.source !== "newNetworkStatus" &&
|
|
1377
|
+
!value.value.loading) {
|
|
1378
|
+
lastValue = value.value;
|
|
1332
1379
|
}
|
|
1333
1380
|
},
|
|
1334
1381
|
finalize: () => {
|