@apollo/client 4.0.10 → 4.0.12-beta.0
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 +217 -0
- package/__cjs/cache/core/cache.cjs +216 -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 +77 -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/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 +56 -17
- package/__cjs/cache/inmemory/policies.cjs.map +1 -1
- package/__cjs/cache/inmemory/policies.d.cts +30 -6
- package/__cjs/cache/inmemory/readFromStore.cjs +3 -3
- package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/types.d.cts +2 -0
- package/__cjs/cache/inmemory/writeToStore.cjs +24 -10
- package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/writeToStore.d.cts +2 -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 +173 -128
- 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 +2 -1
- package/__cjs/core/QueryManager.cjs +47 -25
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/QueryManager.d.cts +18 -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 +222 -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/ws/index.cjs +1 -1
- package/__cjs/local-state/LocalState.cjs +28 -14
- 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/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/useSSRQuery.cjs +1 -0
- 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 +36 -4
- package/__cjs/utilities/internal/DeepMerger.cjs.map +1 -1
- package/__cjs/utilities/internal/DeepMerger.d.cts +20 -4
- 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/constants.cjs +29 -0
- package/__cjs/utilities/internal/constants.cjs.map +1 -0
- package/__cjs/utilities/internal/constants.d.cts +26 -0
- package/__cjs/utilities/internal/getStoreKeyName.cjs +1 -0
- package/__cjs/utilities/internal/getStoreKeyName.cjs.map +1 -1
- package/__cjs/utilities/internal/index.cjs +10 -2
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +4 -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 +2 -2
- package/__cjs/utilities/internal/memoize.cjs.map +1 -1
- package/__cjs/utilities/internal/memoize.d.cts +2 -1
- 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 +24 -0
- package/__cjs/version.cjs +1 -1
- package/__cjs/version.cjs.map +1 -1
- package/cache/core/cache.d.ts +141 -25
- package/cache/core/cache.js +219 -55
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/Cache.d.ts +77 -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/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 +30 -6
- package/cache/inmemory/policies.js +45 -7
- 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 +2 -0
- package/cache/inmemory/types.js.map +1 -1
- package/cache/inmemory/writeToStore.d.ts +2 -1
- package/cache/inmemory/writeToStore.js +26 -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 +176 -131
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +2 -1
- package/core/QueryInfo.js +10 -2
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +18 -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 +218 -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/ws/index.js +1 -1
- package/local-state/LocalState.d.ts +3 -2
- package/local-state/LocalState.js +28 -14
- 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/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/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/useSSRQuery.js +1 -0
- 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/combineLatestBatched.d.ts +14 -0
- package/utilities/internal/combineLatestBatched.js +68 -0
- package/utilities/internal/combineLatestBatched.js.map +1 -0
- package/utilities/internal/constants.d.ts +26 -0
- package/utilities/internal/constants.js +26 -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 +4 -0
- package/utilities/internal/index.js +3 -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 +2 -1
- package/utilities/internal/memoize.js +2 -2
- package/utilities/internal/memoize.js.map +1 -1
- 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 +24 -0
- package/utilities/internal/types/ExtensionsWithStreamDetails.js +2 -0
- package/utilities/internal/types/ExtensionsWithStreamDetails.js.map +1 -0
- package/version.js +1 -1
- package/version.js.map +1 -1
|
@@ -21,6 +21,7 @@ export interface WriteContext extends ReadMergeModifyContext {
|
|
|
21
21
|
clientOnly: boolean;
|
|
22
22
|
deferred: boolean;
|
|
23
23
|
flavors: Map<string, FlavorableWriteContext>;
|
|
24
|
+
extensions?: Record<string, unknown>;
|
|
24
25
|
}
|
|
25
26
|
type FlavorableWriteContext = Pick<WriteContext, "clientOnly" | "deferred" | "flavors">;
|
|
26
27
|
export declare class StoreWriter {
|
|
@@ -28,7 +29,7 @@ export declare class StoreWriter {
|
|
|
28
29
|
private reader?;
|
|
29
30
|
private fragments?;
|
|
30
31
|
constructor(cache: InMemoryCache, reader?: StoreReader | undefined, fragments?: InMemoryCacheConfig["fragments"]);
|
|
31
|
-
writeToStore<TData = unknown, TVariables extends OperationVariables = OperationVariables>(store: NormalizedCache, { query, result, dataId, variables, overwrite, }: Cache.WriteOptions<TData, TVariables>): Reference | undefined;
|
|
32
|
+
writeToStore<TData = unknown, TVariables extends OperationVariables = OperationVariables>(store: NormalizedCache, { query, result, dataId, variables, overwrite, extensions, }: Cache.WriteOptions<TData, TVariables>): Reference | undefined;
|
|
32
33
|
private processSelectionSet;
|
|
33
34
|
private processFieldValue;
|
|
34
35
|
private flattenFields;
|
|
@@ -79,10 +79,10 @@ class ApolloClient {
|
|
|
79
79
|
*/
|
|
80
80
|
constructor(options) {
|
|
81
81
|
if (environment_1.__DEV__) {
|
|
82
|
-
(0, invariant_1.invariant)(options.cache,
|
|
83
|
-
(0, invariant_1.invariant)(options.link,
|
|
82
|
+
(0, invariant_1.invariant)(options.cache, 68);
|
|
83
|
+
(0, invariant_1.invariant)(options.link, 69);
|
|
84
84
|
}
|
|
85
|
-
const { cache, documentTransform, ssrMode = false, ssrForceFetchDelay = 0, queryDeduplication = true, defaultOptions, defaultContext, assumeImmutableResults = cache.assumeImmutableResults, localState, devtools, dataMasking, link, incrementalHandler = new incremental_1.NotImplementedHandler(), } = options;
|
|
85
|
+
const { cache, documentTransform, ssrMode = false, ssrForceFetchDelay = 0, queryDeduplication = true, defaultOptions, defaultContext, assumeImmutableResults = cache.assumeImmutableResults, localState, devtools, dataMasking, link, incrementalHandler = new incremental_1.NotImplementedHandler(), experiments = [], } = options;
|
|
86
86
|
this.link = link;
|
|
87
87
|
this.cache = cache;
|
|
88
88
|
this.queryDeduplication = queryDeduplication;
|
|
@@ -127,6 +127,7 @@ class ApolloClient {
|
|
|
127
127
|
}
|
|
128
128
|
if (this.devtoolsConfig.enabled)
|
|
129
129
|
this.connectToDevTools();
|
|
130
|
+
experiments.forEach((experiment) => experiment.call(this, options));
|
|
130
131
|
}
|
|
131
132
|
connectToDevTools() {
|
|
132
133
|
if (typeof window === "undefined") {
|
|
@@ -240,13 +241,13 @@ class ApolloClient {
|
|
|
240
241
|
options = (0, internal_1.mergeOptions)(this.defaultOptions.query, options);
|
|
241
242
|
}
|
|
242
243
|
if (environment_1.__DEV__) {
|
|
243
|
-
(0, invariant_1.invariant)(options.fetchPolicy !== "cache-and-network",
|
|
244
|
-
(0, invariant_1.invariant)(options.fetchPolicy !== "standby",
|
|
245
|
-
(0, invariant_1.invariant)(options.query,
|
|
246
|
-
(0, invariant_1.invariant)(options.query.kind === "Document",
|
|
247
|
-
(0, invariant_1.invariant)(!options.returnPartialData,
|
|
248
|
-
(0, invariant_1.invariant)(!options.pollInterval,
|
|
249
|
-
(0, invariant_1.invariant)(!options.notifyOnNetworkStatusChange,
|
|
244
|
+
(0, invariant_1.invariant)(options.fetchPolicy !== "cache-and-network", 70);
|
|
245
|
+
(0, invariant_1.invariant)(options.fetchPolicy !== "standby", 71);
|
|
246
|
+
(0, invariant_1.invariant)(options.query, 72);
|
|
247
|
+
(0, invariant_1.invariant)(options.query.kind === "Document", 73);
|
|
248
|
+
(0, invariant_1.invariant)(!options.returnPartialData, 74);
|
|
249
|
+
(0, invariant_1.invariant)(!options.pollInterval, 75);
|
|
250
|
+
(0, invariant_1.invariant)(!options.notifyOnNetworkStatusChange, 76);
|
|
250
251
|
}
|
|
251
252
|
return this.queryManager.query(options);
|
|
252
253
|
}
|
|
@@ -264,9 +265,9 @@ class ApolloClient {
|
|
|
264
265
|
errorPolicy: "none",
|
|
265
266
|
}, this.defaultOptions.mutate), options);
|
|
266
267
|
if (environment_1.__DEV__) {
|
|
267
|
-
(0, invariant_1.invariant)(optionsWithDefaults.mutation,
|
|
268
|
+
(0, invariant_1.invariant)(optionsWithDefaults.mutation, 77);
|
|
268
269
|
(0, invariant_1.invariant)(optionsWithDefaults.fetchPolicy === "network-only" ||
|
|
269
|
-
optionsWithDefaults.fetchPolicy === "no-cache",
|
|
270
|
+
optionsWithDefaults.fetchPolicy === "no-cache", 78);
|
|
270
271
|
}
|
|
271
272
|
(0, internal_1.checkDocument)(optionsWithDefaults.mutation, graphql_1.OperationTypeNode.MUTATION);
|
|
272
273
|
return this.queryManager.mutate(optionsWithDefaults);
|
|
@@ -292,46 +293,27 @@ class ApolloClient {
|
|
|
292
293
|
readQuery(options, optimistic = false) {
|
|
293
294
|
return this.cache.readQuery({ ...options, query: this.transform(options.query) }, optimistic);
|
|
294
295
|
}
|
|
295
|
-
/**
|
|
296
|
-
* Watches the cache store of the fragment according to the options specified
|
|
297
|
-
* and returns an `Observable`. We can subscribe to this
|
|
298
|
-
* `Observable` and receive updated results through an
|
|
299
|
-
* observer when the cache store changes.
|
|
300
|
-
*
|
|
301
|
-
* You must pass in a GraphQL document with a single fragment or a document
|
|
302
|
-
* with multiple fragments that represent what you are reading. If you pass
|
|
303
|
-
* in a document with multiple fragments then you must also specify a
|
|
304
|
-
* `fragmentName`.
|
|
305
|
-
*
|
|
306
|
-
* @since 3.10.0
|
|
307
|
-
* @param options - An object of type `WatchFragmentOptions` that allows
|
|
308
|
-
* the cache to identify the fragment and optionally specify whether to react
|
|
309
|
-
* to optimistic updates.
|
|
310
|
-
*/
|
|
311
296
|
watchFragment(options) {
|
|
312
297
|
const dataMasking = this.queryManager.dataMasking;
|
|
313
|
-
|
|
314
|
-
.watchFragment({
|
|
298
|
+
const observable = this.cache.watchFragment({
|
|
315
299
|
...options,
|
|
316
300
|
fragment: this.transform(options.fragment, dataMasking),
|
|
317
|
-
})
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
return result;
|
|
334
|
-
}));
|
|
301
|
+
});
|
|
302
|
+
if (environment_1.__DEV__) {
|
|
303
|
+
return (0, internal_1.mapObservableFragmentMemoized)(observable, Symbol.for("apollo.transform.dev.mask"), (result) => ({
|
|
304
|
+
...result,
|
|
305
|
+
// The transform will remove fragment spreads from the fragment
|
|
306
|
+
// document when dataMasking is enabled. The `mask` function
|
|
307
|
+
// remains to apply warnings to fragments marked as
|
|
308
|
+
// `@unmask(mode: "migrate")`. Since these warnings are only applied
|
|
309
|
+
// in dev, we can skip the masking algorithm entirely for production.
|
|
310
|
+
data: this.queryManager.maskFragment({
|
|
311
|
+
...options,
|
|
312
|
+
data: result.data,
|
|
313
|
+
}),
|
|
314
|
+
}));
|
|
315
|
+
}
|
|
316
|
+
return observable;
|
|
335
317
|
}
|
|
336
318
|
readFragment(options, optimistic = false) {
|
|
337
319
|
return this.cache.readFragment({ ...options, fragment: this.transform(options.fragment) }, optimistic);
|
|
@@ -491,7 +473,7 @@ class ApolloClient {
|
|
|
491
473
|
// result.queries and result.results instead, you shouldn't have to worry
|
|
492
474
|
// about preventing uncaught rejections for the Promise.all result.
|
|
493
475
|
result.catch((error) => {
|
|
494
|
-
__DEV__ && invariant_1.invariant.debug(
|
|
476
|
+
__DEV__ && invariant_1.invariant.debug(79, error);
|
|
495
477
|
});
|
|
496
478
|
return result;
|
|
497
479
|
}
|