@apollo/client 4.0.12-beta.0 → 4.0.13
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 +10 -194
- package/__cjs/cache/core/cache.cjs +48 -169
- package/__cjs/cache/core/cache.cjs.map +1 -1
- package/__cjs/cache/core/cache.d.cts +25 -94
- package/__cjs/cache/core/types/Cache.d.cts +17 -49
- package/__cjs/cache/index.cjs.map +1 -1
- package/__cjs/cache/index.d.cts +1 -1
- package/__cjs/cache/inmemory/entityStore.cjs +4 -6
- 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 +1 -15
- package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
- package/__cjs/cache/inmemory/inMemoryCache.d.cts +0 -1
- 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 +17 -56
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/policies.d.cts +6 -30
- package/__cjs/cache/inmemory/readFromStore.cjs +3 -3
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/types.d.cts +0 -2
- package/__cjs/cache/inmemory/writeToStore.cjs +10 -24
- package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/writeToStore.d.cts +1 -2
- package/__cjs/core/ApolloClient.cjs +49 -31
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +17 -143
- package/__cjs/core/ObservableQuery.cjs +128 -162
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +0 -1
- package/__cjs/core/QueryInfo.cjs +1 -9
- package/__cjs/core/QueryInfo.cjs.map +1 -1
- package/__cjs/core/QueryInfo.d.cts +1 -2
- package/__cjs/core/QueryManager.cjs +24 -46
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +2 -18
- package/__cjs/incremental/handlers/defer20220824.cjs +19 -44
- package/__cjs/incremental/handlers/defer20220824.cjs.map +1 -1
- package/__cjs/incremental/handlers/defer20220824.d.cts +7 -15
- package/__cjs/incremental/handlers/notImplemented.cjs +1 -1
- package/__cjs/incremental/handlers/notImplemented.cjs.map +1 -1
- package/__cjs/incremental/index.cjs +1 -3
- package/__cjs/incremental/index.cjs.map +1 -1
- package/__cjs/incremental/index.d.cts +0 -1
- package/__cjs/incremental/types.d.cts +0 -9
- package/__cjs/invariantErrorCodes.cjs +62 -78
- package/__cjs/link/client-awareness/ClientAwarenessLink.cjs +1 -13
- 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/http/checkFetcher.cjs +1 -1
- package/__cjs/link/http/parseAndCheckHttpResponse.cjs +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/ws/index.cjs +1 -1
- package/__cjs/local-state/LocalState.cjs +14 -28
- package/__cjs/local-state/LocalState.cjs.map +1 -1
- package/__cjs/local-state/LocalState.d.cts +2 -3
- package/__cjs/masking/types.d.cts +1 -2
- package/__cjs/react/hooks/internal/useDeepMemo.cjs +0 -2
- 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 +3 -1
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useFragment.cjs +87 -38
- package/__cjs/react/hooks/useFragment.cjs.map +1 -1
- package/__cjs/react/hooks/useFragment.d.cts +6 -65
- package/__cjs/react/hooks/useLazyQuery.cjs +0 -2
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.cjs +1 -7
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +1 -13
- package/__cjs/react/hooks/useQuery.cjs +4 -1
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +1 -1
- package/__cjs/react/hooks/useQueryRefHandlers.cjs +3 -1
- package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
- package/__cjs/react/hooks/useReadQuery.cjs +3 -1
- 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 +7 -33
- package/__cjs/react/hooks/useSuspenseQuery.cjs +4 -4
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/internal/cache/FragmentReference.cjs +22 -3
- package/__cjs/react/internal/cache/FragmentReference.cjs.map +1 -1
- package/__cjs/react/internal/cache/FragmentReference.d.cts +4 -2
- package/__cjs/react/internal/cache/QueryReference.cjs +0 -16
- package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
- package/__cjs/react/internal/cache/QueryReference.d.cts +0 -5
- 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 +1 -41
- package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
- package/__cjs/react/ssr/useSSRQuery.cjs +0 -1
- package/__cjs/react/ssr/useSSRQuery.cjs.map +1 -1
- package/__cjs/utilities/DeepPartial.cjs.map +1 -1
- package/__cjs/utilities/DeepPartial.d.cts +1 -1
- package/__cjs/utilities/internal/DeepMerger.cjs +4 -36
- package/__cjs/utilities/internal/DeepMerger.cjs.map +1 -1
- package/__cjs/utilities/internal/DeepMerger.d.cts +4 -20
- 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/compact.cjs +1 -1
- package/__cjs/utilities/internal/compact.cjs.map +1 -1
- package/__cjs/utilities/internal/constants.cjs +1 -17
- package/__cjs/utilities/internal/constants.cjs.map +1 -1
- package/__cjs/utilities/internal/constants.d.cts +0 -16
- package/__cjs/utilities/internal/getStoreKeyName.cjs +0 -1
- package/__cjs/utilities/internal/getStoreKeyName.cjs.map +1 -1
- package/__cjs/utilities/internal/index.cjs +4 -8
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +2 -4
- package/__cjs/utilities/internal/memoize.cjs +2 -2
- package/__cjs/utilities/internal/memoize.cjs.map +1 -1
- package/__cjs/utilities/internal/memoize.d.cts +1 -2
- package/__cjs/version.cjs +1 -1
- package/__cjs/version.cjs.map +1 -1
- package/cache/core/cache.d.ts +25 -94
- package/cache/core/cache.js +51 -172
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +17 -49
- 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 +4 -6
- 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 +0 -1
- package/cache/inmemory/inMemoryCache.js +1 -15
- 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 +6 -30
- package/cache/inmemory/policies.js +7 -45
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.js +3 -3
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +0 -2
- package/cache/inmemory/types.js.map +1 -1
- package/cache/inmemory/writeToStore.d.ts +1 -2
- package/cache/inmemory/writeToStore.js +12 -26
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.d.ts +17 -143
- package/core/ApolloClient.js +50 -32
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +0 -1
- package/core/ObservableQuery.js +131 -165
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +1 -2
- package/core/QueryInfo.js +2 -10
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +2 -18
- package/core/QueryManager.js +25 -47
- package/core/QueryManager.js.map +1 -1
- package/incremental/handlers/defer20220824.d.ts +7 -15
- package/incremental/handlers/defer20220824.js +19 -44
- package/incremental/handlers/defer20220824.js.map +1 -1
- package/incremental/handlers/notImplemented.js +1 -1
- package/incremental/handlers/notImplemented.js.map +1 -1
- package/incremental/index.d.ts +0 -1
- package/incremental/index.js +2 -3
- package/incremental/index.js.map +1 -1
- package/incremental/types.d.ts +0 -9
- package/incremental/types.js.map +1 -1
- package/invariantErrorCodes.js +62 -78
- package/link/client-awareness/ClientAwarenessLink.d.ts +1 -1
- package/link/client-awareness/ClientAwarenessLink.js +1 -13
- package/link/client-awareness/ClientAwarenessLink.js.map +1 -1
- package/link/core/ApolloLink.js +3 -3
- package/link/http/checkFetcher.js +1 -1
- package/link/http/parseAndCheckHttpResponse.js +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/ws/index.js +1 -1
- package/local-state/LocalState.d.ts +2 -3
- package/local-state/LocalState.js +14 -28
- package/local-state/LocalState.js.map +1 -1
- package/masking/types.d.ts +1 -2
- package/masking/types.js.map +1 -1
- package/package.json +1 -15
- package/react/hooks/internal/useDeepMemo.js +0 -2
- 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 +3 -1
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useFragment.d.ts +6 -65
- package/react/hooks/useFragment.js +87 -38
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.js +0 -2
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +1 -13
- package/react/hooks/useMutation.js +1 -7
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.js +4 -1
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useQueryRefHandlers.js +3 -1
- package/react/hooks/useQueryRefHandlers.js.map +1 -1
- package/react/hooks/useReadQuery.js +3 -1
- 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 +7 -33
- package/react/hooks/useSuspenseFragment.js +17 -17
- package/react/hooks/useSuspenseFragment.js.map +1 -1
- package/react/hooks/useSuspenseQuery.js +4 -4
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/internal/useDeepMemo.js +0 -2
- package/react/hooks-compiled/internal/useDeepMemo.js.map +1 -1
- package/react/hooks-compiled/internal/useSuspenseHookCacheKey.js +2 -0
- 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 +3 -1
- package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
- package/react/hooks-compiled/useFragment.d.ts +6 -65
- package/react/hooks-compiled/useFragment.js +88 -110
- package/react/hooks-compiled/useFragment.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.js +0 -2
- package/react/hooks-compiled/useLazyQuery.js.map +1 -1
- package/react/hooks-compiled/useLoadableQuery.js +75 -69
- package/react/hooks-compiled/useMutation.d.ts +1 -13
- package/react/hooks-compiled/useMutation.js +13 -5
- package/react/hooks-compiled/useMutation.js.map +1 -1
- package/react/hooks-compiled/useQuery.js +56 -44
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/hooks-compiled/useQueryRefHandlers.js +5 -1
- package/react/hooks-compiled/useQueryRefHandlers.js.map +1 -1
- package/react/hooks-compiled/useReadQuery.js +14 -77
- package/react/hooks-compiled/useReadQuery.js.map +1 -1
- package/react/hooks-compiled/useSubscription.js +93 -237
- package/react/hooks-compiled/useSubscription.js.map +1 -1
- package/react/hooks-compiled/useSuspenseFragment.d.ts +7 -33
- package/react/hooks-compiled/useSuspenseFragment.js +17 -17
- package/react/hooks-compiled/useSuspenseFragment.js.map +1 -1
- package/react/hooks-compiled/useSuspenseQuery.js +8 -4
- 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 +4 -2
- package/react/internal/cache/FragmentReference.js +22 -3
- package/react/internal/cache/FragmentReference.js.map +1 -1
- package/react/internal/cache/QueryReference.d.ts +0 -5
- package/react/internal/cache/QueryReference.js +0 -16
- 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 +1 -41
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/ssr/useSSRQuery.js +0 -1
- 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 +4 -20
- package/utilities/internal/DeepMerger.js +4 -36
- 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/compact.js +1 -1
- package/utilities/internal/compact.js.map +1 -1
- package/utilities/internal/constants.d.ts +0 -16
- package/utilities/internal/constants.js +0 -16
- package/utilities/internal/constants.js.map +1 -1
- package/utilities/internal/getStoreKeyName.js +0 -1
- package/utilities/internal/getStoreKeyName.js.map +1 -1
- package/utilities/internal/index.d.ts +2 -4
- package/utilities/internal/index.js +2 -3
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/memoize.d.ts +1 -2
- package/utilities/internal/memoize.js +2 -2
- package/utilities/internal/memoize.js.map +1 -1
- package/version.js +1 -1
- package/version.js.map +1 -1
- package/__cjs/incremental/handlers/graphql17Alpha9.cjs +0 -222
- package/__cjs/incremental/handlers/graphql17Alpha9.cjs.map +0 -1
- package/__cjs/incremental/handlers/graphql17Alpha9.d.cts +0 -98
- package/__cjs/utilities/internal/combineLatestBatched.cjs +0 -71
- package/__cjs/utilities/internal/combineLatestBatched.cjs.map +0 -1
- package/__cjs/utilities/internal/combineLatestBatched.d.cts +0 -14
- package/__cjs/utilities/internal/mapObservableFragment.cjs +0 -27
- package/__cjs/utilities/internal/mapObservableFragment.cjs.map +0 -1
- package/__cjs/utilities/internal/mapObservableFragment.d.cts +0 -3
- package/__cjs/utilities/internal/ponyfills/FinalizationRegistry.cjs +0 -61
- package/__cjs/utilities/internal/ponyfills/FinalizationRegistry.cjs.map +0 -1
- package/__cjs/utilities/internal/ponyfills/FinalizationRegistry.d.cts +0 -11
- package/__cjs/utilities/internal/ponyfills/index.cjs +0 -6
- package/__cjs/utilities/internal/ponyfills/index.cjs.map +0 -1
- package/__cjs/utilities/internal/ponyfills/index.d.cts +0 -3
- package/__cjs/utilities/internal/ponyfills/index.react-native.cjs +0 -6
- package/__cjs/utilities/internal/ponyfills/index.react-native.cjs.map +0 -1
- package/__cjs/utilities/internal/ponyfills/index.react-native.d.cts +0 -2
- package/__cjs/utilities/internal/types/ExtensionsWithStreamDetails.cjs +0 -3
- package/__cjs/utilities/internal/types/ExtensionsWithStreamDetails.cjs.map +0 -1
- package/__cjs/utilities/internal/types/ExtensionsWithStreamDetails.d.cts +0 -24
- package/incremental/handlers/graphql17Alpha9.d.ts +0 -98
- package/incremental/handlers/graphql17Alpha9.js +0 -218
- package/incremental/handlers/graphql17Alpha9.js.map +0 -1
- package/legacyEntryPoints/utilities/internal/ponyfills/index.d.ts +0 -1
- package/legacyEntryPoints/utilities/internal/ponyfills/index.js +0 -1
- package/legacyEntryPoints/utilities/internal/ponyfills/ponyfills.cjs +0 -1
- package/legacyEntryPoints/utilities/internal/ponyfills/ponyfills.d.cts +0 -1
- package/utilities/internal/combineLatestBatched.d.ts +0 -14
- package/utilities/internal/combineLatestBatched.js +0 -68
- package/utilities/internal/combineLatestBatched.js.map +0 -1
- package/utilities/internal/mapObservableFragment.d.ts +0 -3
- package/utilities/internal/mapObservableFragment.js +0 -24
- package/utilities/internal/mapObservableFragment.js.map +0 -1
- package/utilities/internal/ponyfills/FinalizationRegistry.d.ts +0 -11
- package/utilities/internal/ponyfills/FinalizationRegistry.js +0 -57
- package/utilities/internal/ponyfills/FinalizationRegistry.js.map +0 -1
- package/utilities/internal/ponyfills/index.d.ts +0 -3
- package/utilities/internal/ponyfills/index.js +0 -3
- package/utilities/internal/ponyfills/index.js.map +0 -1
- package/utilities/internal/ponyfills/index.react-native.d.ts +0 -2
- package/utilities/internal/ponyfills/index.react-native.js +0 -2
- package/utilities/internal/ponyfills/index.react-native.js.map +0 -1
- package/utilities/internal/types/ExtensionsWithStreamDetails.d.ts +0 -24
- package/utilities/internal/types/ExtensionsWithStreamDetails.js +0 -2
- package/utilities/internal/types/ExtensionsWithStreamDetails.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { DocumentNode } from "graphql";
|
|
2
2
|
import type { Observable } from "rxjs";
|
|
3
|
-
import type { ApolloCache,
|
|
3
|
+
import type { ApolloCache, IgnoreModifier, Reference } from "@apollo/client/cache";
|
|
4
4
|
import type { Incremental } from "@apollo/client/incremental";
|
|
5
5
|
import type { ApolloLink } from "@apollo/client/link";
|
|
6
6
|
import type { ClientAwarenessLink } from "@apollo/client/link/client-awareness";
|
|
@@ -87,14 +87,6 @@ export declare namespace ApolloClient {
|
|
|
87
87
|
* queries.
|
|
88
88
|
*/
|
|
89
89
|
incrementalHandler?: Incremental.Handler<any>;
|
|
90
|
-
/**
|
|
91
|
-
* @experimental
|
|
92
|
-
* Allows passing in "experiments", experimental features that might one day
|
|
93
|
-
* become part of Apollo Client's core functionality.
|
|
94
|
-
* Keep in mind that these features might change the core of Apollo Client.
|
|
95
|
-
* Do not pass in experiments that are not provided by Apollo.
|
|
96
|
-
*/
|
|
97
|
-
experiments?: ApolloClient.Experiment[];
|
|
98
90
|
}
|
|
99
91
|
interface DevtoolsOptions {
|
|
100
92
|
/**
|
|
@@ -384,13 +376,7 @@ export declare namespace ApolloClient {
|
|
|
384
376
|
extensions?: Record<string, unknown>;
|
|
385
377
|
}
|
|
386
378
|
type WatchFragmentOptions<TData = unknown, TVariables extends OperationVariables = OperationVariables> = ApolloCache.WatchFragmentOptions<TData, TVariables>;
|
|
387
|
-
type WatchFragmentResult<TData = unknown> = ApolloCache.WatchFragmentResult<
|
|
388
|
-
interface ObservableFragment<TData = unknown> extends Observable<ApolloClient.WatchFragmentResult<TData>> {
|
|
389
|
-
/**
|
|
390
|
-
* Return the current result for the fragment.
|
|
391
|
-
*/
|
|
392
|
-
getCurrentResult: () => ApolloClient.WatchFragmentResult<TData>;
|
|
393
|
-
}
|
|
379
|
+
type WatchFragmentResult<TData = unknown> = ApolloCache.WatchFragmentResult<TData>;
|
|
394
380
|
/**
|
|
395
381
|
* Watched query options.
|
|
396
382
|
*/
|
|
@@ -537,6 +523,12 @@ export declare namespace ApolloClient {
|
|
|
537
523
|
}
|
|
538
524
|
namespace Base {
|
|
539
525
|
interface ReadFragmentOptions<TData, TVariables extends OperationVariables> {
|
|
526
|
+
/**
|
|
527
|
+
* The root id to be used. This id should take the same form as the
|
|
528
|
+
* value returned by the `cache.identify` function. If a value with your
|
|
529
|
+
* id does not exist in the store, `null` will be returned.
|
|
530
|
+
*/
|
|
531
|
+
id?: string;
|
|
540
532
|
/**
|
|
541
533
|
* A GraphQL document created using the `gql` template string tag
|
|
542
534
|
* with one or more fragments which will be used to determine
|
|
@@ -565,27 +557,7 @@ export declare namespace ApolloClient {
|
|
|
565
557
|
optimistic?: boolean;
|
|
566
558
|
}
|
|
567
559
|
}
|
|
568
|
-
|
|
569
|
-
interface ReadFragmentOptions<TData, TVariables extends OperationVariables> extends Base.ReadFragmentOptions<TData, TVariables> {
|
|
570
|
-
/**
|
|
571
|
-
* The root id to be used. This id should take the same form as the
|
|
572
|
-
* value returned by the `cache.identify` function. If a value with your
|
|
573
|
-
* id does not exist in the store, `null` will be returned.
|
|
574
|
-
*/
|
|
575
|
-
id?: string;
|
|
576
|
-
/**
|
|
577
|
-
* An object containing a `__typename` and primary key fields
|
|
578
|
-
* (such as `id`) identifying the entity object from which the fragment will
|
|
579
|
-
* be retrieved, or a `{ __ref: "..." }` reference, or a `string` ID
|
|
580
|
-
* (uncommon).
|
|
581
|
-
*
|
|
582
|
-
* @remarks
|
|
583
|
-
* `from` is given precedence over `id` when both are provided.
|
|
584
|
-
*/
|
|
585
|
-
from?: ApolloCache.FromOptionValue<TData>;
|
|
586
|
-
}
|
|
587
|
-
}
|
|
588
|
-
type ReadFragmentOptions<TData, TVariables extends OperationVariables> = Base.ReadFragmentOptions<TData, TVariables> & VariablesOption<TVariables> & Cache.CacheIdentifierOption<TData>;
|
|
560
|
+
type ReadFragmentOptions<TData, TVariables extends OperationVariables> = Base.ReadFragmentOptions<TData, TVariables> & VariablesOption<TVariables>;
|
|
589
561
|
namespace DocumentationTypes {
|
|
590
562
|
interface WriteQueryOptions<TData, TVariables extends OperationVariables> extends Base.WriteQueryOptions<TData, TVariables> {
|
|
591
563
|
/**
|
|
@@ -623,11 +595,6 @@ export declare namespace ApolloClient {
|
|
|
623
595
|
* @defaultValue false
|
|
624
596
|
*/
|
|
625
597
|
overwrite?: boolean;
|
|
626
|
-
/**
|
|
627
|
-
* GraphQL extensions for the write operation. Any provided `extensions`
|
|
628
|
-
* are available in `merge` functions.
|
|
629
|
-
*/
|
|
630
|
-
extensions?: Record<string, unknown>;
|
|
631
598
|
}
|
|
632
599
|
}
|
|
633
600
|
type WriteQueryOptions<TData, TVariables extends OperationVariables> = Base.WriteQueryOptions<TData, TVariables> & VariablesOption<TVariables>;
|
|
@@ -641,6 +608,12 @@ export declare namespace ApolloClient {
|
|
|
641
608
|
}
|
|
642
609
|
namespace Base {
|
|
643
610
|
interface WriteFragmentOptions<TData, TVariables extends OperationVariables> {
|
|
611
|
+
/**
|
|
612
|
+
* The root id to be used. This id should take the same form as the
|
|
613
|
+
* value returned by the `cache.identify` function. If a value with your
|
|
614
|
+
* id does not exist in the store, `null` will be returned.
|
|
615
|
+
*/
|
|
616
|
+
id?: string;
|
|
644
617
|
/**
|
|
645
618
|
* A GraphQL document created using the `gql` template string tag from
|
|
646
619
|
* `graphql-tag` with one or more fragments which will be used to determine
|
|
@@ -672,35 +645,15 @@ export declare namespace ApolloClient {
|
|
|
672
645
|
overwrite?: boolean;
|
|
673
646
|
}
|
|
674
647
|
}
|
|
675
|
-
type WriteFragmentOptions<TData, TVariables extends OperationVariables> = Base.WriteFragmentOptions<TData, TVariables> & VariablesOption<TVariables
|
|
648
|
+
type WriteFragmentOptions<TData, TVariables extends OperationVariables> = Base.WriteFragmentOptions<TData, TVariables> & VariablesOption<TVariables>;
|
|
676
649
|
namespace DocumentationTypes {
|
|
677
650
|
interface WriteFragmentOptions<TData, TVariables extends OperationVariables> extends Base.WriteFragmentOptions<TData, TVariables> {
|
|
678
|
-
/**
|
|
679
|
-
* The root id to be used. This id should take the same form as the
|
|
680
|
-
* value returned by the `cache.identify` function. If a value with your
|
|
681
|
-
* id does not exist in the store, `null` will be returned.
|
|
682
|
-
*/
|
|
683
|
-
id?: string;
|
|
684
|
-
/**
|
|
685
|
-
* An object containing a `__typename` and primary key fields
|
|
686
|
-
* (such as `id`) identifying the entity object from which the fragment will
|
|
687
|
-
* be retrieved, or a `{ __ref: "..." }` reference, or a `string` ID
|
|
688
|
-
* (uncommon).
|
|
689
|
-
*
|
|
690
|
-
* @remarks
|
|
691
|
-
* `from` is given precedence over `id` when both are provided.
|
|
692
|
-
*/
|
|
693
|
-
from?: ApolloCache.FromOptionValue<TData>;
|
|
694
651
|
/**
|
|
695
652
|
* Any variables that your GraphQL fragments depend on.
|
|
696
653
|
*/
|
|
697
654
|
variables?: TVariables;
|
|
698
655
|
}
|
|
699
656
|
}
|
|
700
|
-
interface Experiment {
|
|
701
|
-
(this: ApolloClient, options: ApolloClient.Options): void;
|
|
702
|
-
v: 1;
|
|
703
|
-
}
|
|
704
657
|
}
|
|
705
658
|
/**
|
|
706
659
|
* This is the primary Apollo Client class. It is used to send GraphQL documents (i.e. queries
|
|
@@ -873,86 +826,7 @@ export declare class ApolloClient {
|
|
|
873
826
|
* the cache to identify the fragment and optionally specify whether to react
|
|
874
827
|
* to optimistic updates.
|
|
875
828
|
*/
|
|
876
|
-
watchFragment<TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: ApolloClient.WatchFragmentOptions<TData, TVariables>
|
|
877
|
-
from: Array<ApolloCache.FromOptionValue<TData>>;
|
|
878
|
-
}): ApolloClient.ObservableFragment<Array<TData>>;
|
|
879
|
-
/**
|
|
880
|
-
* Watches the cache store of the fragment according to the options specified
|
|
881
|
-
* and returns an `Observable`. We can subscribe to this
|
|
882
|
-
* `Observable` and receive updated results through an
|
|
883
|
-
* observer when the cache store changes.
|
|
884
|
-
*
|
|
885
|
-
* You must pass in a GraphQL document with a single fragment or a document
|
|
886
|
-
* with multiple fragments that represent what you are reading. If you pass
|
|
887
|
-
* in a document with multiple fragments then you must also specify a
|
|
888
|
-
* `fragmentName`.
|
|
889
|
-
*
|
|
890
|
-
* @since 3.10.0
|
|
891
|
-
* @param options - An object of type `WatchFragmentOptions` that allows
|
|
892
|
-
* the cache to identify the fragment and optionally specify whether to react
|
|
893
|
-
* to optimistic updates.
|
|
894
|
-
*/
|
|
895
|
-
watchFragment<TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: ApolloClient.WatchFragmentOptions<TData, TVariables> & {
|
|
896
|
-
from: Array<null>;
|
|
897
|
-
}): ApolloClient.ObservableFragment<Array<null>>;
|
|
898
|
-
watchFragment<TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: ApolloClient.WatchFragmentOptions<TData, TVariables> & {
|
|
899
|
-
from: Array<ApolloCache.FromOptionValue<TData> | null>;
|
|
900
|
-
}): ApolloClient.ObservableFragment<Array<TData | null>>;
|
|
901
|
-
/**
|
|
902
|
-
* Watches the cache store of the fragment according to the options specified
|
|
903
|
-
* and returns an `Observable`. We can subscribe to this
|
|
904
|
-
* `Observable` and receive updated results through an
|
|
905
|
-
* observer when the cache store changes.
|
|
906
|
-
*
|
|
907
|
-
* You must pass in a GraphQL document with a single fragment or a document
|
|
908
|
-
* with multiple fragments that represent what you are reading. If you pass
|
|
909
|
-
* in a document with multiple fragments then you must also specify a
|
|
910
|
-
* `fragmentName`.
|
|
911
|
-
*
|
|
912
|
-
* @since 3.10.0
|
|
913
|
-
* @param options - An object of type `WatchFragmentOptions` that allows
|
|
914
|
-
* the cache to identify the fragment and optionally specify whether to react
|
|
915
|
-
* to optimistic updates.
|
|
916
|
-
*/
|
|
917
|
-
watchFragment<TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: ApolloClient.WatchFragmentOptions<TData, TVariables> & {
|
|
918
|
-
from: null;
|
|
919
|
-
}): ApolloClient.ObservableFragment<null>;
|
|
920
|
-
/**
|
|
921
|
-
* Watches the cache store of the fragment according to the options specified
|
|
922
|
-
* and returns an `Observable`. We can subscribe to this
|
|
923
|
-
* `Observable` and receive updated results through an
|
|
924
|
-
* observer when the cache store changes.
|
|
925
|
-
*
|
|
926
|
-
* You must pass in a GraphQL document with a single fragment or a document
|
|
927
|
-
* with multiple fragments that represent what you are reading. If you pass
|
|
928
|
-
* in a document with multiple fragments then you must also specify a
|
|
929
|
-
* `fragmentName`.
|
|
930
|
-
*
|
|
931
|
-
* @since 3.10.0
|
|
932
|
-
* @param options - An object of type `WatchFragmentOptions` that allows
|
|
933
|
-
* the cache to identify the fragment and optionally specify whether to react
|
|
934
|
-
* to optimistic updates.
|
|
935
|
-
*/
|
|
936
|
-
watchFragment<TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: ApolloClient.WatchFragmentOptions<TData, TVariables> & {
|
|
937
|
-
from: ApolloCache.FromOptionValue<TData>;
|
|
938
|
-
}): ApolloClient.ObservableFragment<TData>;
|
|
939
|
-
/**
|
|
940
|
-
* Watches the cache store of the fragment according to the options specified
|
|
941
|
-
* and returns an `Observable`. We can subscribe to this
|
|
942
|
-
* `Observable` and receive updated results through an
|
|
943
|
-
* observer when the cache store changes.
|
|
944
|
-
*
|
|
945
|
-
* You must pass in a GraphQL document with a single fragment or a document
|
|
946
|
-
* with multiple fragments that represent what you are reading. If you pass
|
|
947
|
-
* in a document with multiple fragments then you must also specify a
|
|
948
|
-
* `fragmentName`.
|
|
949
|
-
*
|
|
950
|
-
* @since 3.10.0
|
|
951
|
-
* @param options - An object of type `WatchFragmentOptions` that allows
|
|
952
|
-
* the cache to identify the fragment and optionally specify whether to react
|
|
953
|
-
* to optimistic updates.
|
|
954
|
-
*/
|
|
955
|
-
watchFragment<TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: ApolloClient.WatchFragmentOptions<TData, TVariables>): ApolloClient.ObservableFragment<TData | null>;
|
|
829
|
+
watchFragment<TData = unknown, TVariables extends OperationVariables = OperationVariables>(options: ApolloClient.WatchFragmentOptions<TData, TVariables>): Observable<ApolloClient.WatchFragmentResult<MaybeMasked<TData>>>;
|
|
956
830
|
/**
|
|
957
831
|
* Tries to read some data from the store in the shape of the provided
|
|
958
832
|
* GraphQL fragment without making a network request. This method will read a
|
|
@@ -69,9 +69,6 @@ class ObservableQuery {
|
|
|
69
69
|
get networkStatus() {
|
|
70
70
|
return this.subject.getValue().result.networkStatus;
|
|
71
71
|
}
|
|
72
|
-
get cache() {
|
|
73
|
-
return this.queryManager.cache;
|
|
74
|
-
}
|
|
75
72
|
constructor({ queryManager, options, transformedQuery = queryManager.transform(options.query), }) {
|
|
76
73
|
this.queryManager = queryManager;
|
|
77
74
|
// active state
|
|
@@ -84,7 +81,7 @@ class ObservableQuery {
|
|
|
84
81
|
// Make sure we don't store "standby" as the initialFetchPolicy.
|
|
85
82
|
initialFetchPolicy = fetchPolicy === "standby" ? defaultFetchPolicy : (fetchPolicy), } = options;
|
|
86
83
|
if (options[internal_1.variablesUnknownSymbol]) {
|
|
87
|
-
(0, invariant_1.invariant)(fetchPolicy === "standby",
|
|
84
|
+
(0, invariant_1.invariant)(fetchPolicy === "standby", 77);
|
|
88
85
|
this.variablesUnknown = true;
|
|
89
86
|
}
|
|
90
87
|
this.lastQuery = transformedQuery;
|
|
@@ -213,7 +210,7 @@ class ObservableQuery {
|
|
|
213
210
|
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
214
211
|
*/
|
|
215
212
|
getCacheDiff({ optimistic = true } = {}) {
|
|
216
|
-
return this.cache.diff({
|
|
213
|
+
return this.queryManager.cache.diff({
|
|
217
214
|
query: this.query,
|
|
218
215
|
variables: this.variables,
|
|
219
216
|
returnPartialData: true,
|
|
@@ -324,7 +321,7 @@ class ObservableQuery {
|
|
|
324
321
|
}
|
|
325
322
|
},
|
|
326
323
|
};
|
|
327
|
-
const cancelWatch = this.cache.watch(watch);
|
|
324
|
+
const cancelWatch = this.queryManager.cache.watch(watch);
|
|
328
325
|
this.unsubscribeFromCache = Object.assign(() => {
|
|
329
326
|
this.unsubscribeFromCache = undefined;
|
|
330
327
|
cancelWatch();
|
|
@@ -388,7 +385,7 @@ class ObservableQuery {
|
|
|
388
385
|
const queryDef = (0, internal_1.getQueryDefinition)(this.query);
|
|
389
386
|
const vars = queryDef.variableDefinitions;
|
|
390
387
|
if (!vars || !vars.some((v) => v.variable.name.value === "variables")) {
|
|
391
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
388
|
+
__DEV__ && invariant_1.invariant.warn(78, variables, queryDef.name?.value || queryDef);
|
|
392
389
|
}
|
|
393
390
|
}
|
|
394
391
|
if (variables && !(0, equality_1.equal)(this.variables, variables)) {
|
|
@@ -404,7 +401,7 @@ class ObservableQuery {
|
|
|
404
401
|
fetchMore({ query, variables, context, errorPolicy, updateQuery, }) {
|
|
405
402
|
(0, invariant_1.invariant)(
|
|
406
403
|
this.options.fetchPolicy !== "cache-only",
|
|
407
|
-
|
|
404
|
+
79,
|
|
408
405
|
(0, internal_1.getOperationName)(this.query, "(anonymous)")
|
|
409
406
|
);
|
|
410
407
|
const combinedOptions = {
|
|
@@ -438,7 +435,7 @@ class ObservableQuery {
|
|
|
438
435
|
let wasUpdated = false;
|
|
439
436
|
const isCached = this.options.fetchPolicy !== "no-cache";
|
|
440
437
|
if (!isCached) {
|
|
441
|
-
(0, invariant_1.invariant)(updateQuery,
|
|
438
|
+
(0, invariant_1.invariant)(updateQuery, 80);
|
|
442
439
|
}
|
|
443
440
|
const { finalize, pushNotification } = this.pushOperation(networkStatus_js_1.NetworkStatus.fetchMore);
|
|
444
441
|
pushNotification({
|
|
@@ -446,149 +443,109 @@ class ObservableQuery {
|
|
|
446
443
|
kind: "N",
|
|
447
444
|
value: {},
|
|
448
445
|
}, { shouldEmit: 3 /* EmitBehavior.networkStatusChange */ });
|
|
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
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
// If we get bug reports due to the `data` property access on
|
|
537
|
-
// undefined, this should give us a real-world scenario that we can
|
|
538
|
-
// use to test against and determine the right behavior. If we do end
|
|
539
|
-
// up changing this behavior, this may require, for example, an
|
|
540
|
-
// adjustment to the types on `updateQuery` since that function
|
|
541
|
-
// expects that the first argument always contains previous result
|
|
542
|
-
// data, but not `undefined`.
|
|
543
|
-
const lastResult = this.getCurrentResult();
|
|
544
|
-
const data = updateQuery(lastResult.data, {
|
|
545
|
-
fetchMoreResult: fetchMoreResult.data,
|
|
546
|
-
variables: combinedOptions.variables,
|
|
547
|
-
});
|
|
548
|
-
pushNotification({
|
|
549
|
-
kind: "N",
|
|
550
|
-
value: {
|
|
551
|
-
...lastResult,
|
|
552
|
-
networkStatus: networkStatus_js_1.NetworkStatus.ready,
|
|
553
|
-
// will be overwritten anyways, just here for types sake
|
|
554
|
-
loading: false,
|
|
555
|
-
data: data,
|
|
556
|
-
dataState: lastResult.dataState === "streaming" ?
|
|
557
|
-
"streaming"
|
|
558
|
-
: "complete",
|
|
559
|
-
},
|
|
560
|
-
source: "network",
|
|
561
|
-
});
|
|
562
|
-
}
|
|
563
|
-
},
|
|
564
|
-
});
|
|
565
|
-
return (0, internal_1.preventUnhandledRejection)(promise
|
|
566
|
-
.then((result) => (0, internal_1.toQueryResult)(this.maskResult(result)))
|
|
446
|
+
return this.queryManager
|
|
447
|
+
.fetchQuery(combinedOptions, networkStatus_js_1.NetworkStatus.fetchMore)
|
|
448
|
+
.then((fetchMoreResult) => {
|
|
449
|
+
// disable the `fetchMore` override that is currently active
|
|
450
|
+
// the next updates caused by this should not be `fetchMore` anymore,
|
|
451
|
+
// but `ready` or whatever other calculated loading state is currently
|
|
452
|
+
// appropriate
|
|
453
|
+
finalize();
|
|
454
|
+
if (isCached) {
|
|
455
|
+
// Separately getting a diff here before the batch - `onWatchUpdated` might be
|
|
456
|
+
// called with an `undefined` `lastDiff` on the watcher if the cache was just subscribed to.
|
|
457
|
+
const lastDiff = this.getCacheDiff();
|
|
458
|
+
// Performing this cache update inside a cache.batch transaction ensures
|
|
459
|
+
// any affected cache.watch watchers are notified at most once about any
|
|
460
|
+
// updates. Most watchers will be using the QueryInfo class, which
|
|
461
|
+
// responds to notifications by calling reobserveCacheFirst to deliver
|
|
462
|
+
// fetchMore cache results back to this ObservableQuery.
|
|
463
|
+
this.queryManager.cache.batch({
|
|
464
|
+
update: (cache) => {
|
|
465
|
+
if (updateQuery) {
|
|
466
|
+
cache.updateQuery({
|
|
467
|
+
query: this.query,
|
|
468
|
+
variables: this.variables,
|
|
469
|
+
returnPartialData: true,
|
|
470
|
+
optimistic: false,
|
|
471
|
+
}, (previous) => updateQuery(previous, {
|
|
472
|
+
fetchMoreResult: fetchMoreResult.data,
|
|
473
|
+
variables: combinedOptions.variables,
|
|
474
|
+
}));
|
|
475
|
+
}
|
|
476
|
+
else {
|
|
477
|
+
// If we're using a field policy instead of updateQuery, the only
|
|
478
|
+
// thing we need to do is write the new data to the cache using
|
|
479
|
+
// combinedOptions.variables (instead of this.variables, which is
|
|
480
|
+
// what this.updateQuery uses, because it works by abusing the
|
|
481
|
+
// original field value, keyed by the original variables).
|
|
482
|
+
cache.writeQuery({
|
|
483
|
+
query: combinedOptions.query,
|
|
484
|
+
variables: combinedOptions.variables,
|
|
485
|
+
data: fetchMoreResult.data,
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
},
|
|
489
|
+
onWatchUpdated: (watch, diff) => {
|
|
490
|
+
if (watch.watcher === this &&
|
|
491
|
+
!(0, equality_1.equal)(diff.result, lastDiff.result)) {
|
|
492
|
+
wasUpdated = true;
|
|
493
|
+
}
|
|
494
|
+
},
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
else {
|
|
498
|
+
// There is a possibility `lastResult` may not be set when
|
|
499
|
+
// `fetchMore` is called which would cause this to crash. This should
|
|
500
|
+
// only happen if we haven't previously reported a result. We don't
|
|
501
|
+
// quite know what the right behavior should be here since this block
|
|
502
|
+
// of code runs after the fetch result has executed on the network.
|
|
503
|
+
// We plan to let it crash in the meantime.
|
|
504
|
+
//
|
|
505
|
+
// If we get bug reports due to the `data` property access on
|
|
506
|
+
// undefined, this should give us a real-world scenario that we can
|
|
507
|
+
// use to test against and determine the right behavior. If we do end
|
|
508
|
+
// up changing this behavior, this may require, for example, an
|
|
509
|
+
// adjustment to the types on `updateQuery` since that function
|
|
510
|
+
// expects that the first argument always contains previous result
|
|
511
|
+
// data, but not `undefined`.
|
|
512
|
+
const lastResult = this.getCurrentResult();
|
|
513
|
+
const data = updateQuery(lastResult.data, {
|
|
514
|
+
fetchMoreResult: fetchMoreResult.data,
|
|
515
|
+
variables: combinedOptions.variables,
|
|
516
|
+
});
|
|
517
|
+
// was reportResult
|
|
518
|
+
pushNotification({
|
|
519
|
+
kind: "N",
|
|
520
|
+
value: {
|
|
521
|
+
...lastResult,
|
|
522
|
+
networkStatus: networkStatus_js_1.NetworkStatus.ready,
|
|
523
|
+
// will be overwritten anyways, just here for types sake
|
|
524
|
+
loading: false,
|
|
525
|
+
data: data,
|
|
526
|
+
dataState: lastResult.dataState === "streaming" ? "streaming" : "complete",
|
|
527
|
+
},
|
|
528
|
+
source: "network",
|
|
529
|
+
});
|
|
530
|
+
}
|
|
531
|
+
return this.maskResult(fetchMoreResult);
|
|
532
|
+
})
|
|
567
533
|
.finally(() => {
|
|
568
|
-
|
|
534
|
+
// call `finalize` a second time in case the `.then` case above was not reached
|
|
569
535
|
finalize();
|
|
536
|
+
// In case the cache writes above did not generate a broadcast
|
|
537
|
+
// notification (which would have been intercepted by onWatchUpdated),
|
|
538
|
+
// likely because the written data were the same as what was already in
|
|
539
|
+
// the cache, we still want fetchMore to deliver its final loading:false
|
|
540
|
+
// result with the unchanged data.
|
|
570
541
|
if (isCached && !wasUpdated) {
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
value: {
|
|
577
|
-
...lastResult,
|
|
578
|
-
dataState: "complete",
|
|
579
|
-
networkStatus: networkStatus_js_1.NetworkStatus.ready,
|
|
580
|
-
},
|
|
581
|
-
});
|
|
582
|
-
}
|
|
583
|
-
else {
|
|
584
|
-
pushNotification({
|
|
585
|
-
kind: "N",
|
|
586
|
-
source: "newNetworkStatus",
|
|
587
|
-
value: {},
|
|
588
|
-
}, { shouldEmit: 1 /* EmitBehavior.force */ });
|
|
589
|
-
}
|
|
542
|
+
pushNotification({
|
|
543
|
+
kind: "N",
|
|
544
|
+
source: "newNetworkStatus",
|
|
545
|
+
value: {},
|
|
546
|
+
}, { shouldEmit: 1 /* EmitBehavior.force */ });
|
|
590
547
|
}
|
|
591
|
-
})
|
|
548
|
+
});
|
|
592
549
|
}
|
|
593
550
|
// XXX the subscription variables are separate from the query variables.
|
|
594
551
|
// if you want to update subscription variables, right now you have to do that separately,
|
|
@@ -614,7 +571,7 @@ class ObservableQuery {
|
|
|
614
571
|
onError(error);
|
|
615
572
|
}
|
|
616
573
|
else {
|
|
617
|
-
invariant_1.invariant.error(
|
|
574
|
+
invariant_1.invariant.error(81, error);
|
|
618
575
|
}
|
|
619
576
|
return;
|
|
620
577
|
}
|
|
@@ -692,7 +649,7 @@ class ObservableQuery {
|
|
|
692
649
|
previousData: result,
|
|
693
650
|
});
|
|
694
651
|
if (newResult) {
|
|
695
|
-
|
|
652
|
+
queryManager.cache.writeQuery({
|
|
696
653
|
query: this.options.query,
|
|
697
654
|
data: newResult,
|
|
698
655
|
variables: this.variables,
|
|
@@ -858,7 +815,7 @@ class ObservableQuery {
|
|
|
858
815
|
if (!this.didWarnCacheOnlyPolling &&
|
|
859
816
|
pollInterval &&
|
|
860
817
|
fetchPolicy === "cache-only") {
|
|
861
|
-
__DEV__ && invariant_1.invariant.warn(
|
|
818
|
+
__DEV__ && invariant_1.invariant.warn(82, (0, internal_1.getOperationName)(this.query, "(anonymous)"));
|
|
862
819
|
this.didWarnCacheOnlyPolling = true;
|
|
863
820
|
}
|
|
864
821
|
}
|
|
@@ -999,7 +956,15 @@ class ObservableQuery {
|
|
|
999
956
|
this.cancelPolling();
|
|
1000
957
|
}
|
|
1001
958
|
this.resubscribeCache();
|
|
1002
|
-
const { promise, operator: promiseOperator } = getTrackingOperatorPromise(
|
|
959
|
+
const { promise, operator: promiseOperator } = getTrackingOperatorPromise((value) => {
|
|
960
|
+
switch (value.kind) {
|
|
961
|
+
case "E":
|
|
962
|
+
throw value.error;
|
|
963
|
+
case "N":
|
|
964
|
+
if (value.source !== "newNetworkStatus" && !value.value.loading)
|
|
965
|
+
return value.value;
|
|
966
|
+
}
|
|
967
|
+
},
|
|
1003
968
|
// This default value should only be used when using a `fetchPolicy` of
|
|
1004
969
|
// `standby` since that fetch policy completes without emitting a
|
|
1005
970
|
// result. Since we are converting this to a QueryResult type, we
|
|
@@ -1121,8 +1086,8 @@ class ObservableQuery {
|
|
|
1121
1086
|
const { dirty } = this;
|
|
1122
1087
|
this.resetNotifications();
|
|
1123
1088
|
if (dirty &&
|
|
1124
|
-
(this.options.fetchPolicy
|
|
1125
|
-
this.options.fetchPolicy
|
|
1089
|
+
(this.options.fetchPolicy == "cache-only" ||
|
|
1090
|
+
this.options.fetchPolicy == "cache-and-network" ||
|
|
1126
1091
|
!this.activeOperations.size)) {
|
|
1127
1092
|
const diff = this.getCacheDiff();
|
|
1128
1093
|
if (
|
|
@@ -1353,13 +1318,13 @@ class ObservableQuery {
|
|
|
1353
1318
|
exports.ObservableQuery = ObservableQuery;
|
|
1354
1319
|
function logMissingFieldErrors(missing) {
|
|
1355
1320
|
if (environment_1.__DEV__ && missing) {
|
|
1356
|
-
__DEV__ && invariant_1.invariant.debug(
|
|
1321
|
+
__DEV__ && invariant_1.invariant.debug(83, missing);
|
|
1357
1322
|
}
|
|
1358
1323
|
}
|
|
1359
1324
|
function isEqualQuery(a, b) {
|
|
1360
1325
|
return !!(a && b && a.query === b.query && (0, equality_1.equal)(a.variables, b.variables));
|
|
1361
1326
|
}
|
|
1362
|
-
function getTrackingOperatorPromise(defaultValue) {
|
|
1327
|
+
function getTrackingOperatorPromise(filterMapCb, defaultValue) {
|
|
1363
1328
|
let lastValue = defaultValue, resolve, reject;
|
|
1364
1329
|
const promise = new Promise((res, rej) => {
|
|
1365
1330
|
resolve = res;
|
|
@@ -1367,13 +1332,14 @@ function getTrackingOperatorPromise(defaultValue) {
|
|
|
1367
1332
|
});
|
|
1368
1333
|
const operator = (0, rxjs_1.tap)({
|
|
1369
1334
|
next(value) {
|
|
1370
|
-
|
|
1371
|
-
|
|
1335
|
+
try {
|
|
1336
|
+
const newValue = filterMapCb(value);
|
|
1337
|
+
if (newValue !== undefined) {
|
|
1338
|
+
lastValue = newValue;
|
|
1339
|
+
}
|
|
1372
1340
|
}
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
!value.value.loading) {
|
|
1376
|
-
lastValue = value.value;
|
|
1341
|
+
catch (error) {
|
|
1342
|
+
reject(error);
|
|
1377
1343
|
}
|
|
1378
1344
|
},
|
|
1379
1345
|
finalize: () => {
|