@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
package/core/ObservableQuery.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { equal } from "@wry/equality";
|
|
2
|
-
import { BehaviorSubject,
|
|
3
|
-
import { isNetworkRequestInFlight
|
|
2
|
+
import { BehaviorSubject, Observable, share, Subject, tap } from "rxjs";
|
|
3
|
+
import { isNetworkRequestInFlight } from "@apollo/client/utilities";
|
|
4
4
|
import { __DEV__ } from "@apollo/client/utilities/environment";
|
|
5
|
-
import { compact, equalByQuery,
|
|
5
|
+
import { compact, equalByQuery, 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;
|
|
@@ -61,9 +61,6 @@ export class ObservableQuery {
|
|
|
61
61
|
get networkStatus() {
|
|
62
62
|
return this.subject.getValue().result.networkStatus;
|
|
63
63
|
}
|
|
64
|
-
get cache() {
|
|
65
|
-
return this.queryManager.cache;
|
|
66
|
-
}
|
|
67
64
|
constructor({ queryManager, options, transformedQuery = queryManager.transform(options.query), }) {
|
|
68
65
|
this.queryManager = queryManager;
|
|
69
66
|
// active state
|
|
@@ -76,7 +73,7 @@ export class ObservableQuery {
|
|
|
76
73
|
// Make sure we don't store "standby" as the initialFetchPolicy.
|
|
77
74
|
initialFetchPolicy = fetchPolicy === "standby" ? defaultFetchPolicy : (fetchPolicy), } = options;
|
|
78
75
|
if (options[variablesUnknownSymbol]) {
|
|
79
|
-
invariant(fetchPolicy === "standby",
|
|
76
|
+
invariant(fetchPolicy === "standby", 77);
|
|
80
77
|
this.variablesUnknown = true;
|
|
81
78
|
}
|
|
82
79
|
this.lastQuery = transformedQuery;
|
|
@@ -205,7 +202,7 @@ export class ObservableQuery {
|
|
|
205
202
|
* @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
|
|
206
203
|
*/
|
|
207
204
|
getCacheDiff({ optimistic = true } = {}) {
|
|
208
|
-
return this.cache.diff({
|
|
205
|
+
return this.queryManager.cache.diff({
|
|
209
206
|
query: this.query,
|
|
210
207
|
variables: this.variables,
|
|
211
208
|
returnPartialData: true,
|
|
@@ -316,7 +313,7 @@ export class ObservableQuery {
|
|
|
316
313
|
}
|
|
317
314
|
},
|
|
318
315
|
};
|
|
319
|
-
const cancelWatch = this.cache.watch(watch);
|
|
316
|
+
const cancelWatch = this.queryManager.cache.watch(watch);
|
|
320
317
|
this.unsubscribeFromCache = Object.assign(() => {
|
|
321
318
|
this.unsubscribeFromCache = undefined;
|
|
322
319
|
cancelWatch();
|
|
@@ -380,7 +377,7 @@ export class ObservableQuery {
|
|
|
380
377
|
const queryDef = getQueryDefinition(this.query);
|
|
381
378
|
const vars = queryDef.variableDefinitions;
|
|
382
379
|
if (!vars || !vars.some((v) => v.variable.name.value === "variables")) {
|
|
383
|
-
__DEV__ && invariant.warn(
|
|
380
|
+
__DEV__ && invariant.warn(78, variables, queryDef.name?.value || queryDef);
|
|
384
381
|
}
|
|
385
382
|
}
|
|
386
383
|
if (variables && !equal(this.variables, variables)) {
|
|
@@ -396,7 +393,7 @@ export class ObservableQuery {
|
|
|
396
393
|
fetchMore({ query, variables, context, errorPolicy, updateQuery, }) {
|
|
397
394
|
invariant(
|
|
398
395
|
this.options.fetchPolicy !== "cache-only",
|
|
399
|
-
|
|
396
|
+
79,
|
|
400
397
|
getOperationName(this.query, "(anonymous)")
|
|
401
398
|
);
|
|
402
399
|
const combinedOptions = {
|
|
@@ -430,7 +427,7 @@ export class ObservableQuery {
|
|
|
430
427
|
let wasUpdated = false;
|
|
431
428
|
const isCached = this.options.fetchPolicy !== "no-cache";
|
|
432
429
|
if (!isCached) {
|
|
433
|
-
invariant(updateQuery,
|
|
430
|
+
invariant(updateQuery, 80);
|
|
434
431
|
}
|
|
435
432
|
const { finalize, pushNotification } = this.pushOperation(NetworkStatus.fetchMore);
|
|
436
433
|
pushNotification({
|
|
@@ -438,149 +435,109 @@ export class ObservableQuery {
|
|
|
438
435
|
kind: "N",
|
|
439
436
|
value: {},
|
|
440
437
|
}, { 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
|
-
|
|
528
|
-
// If we get bug reports due to the `data` property access on
|
|
529
|
-
// undefined, this should give us a real-world scenario that we can
|
|
530
|
-
// use to test against and determine the right behavior. If we do end
|
|
531
|
-
// up changing this behavior, this may require, for example, an
|
|
532
|
-
// adjustment to the types on `updateQuery` since that function
|
|
533
|
-
// expects that the first argument always contains previous result
|
|
534
|
-
// data, but not `undefined`.
|
|
535
|
-
const lastResult = this.getCurrentResult();
|
|
536
|
-
const data = updateQuery(lastResult.data, {
|
|
537
|
-
fetchMoreResult: fetchMoreResult.data,
|
|
538
|
-
variables: combinedOptions.variables,
|
|
539
|
-
});
|
|
540
|
-
pushNotification({
|
|
541
|
-
kind: "N",
|
|
542
|
-
value: {
|
|
543
|
-
...lastResult,
|
|
544
|
-
networkStatus: NetworkStatus.ready,
|
|
545
|
-
// will be overwritten anyways, just here for types sake
|
|
546
|
-
loading: false,
|
|
547
|
-
data: data,
|
|
548
|
-
dataState: lastResult.dataState === "streaming" ?
|
|
549
|
-
"streaming"
|
|
550
|
-
: "complete",
|
|
551
|
-
},
|
|
552
|
-
source: "network",
|
|
553
|
-
});
|
|
554
|
-
}
|
|
555
|
-
},
|
|
556
|
-
});
|
|
557
|
-
return preventUnhandledRejection(promise
|
|
558
|
-
.then((result) => toQueryResult(this.maskResult(result)))
|
|
438
|
+
return this.queryManager
|
|
439
|
+
.fetchQuery(combinedOptions, NetworkStatus.fetchMore)
|
|
440
|
+
.then((fetchMoreResult) => {
|
|
441
|
+
// disable the `fetchMore` override that is currently active
|
|
442
|
+
// the next updates caused by this should not be `fetchMore` anymore,
|
|
443
|
+
// but `ready` or whatever other calculated loading state is currently
|
|
444
|
+
// appropriate
|
|
445
|
+
finalize();
|
|
446
|
+
if (isCached) {
|
|
447
|
+
// Separately getting a diff here before the batch - `onWatchUpdated` might be
|
|
448
|
+
// called with an `undefined` `lastDiff` on the watcher if the cache was just subscribed to.
|
|
449
|
+
const lastDiff = this.getCacheDiff();
|
|
450
|
+
// Performing this cache update inside a cache.batch transaction ensures
|
|
451
|
+
// any affected cache.watch watchers are notified at most once about any
|
|
452
|
+
// updates. Most watchers will be using the QueryInfo class, which
|
|
453
|
+
// responds to notifications by calling reobserveCacheFirst to deliver
|
|
454
|
+
// fetchMore cache results back to this ObservableQuery.
|
|
455
|
+
this.queryManager.cache.batch({
|
|
456
|
+
update: (cache) => {
|
|
457
|
+
if (updateQuery) {
|
|
458
|
+
cache.updateQuery({
|
|
459
|
+
query: this.query,
|
|
460
|
+
variables: this.variables,
|
|
461
|
+
returnPartialData: true,
|
|
462
|
+
optimistic: false,
|
|
463
|
+
}, (previous) => updateQuery(previous, {
|
|
464
|
+
fetchMoreResult: fetchMoreResult.data,
|
|
465
|
+
variables: combinedOptions.variables,
|
|
466
|
+
}));
|
|
467
|
+
}
|
|
468
|
+
else {
|
|
469
|
+
// If we're using a field policy instead of updateQuery, the only
|
|
470
|
+
// thing we need to do is write the new data to the cache using
|
|
471
|
+
// combinedOptions.variables (instead of this.variables, which is
|
|
472
|
+
// what this.updateQuery uses, because it works by abusing the
|
|
473
|
+
// original field value, keyed by the original variables).
|
|
474
|
+
cache.writeQuery({
|
|
475
|
+
query: combinedOptions.query,
|
|
476
|
+
variables: combinedOptions.variables,
|
|
477
|
+
data: fetchMoreResult.data,
|
|
478
|
+
});
|
|
479
|
+
}
|
|
480
|
+
},
|
|
481
|
+
onWatchUpdated: (watch, diff) => {
|
|
482
|
+
if (watch.watcher === this &&
|
|
483
|
+
!equal(diff.result, lastDiff.result)) {
|
|
484
|
+
wasUpdated = true;
|
|
485
|
+
}
|
|
486
|
+
},
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
else {
|
|
490
|
+
// There is a possibility `lastResult` may not be set when
|
|
491
|
+
// `fetchMore` is called which would cause this to crash. This should
|
|
492
|
+
// only happen if we haven't previously reported a result. We don't
|
|
493
|
+
// quite know what the right behavior should be here since this block
|
|
494
|
+
// of code runs after the fetch result has executed on the network.
|
|
495
|
+
// We plan to let it crash in the meantime.
|
|
496
|
+
//
|
|
497
|
+
// If we get bug reports due to the `data` property access on
|
|
498
|
+
// undefined, this should give us a real-world scenario that we can
|
|
499
|
+
// use to test against and determine the right behavior. If we do end
|
|
500
|
+
// up changing this behavior, this may require, for example, an
|
|
501
|
+
// adjustment to the types on `updateQuery` since that function
|
|
502
|
+
// expects that the first argument always contains previous result
|
|
503
|
+
// data, but not `undefined`.
|
|
504
|
+
const lastResult = this.getCurrentResult();
|
|
505
|
+
const data = updateQuery(lastResult.data, {
|
|
506
|
+
fetchMoreResult: fetchMoreResult.data,
|
|
507
|
+
variables: combinedOptions.variables,
|
|
508
|
+
});
|
|
509
|
+
// was reportResult
|
|
510
|
+
pushNotification({
|
|
511
|
+
kind: "N",
|
|
512
|
+
value: {
|
|
513
|
+
...lastResult,
|
|
514
|
+
networkStatus: NetworkStatus.ready,
|
|
515
|
+
// will be overwritten anyways, just here for types sake
|
|
516
|
+
loading: false,
|
|
517
|
+
data: data,
|
|
518
|
+
dataState: lastResult.dataState === "streaming" ? "streaming" : "complete",
|
|
519
|
+
},
|
|
520
|
+
source: "network",
|
|
521
|
+
});
|
|
522
|
+
}
|
|
523
|
+
return this.maskResult(fetchMoreResult);
|
|
524
|
+
})
|
|
559
525
|
.finally(() => {
|
|
560
|
-
|
|
526
|
+
// call `finalize` a second time in case the `.then` case above was not reached
|
|
561
527
|
finalize();
|
|
528
|
+
// In case the cache writes above did not generate a broadcast
|
|
529
|
+
// notification (which would have been intercepted by onWatchUpdated),
|
|
530
|
+
// likely because the written data were the same as what was already in
|
|
531
|
+
// the cache, we still want fetchMore to deliver its final loading:false
|
|
532
|
+
// result with the unchanged data.
|
|
562
533
|
if (isCached && !wasUpdated) {
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
value: {
|
|
569
|
-
...lastResult,
|
|
570
|
-
dataState: "complete",
|
|
571
|
-
networkStatus: NetworkStatus.ready,
|
|
572
|
-
},
|
|
573
|
-
});
|
|
574
|
-
}
|
|
575
|
-
else {
|
|
576
|
-
pushNotification({
|
|
577
|
-
kind: "N",
|
|
578
|
-
source: "newNetworkStatus",
|
|
579
|
-
value: {},
|
|
580
|
-
}, { shouldEmit: 1 /* EmitBehavior.force */ });
|
|
581
|
-
}
|
|
534
|
+
pushNotification({
|
|
535
|
+
kind: "N",
|
|
536
|
+
source: "newNetworkStatus",
|
|
537
|
+
value: {},
|
|
538
|
+
}, { shouldEmit: 1 /* EmitBehavior.force */ });
|
|
582
539
|
}
|
|
583
|
-
})
|
|
540
|
+
});
|
|
584
541
|
}
|
|
585
542
|
// XXX the subscription variables are separate from the query variables.
|
|
586
543
|
// if you want to update subscription variables, right now you have to do that separately,
|
|
@@ -606,7 +563,7 @@ export class ObservableQuery {
|
|
|
606
563
|
onError(error);
|
|
607
564
|
}
|
|
608
565
|
else {
|
|
609
|
-
invariant.error(
|
|
566
|
+
invariant.error(81, error);
|
|
610
567
|
}
|
|
611
568
|
return;
|
|
612
569
|
}
|
|
@@ -684,7 +641,7 @@ export class ObservableQuery {
|
|
|
684
641
|
previousData: result,
|
|
685
642
|
});
|
|
686
643
|
if (newResult) {
|
|
687
|
-
|
|
644
|
+
queryManager.cache.writeQuery({
|
|
688
645
|
query: this.options.query,
|
|
689
646
|
data: newResult,
|
|
690
647
|
variables: this.variables,
|
|
@@ -850,7 +807,7 @@ export class ObservableQuery {
|
|
|
850
807
|
if (!this.didWarnCacheOnlyPolling &&
|
|
851
808
|
pollInterval &&
|
|
852
809
|
fetchPolicy === "cache-only") {
|
|
853
|
-
__DEV__ && invariant.warn(
|
|
810
|
+
__DEV__ && invariant.warn(82, getOperationName(this.query, "(anonymous)"));
|
|
854
811
|
this.didWarnCacheOnlyPolling = true;
|
|
855
812
|
}
|
|
856
813
|
}
|
|
@@ -991,7 +948,15 @@ export class ObservableQuery {
|
|
|
991
948
|
this.cancelPolling();
|
|
992
949
|
}
|
|
993
950
|
this.resubscribeCache();
|
|
994
|
-
const { promise, operator: promiseOperator } = getTrackingOperatorPromise(
|
|
951
|
+
const { promise, operator: promiseOperator } = getTrackingOperatorPromise((value) => {
|
|
952
|
+
switch (value.kind) {
|
|
953
|
+
case "E":
|
|
954
|
+
throw value.error;
|
|
955
|
+
case "N":
|
|
956
|
+
if (value.source !== "newNetworkStatus" && !value.value.loading)
|
|
957
|
+
return value.value;
|
|
958
|
+
}
|
|
959
|
+
},
|
|
995
960
|
// This default value should only be used when using a `fetchPolicy` of
|
|
996
961
|
// `standby` since that fetch policy completes without emitting a
|
|
997
962
|
// result. Since we are converting this to a QueryResult type, we
|
|
@@ -1113,8 +1078,8 @@ export class ObservableQuery {
|
|
|
1113
1078
|
const { dirty } = this;
|
|
1114
1079
|
this.resetNotifications();
|
|
1115
1080
|
if (dirty &&
|
|
1116
|
-
(this.options.fetchPolicy
|
|
1117
|
-
this.options.fetchPolicy
|
|
1081
|
+
(this.options.fetchPolicy == "cache-only" ||
|
|
1082
|
+
this.options.fetchPolicy == "cache-and-network" ||
|
|
1118
1083
|
!this.activeOperations.size)) {
|
|
1119
1084
|
const diff = this.getCacheDiff();
|
|
1120
1085
|
if (
|
|
@@ -1344,13 +1309,13 @@ export class ObservableQuery {
|
|
|
1344
1309
|
}
|
|
1345
1310
|
export function logMissingFieldErrors(missing) {
|
|
1346
1311
|
if (__DEV__ && missing) {
|
|
1347
|
-
__DEV__ && invariant.debug(
|
|
1312
|
+
__DEV__ && invariant.debug(83, missing);
|
|
1348
1313
|
}
|
|
1349
1314
|
}
|
|
1350
1315
|
function isEqualQuery(a, b) {
|
|
1351
1316
|
return !!(a && b && a.query === b.query && equal(a.variables, b.variables));
|
|
1352
1317
|
}
|
|
1353
|
-
function getTrackingOperatorPromise(defaultValue) {
|
|
1318
|
+
function getTrackingOperatorPromise(filterMapCb, defaultValue) {
|
|
1354
1319
|
let lastValue = defaultValue, resolve, reject;
|
|
1355
1320
|
const promise = new Promise((res, rej) => {
|
|
1356
1321
|
resolve = res;
|
|
@@ -1358,13 +1323,14 @@ function getTrackingOperatorPromise(defaultValue) {
|
|
|
1358
1323
|
});
|
|
1359
1324
|
const operator = tap({
|
|
1360
1325
|
next(value) {
|
|
1361
|
-
|
|
1362
|
-
|
|
1326
|
+
try {
|
|
1327
|
+
const newValue = filterMapCb(value);
|
|
1328
|
+
if (newValue !== undefined) {
|
|
1329
|
+
lastValue = newValue;
|
|
1330
|
+
}
|
|
1363
1331
|
}
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
!value.value.loading) {
|
|
1367
|
-
lastValue = value.value;
|
|
1332
|
+
catch (error) {
|
|
1333
|
+
reject(error);
|
|
1368
1334
|
}
|
|
1369
1335
|
},
|
|
1370
1336
|
finalize: () => {
|