@apollo/client 3.8.0-alpha.0 → 3.8.0-alpha.10
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/README.md +10 -8
- package/apollo-client.cjs +595 -339
- package/apollo-client.cjs.map +1 -1
- package/apollo-client.min.cjs +1 -1
- package/cache/cache.cjs +54 -44
- package/cache/cache.cjs.map +1 -1
- package/cache/cache.cjs.native.js +54 -44
- package/cache/core/cache.d.ts +1 -1
- package/cache/core/cache.d.ts.map +1 -1
- package/cache/core/cache.js.map +1 -1
- package/cache/core/types/DataProxy.d.ts +3 -2
- package/cache/core/types/DataProxy.d.ts.map +1 -1
- package/cache/core/types/DataProxy.js.map +1 -1
- package/cache/core/types/common.d.ts +7 -7
- package/cache/core/types/common.d.ts.map +1 -1
- package/cache/inmemory/entityStore.d.ts +1 -1
- package/cache/inmemory/entityStore.d.ts.map +1 -1
- package/cache/inmemory/entityStore.js +1 -1
- package/cache/inmemory/helpers.d.ts +2 -2
- package/cache/inmemory/helpers.d.ts.map +1 -1
- package/cache/inmemory/helpers.js +2 -2
- package/cache/inmemory/helpers.js.map +1 -1
- package/cache/inmemory/inMemoryCache.d.ts +3 -2
- package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
- package/cache/inmemory/inMemoryCache.js +1 -1
- package/cache/inmemory/inMemoryCache.js.map +1 -1
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/object-canon.d.ts +0 -1
- package/cache/inmemory/object-canon.d.ts.map +1 -1
- package/cache/inmemory/object-canon.js +1 -1
- package/cache/inmemory/object-canon.js.map +1 -1
- package/cache/inmemory/policies.d.ts +12 -12
- package/cache/inmemory/policies.d.ts.map +1 -1
- package/cache/inmemory/policies.js +15 -4
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/reactiveVars.d.ts +1 -1
- package/cache/inmemory/reactiveVars.d.ts.map +1 -1
- package/cache/inmemory/readFromStore.d.ts +2 -2
- package/cache/inmemory/readFromStore.d.ts.map +1 -1
- package/cache/inmemory/readFromStore.js +1 -1
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/types.d.ts +4 -4
- package/cache/inmemory/types.d.ts.map +1 -1
- package/cache/inmemory/writeToStore.d.ts +1 -1
- package/cache/inmemory/writeToStore.d.ts.map +1 -1
- package/cache/inmemory/writeToStore.js +1 -1
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.d.ts +10 -9
- package/core/ApolloClient.d.ts.map +1 -1
- package/core/ApolloClient.js +11 -5
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.d.ts +12 -7
- package/core/LocalState.d.ts.map +1 -1
- package/core/LocalState.js +71 -17
- package/core/LocalState.js.map +1 -1
- package/core/ObservableQuery.d.ts +7 -6
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +7 -4
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryInfo.d.ts +1 -1
- package/core/QueryInfo.d.ts.map +1 -1
- package/core/QueryInfo.js +3 -16
- package/core/QueryInfo.js.map +1 -1
- package/core/QueryManager.d.ts +7 -7
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +72 -37
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs +265 -100
- package/core/core.cjs.map +1 -1
- package/core/core.cjs.native.js +265 -100
- package/core/index.js +2 -2
- package/core/index.js.map +1 -1
- package/core/types.d.ts +21 -17
- package/core/types.d.ts.map +1 -1
- package/core/types.js +1 -0
- package/core/types.js.map +1 -1
- package/core/watchQueryOptions.d.ts +11 -11
- package/core/watchQueryOptions.d.ts.map +1 -1
- package/core/watchQueryOptions.js.map +1 -1
- package/errors/index.d.ts +2 -2
- package/errors/index.d.ts.map +1 -1
- package/invariantErrorCodes.js +36 -35
- package/link/batch/batch.cjs +5 -3
- package/link/batch/batch.cjs.map +1 -1
- package/link/batch/batch.cjs.native.js +5 -3
- package/link/batch/batching.d.ts +2 -2
- package/link/batch/batching.d.ts.map +1 -1
- package/link/batch/batching.js +5 -3
- package/link/batch/batching.js.map +1 -1
- package/link/batch-http/batch-http.cjs +12 -2
- package/link/batch-http/batch-http.cjs.map +1 -1
- package/link/batch-http/batch-http.cjs.native.js +12 -2
- package/link/batch-http/batchHttpLink.d.ts.map +1 -1
- package/link/batch-http/batchHttpLink.js +13 -3
- package/link/batch-http/batchHttpLink.js.map +1 -1
- package/link/context/index.d.ts +2 -1
- package/link/context/index.d.ts.map +1 -1
- package/link/context/index.js.map +1 -1
- package/link/core/ApolloLink.js +2 -2
- package/link/core/core.cjs +2 -2
- package/link/core/core.cjs.map +1 -1
- package/link/core/core.cjs.native.js +2 -2
- package/link/core/types.d.ts +15 -15
- package/link/core/types.d.ts.map +1 -1
- package/link/core/types.js.map +1 -1
- package/link/http/checkFetcher.js +2 -2
- package/link/http/createHttpLink.d.ts +0 -1
- package/link/http/createHttpLink.d.ts.map +1 -1
- package/link/http/createHttpLink.js +10 -2
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/http.cjs +20 -38
- package/link/http/http.cjs.map +1 -1
- package/link/http/http.cjs.native.js +20 -38
- package/link/http/iterators/async.js.map +1 -1
- package/link/http/iterators/nodeStream.js.map +1 -1
- package/link/http/iterators/promise.js.map +1 -1
- package/link/http/iterators/reader.js.map +1 -1
- package/link/http/parseAndCheckHttpResponse.d.ts +2 -2
- package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -1
- package/link/http/parseAndCheckHttpResponse.js.map +1 -1
- package/link/http/responseIterator.js +1 -1
- package/link/http/responseIterator.js.map +1 -1
- package/link/http/selectHttpOptionsAndBody.d.ts +2 -2
- package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
- package/link/http/selectHttpOptionsAndBody.js +3 -1
- package/link/http/selectHttpOptionsAndBody.js.map +1 -1
- package/link/http/serializeFetchParameter.d.ts +1 -1
- package/link/http/serializeFetchParameter.d.ts.map +1 -1
- package/link/http/serializeFetchParameter.js +2 -2
- package/link/persisted-queries/index.d.ts +2 -2
- package/link/persisted-queries/index.d.ts.map +1 -1
- package/link/persisted-queries/index.js +3 -3
- package/link/persisted-queries/persisted-queries.cjs +3 -3
- package/link/persisted-queries/persisted-queries.cjs.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.native.js +3 -3
- package/link/utils/throwServerError.d.ts +1 -1
- package/link/utils/throwServerError.d.ts.map +1 -1
- package/link/utils/toPromise.js +1 -1
- package/link/utils/utils.cjs +2 -2
- package/link/utils/utils.cjs.map +1 -1
- package/link/utils/utils.cjs.native.js +2 -2
- package/link/utils/validateOperation.js +2 -2
- package/package.json +29 -27
- package/react/cache/SuspenseCache.d.ts +1 -1
- package/react/cache/SuspenseCache.d.ts.map +1 -1
- package/react/cache/SuspenseCache.js.map +1 -1
- package/react/components/Query.d.ts +2 -2
- package/react/components/Query.d.ts.map +1 -1
- package/react/components/Query.js.map +1 -1
- package/react/components/Subscription.d.ts +2 -2
- package/react/components/Subscription.d.ts.map +1 -1
- package/react/components/Subscription.js.map +1 -1
- package/react/components/types.d.ts +2 -2
- package/react/components/types.d.ts.map +1 -1
- package/react/components/types.js.map +1 -1
- package/react/context/ApolloConsumer.js +2 -2
- package/react/context/ApolloProvider.js +2 -2
- package/react/context/context.cjs +4 -4
- package/react/context/context.cjs.map +1 -1
- package/react/context/context.cjs.native.js +4 -4
- package/react/hoc/graphql.d.ts +2 -1
- package/react/hoc/graphql.d.ts.map +1 -1
- package/react/hoc/graphql.js.map +1 -1
- package/react/hoc/hoc-utils.d.ts +1 -1
- package/react/hoc/hoc-utils.d.ts.map +1 -1
- package/react/hoc/hoc-utils.js +2 -2
- package/react/hoc/hoc.cjs +4 -4
- package/react/hoc/hoc.cjs.map +1 -1
- package/react/hoc/hoc.cjs.native.js +4 -4
- package/react/hoc/mutation-hoc.d.ts +2 -2
- package/react/hoc/mutation-hoc.d.ts.map +1 -1
- package/react/hoc/mutation-hoc.js.map +1 -1
- package/react/hoc/query-hoc.d.ts +1 -1
- package/react/hoc/query-hoc.d.ts.map +1 -1
- package/react/hoc/query-hoc.js.map +1 -1
- package/react/hoc/subscription-hoc.d.ts +1 -1
- package/react/hoc/subscription-hoc.d.ts.map +1 -1
- package/react/hoc/subscription-hoc.js.map +1 -1
- package/react/hoc/types.d.ts +6 -6
- package/react/hoc/types.d.ts.map +1 -1
- package/react/hoc/types.js.map +1 -1
- package/react/hoc/withApollo.js +2 -2
- package/react/hooks/hooks.cjs +154 -72
- package/react/hooks/hooks.cjs.map +1 -1
- package/react/hooks/hooks.cjs.native.js +154 -72
- package/react/hooks/internal/index.d.ts +1 -0
- package/react/hooks/internal/index.d.ts.map +1 -1
- package/react/hooks/internal/index.js +1 -0
- package/react/hooks/internal/index.js.map +1 -1
- package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts +3 -0
- package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts.map +1 -0
- package/react/hooks/internal/useIsomorphicLayoutEffect.js +6 -0
- package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -0
- package/react/hooks/useApolloClient.js +2 -2
- package/react/hooks/useFragment.d.ts +4 -2
- package/react/hooks/useFragment.d.ts.map +1 -1
- package/react/hooks/useFragment.js +9 -8
- package/react/hooks/useFragment.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +2 -2
- package/react/hooks/useLazyQuery.d.ts.map +1 -1
- package/react/hooks/useLazyQuery.js +22 -8
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +2 -2
- package/react/hooks/useMutation.d.ts.map +1 -1
- package/react/hooks/useMutation.js +9 -8
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +6 -5
- package/react/hooks/useQuery.d.ts.map +1 -1
- package/react/hooks/useQuery.js +21 -7
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +2 -3
- package/react/hooks/useSubscription.d.ts.map +1 -1
- package/react/hooks/useSubscription.js +1 -2
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseCache.d.ts +2 -1
- package/react/hooks/useSuspenseCache.d.ts.map +1 -1
- package/react/hooks/useSuspenseCache.js +7 -5
- package/react/hooks/useSuspenseCache.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +11 -4
- package/react/hooks/useSuspenseQuery.d.ts.map +1 -1
- package/react/hooks/useSuspenseQuery.js +80 -34
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks/useSyncExternalStore.d.ts +1 -1
- package/react/hooks/useSyncExternalStore.d.ts.map +1 -1
- package/react/hooks/useSyncExternalStore.js +1 -1
- package/react/hooks/useSyncExternalStore.js.map +1 -1
- package/react/parser/index.js +6 -6
- package/react/parser/parser.cjs +10 -10
- package/react/parser/parser.cjs.map +1 -1
- package/react/parser/parser.cjs.native.js +10 -10
- package/react/ssr/RenderPromises.d.ts +4 -4
- package/react/ssr/RenderPromises.d.ts.map +1 -1
- package/react/ssr/RenderPromises.js.map +1 -1
- package/react/ssr/getDataFromTree.d.ts +1 -1
- package/react/ssr/getDataFromTree.d.ts.map +1 -1
- package/react/types/types.d.ts +26 -23
- package/react/types/types.d.ts.map +1 -1
- package/react/types/types.js.map +1 -1
- package/testing/core/core.cjs +30 -3
- package/testing/core/core.cjs.map +1 -1
- package/testing/core/core.cjs.native.js +30 -3
- package/testing/core/index.d.ts +2 -1
- package/testing/core/index.d.ts.map +1 -1
- package/testing/core/index.js +1 -0
- package/testing/core/index.js.map +1 -1
- package/testing/core/itAsync.js.map +1 -1
- package/testing/core/mocking/mockFetch.js.map +1 -1
- package/testing/core/mocking/mockLink.d.ts +8 -4
- package/testing/core/mocking/mockLink.d.ts.map +1 -1
- package/testing/core/mocking/mockLink.js +14 -4
- package/testing/core/mocking/mockLink.js.map +1 -1
- package/testing/core/mocking/mockQueryManager.d.ts +1 -1
- package/testing/core/mocking/mockQueryManager.d.ts.map +1 -1
- package/testing/core/mocking/mockQueryManager.js +3 -3
- package/testing/core/mocking/mockQueryManager.js.map +1 -1
- package/testing/core/mocking/mockWatchQuery.d.ts +1 -1
- package/testing/core/mocking/mockWatchQuery.d.ts.map +1 -1
- package/testing/core/mocking/mockWatchQuery.js +4 -5
- package/testing/core/mocking/mockWatchQuery.js.map +1 -1
- package/testing/core/observableToPromise.d.ts +2 -2
- package/testing/core/observableToPromise.d.ts.map +1 -1
- package/testing/core/observableToPromise.js.map +1 -1
- package/testing/core/wait.d.ts +3 -0
- package/testing/core/wait.d.ts.map +1 -0
- package/testing/core/wait.js +16 -0
- package/testing/core/wait.js.map +1 -0
- package/testing/react/MockedProvider.d.ts +1 -0
- package/testing/react/MockedProvider.d.ts.map +1 -1
- package/testing/react/MockedProvider.js +2 -2
- package/testing/react/MockedProvider.js.map +1 -1
- package/testing/testing.cjs +2 -2
- package/testing/testing.cjs.map +1 -1
- package/testing/testing.cjs.native.js +2 -2
- package/utilities/common/arrays.d.ts +1 -0
- package/utilities/common/arrays.d.ts.map +1 -1
- package/utilities/common/arrays.js +1 -0
- package/utilities/common/arrays.js.map +1 -1
- package/utilities/common/cloneDeep.js.map +1 -1
- package/utilities/common/errorHandling.d.ts +3 -2
- package/utilities/common/errorHandling.d.ts.map +1 -1
- package/utilities/common/errorHandling.js +18 -1
- package/utilities/common/errorHandling.js.map +1 -1
- package/utilities/common/incrementalResult.d.ts +5 -2
- package/utilities/common/incrementalResult.d.ts.map +1 -1
- package/utilities/common/incrementalResult.js +29 -1
- package/utilities/common/incrementalResult.js.map +1 -1
- package/utilities/common/maybeDeepFreeze.d.ts +0 -1
- package/utilities/common/maybeDeepFreeze.d.ts.map +1 -1
- package/utilities/common/maybeDeepFreeze.js +1 -1
- package/utilities/common/maybeDeepFreeze.js.map +1 -1
- package/utilities/common/mergeDeep.d.ts +2 -2
- package/utilities/common/mergeDeep.d.ts.map +1 -1
- package/utilities/common/mergeOptions.d.ts +3 -3
- package/utilities/common/mergeOptions.d.ts.map +1 -1
- package/utilities/common/mergeOptions.js.map +1 -1
- package/utilities/globals/DEV.d.ts +1 -1
- package/utilities/globals/DEV.d.ts.map +1 -1
- package/utilities/globals/DEV.js +1 -17
- package/utilities/globals/DEV.js.map +1 -1
- package/utilities/globals/global.d.ts +5 -2
- package/utilities/globals/global.d.ts.map +1 -1
- package/utilities/globals/global.js.map +1 -1
- package/utilities/globals/globals.cjs +5 -22
- package/utilities/globals/globals.cjs.map +1 -1
- package/utilities/globals/globals.cjs.native.js +5 -22
- package/utilities/globals/index.d.ts +1 -1
- package/utilities/globals/index.d.ts.map +1 -1
- package/utilities/globals/index.js +1 -4
- package/utilities/globals/index.js.map +1 -1
- package/utilities/graphql/directives.d.ts +2 -2
- package/utilities/graphql/directives.d.ts.map +1 -1
- package/utilities/graphql/directives.js +1 -1
- package/utilities/graphql/directives.js.map +1 -1
- package/utilities/graphql/fragments.d.ts +1 -1
- package/utilities/graphql/fragments.d.ts.map +1 -1
- package/utilities/graphql/fragments.js +1 -1
- package/utilities/graphql/getFromAST.d.ts.map +1 -1
- package/utilities/graphql/getFromAST.js +8 -4
- package/utilities/graphql/getFromAST.js.map +1 -1
- package/utilities/graphql/storeUtils.d.ts +3 -3
- package/utilities/graphql/storeUtils.d.ts.map +1 -1
- package/utilities/graphql/storeUtils.js +1 -1
- package/utilities/graphql/storeUtils.js.map +1 -1
- package/utilities/graphql/transform.d.ts +9 -9
- package/utilities/graphql/transform.d.ts.map +1 -1
- package/utilities/graphql/transform.js +168 -91
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/index.d.ts +2 -0
- package/utilities/index.d.ts.map +1 -1
- package/utilities/index.js +2 -0
- package/utilities/index.js.map +1 -1
- package/utilities/observables/Concast.d.ts +5 -5
- package/utilities/observables/Concast.d.ts.map +1 -1
- package/utilities/observables/Concast.js +2 -2
- package/utilities/observables/Concast.js.map +1 -1
- package/utilities/observables/asyncMap.js.map +1 -1
- package/utilities/policies/pagination.d.ts +7 -7
- package/utilities/policies/pagination.d.ts.map +1 -1
- package/utilities/policies/pagination.js.map +1 -1
- package/utilities/types/IsStrictlyAny.d.ts +3 -3
- package/utilities/types/IsStrictlyAny.d.ts.map +1 -1
- package/utilities/utilities.cjs +271 -123
- package/utilities/utilities.cjs.map +1 -1
- package/utilities/utilities.cjs.native.js +271 -123
- package/version.js +1 -1
package/core/core.cjs.native.js
CHANGED
|
@@ -7,18 +7,100 @@ var tslib = require('tslib');
|
|
|
7
7
|
var core = require('../link/core');
|
|
8
8
|
var http = require('../link/http');
|
|
9
9
|
var equality = require('@wry/equality');
|
|
10
|
-
var cache = require('../cache');
|
|
11
10
|
var utilities = require('../utilities');
|
|
11
|
+
var cache = require('../cache');
|
|
12
12
|
var errors = require('../errors');
|
|
13
13
|
var graphql = require('graphql');
|
|
14
14
|
var utils = require('../link/utils');
|
|
15
15
|
var tsInvariant = require('ts-invariant');
|
|
16
16
|
var graphqlTag = require('graphql-tag');
|
|
17
17
|
|
|
18
|
-
var version = '3.8.0-alpha.
|
|
18
|
+
var version = '3.8.0-alpha.10';
|
|
19
|
+
|
|
20
|
+
function isNonEmptyArray(value) {
|
|
21
|
+
return Array.isArray(value) && value.length > 0;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
function isNonNullObject(obj) {
|
|
25
|
+
return obj !== null && typeof obj === 'object';
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
|
|
29
|
+
var defaultReconciler = function (target, source, property) {
|
|
30
|
+
return this.merge(target[property], source[property]);
|
|
31
|
+
};
|
|
32
|
+
var DeepMerger = (function () {
|
|
33
|
+
function DeepMerger(reconciler) {
|
|
34
|
+
if (reconciler === void 0) { reconciler = defaultReconciler; }
|
|
35
|
+
this.reconciler = reconciler;
|
|
36
|
+
this.isObject = isNonNullObject;
|
|
37
|
+
this.pastCopies = new Set();
|
|
38
|
+
}
|
|
39
|
+
DeepMerger.prototype.merge = function (target, source) {
|
|
40
|
+
var _this = this;
|
|
41
|
+
var context = [];
|
|
42
|
+
for (var _i = 2; _i < arguments.length; _i++) {
|
|
43
|
+
context[_i - 2] = arguments[_i];
|
|
44
|
+
}
|
|
45
|
+
if (isNonNullObject(source) && isNonNullObject(target)) {
|
|
46
|
+
Object.keys(source).forEach(function (sourceKey) {
|
|
47
|
+
if (hasOwnProperty$2.call(target, sourceKey)) {
|
|
48
|
+
var targetValue = target[sourceKey];
|
|
49
|
+
if (source[sourceKey] !== targetValue) {
|
|
50
|
+
var result = _this.reconciler.apply(_this, tslib.__spreadArray([target, source, sourceKey], context, false));
|
|
51
|
+
if (result !== targetValue) {
|
|
52
|
+
target = _this.shallowCopyForMerge(target);
|
|
53
|
+
target[sourceKey] = result;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
target = _this.shallowCopyForMerge(target);
|
|
59
|
+
target[sourceKey] = source[sourceKey];
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
return target;
|
|
63
|
+
}
|
|
64
|
+
return source;
|
|
65
|
+
};
|
|
66
|
+
DeepMerger.prototype.shallowCopyForMerge = function (value) {
|
|
67
|
+
if (isNonNullObject(value)) {
|
|
68
|
+
if (!this.pastCopies.has(value)) {
|
|
69
|
+
if (Array.isArray(value)) {
|
|
70
|
+
value = value.slice(0);
|
|
71
|
+
}
|
|
72
|
+
else {
|
|
73
|
+
value = tslib.__assign({ __proto__: Object.getPrototypeOf(value) }, value);
|
|
74
|
+
}
|
|
75
|
+
this.pastCopies.add(value);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
return value;
|
|
79
|
+
};
|
|
80
|
+
return DeepMerger;
|
|
81
|
+
}());
|
|
19
82
|
|
|
20
83
|
function isExecutionPatchIncrementalResult(value) {
|
|
21
|
-
return
|
|
84
|
+
return "incremental" in value;
|
|
85
|
+
}
|
|
86
|
+
function mergeIncrementalData(prevResult, result) {
|
|
87
|
+
var mergedData = prevResult;
|
|
88
|
+
var merger = new DeepMerger();
|
|
89
|
+
if (isExecutionPatchIncrementalResult(result) &&
|
|
90
|
+
isNonEmptyArray(result.incremental)) {
|
|
91
|
+
result.incremental.forEach(function (_a) {
|
|
92
|
+
var data = _a.data, path = _a.path;
|
|
93
|
+
for (var i = path.length - 1; i >= 0; --i) {
|
|
94
|
+
var key = path[i];
|
|
95
|
+
var isNumericKey = !isNaN(+key);
|
|
96
|
+
var parent_1 = isNumericKey ? [] : {};
|
|
97
|
+
parent_1[key] = data;
|
|
98
|
+
data = parent_1;
|
|
99
|
+
}
|
|
100
|
+
mergedData = merger.merge(mergedData, data);
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
return mergedData;
|
|
22
104
|
}
|
|
23
105
|
|
|
24
106
|
exports.NetworkStatus = void 0;
|
|
@@ -146,7 +228,7 @@ var ObservableQuery = (function (_super) {
|
|
|
146
228
|
else {
|
|
147
229
|
result.partial = true;
|
|
148
230
|
}
|
|
149
|
-
if (__DEV__ &&
|
|
231
|
+
if (globals.__DEV__ &&
|
|
150
232
|
!diff.complete &&
|
|
151
233
|
!this.options.partialRefetch &&
|
|
152
234
|
!result.loading &&
|
|
@@ -201,11 +283,11 @@ var ObservableQuery = (function (_super) {
|
|
|
201
283
|
else {
|
|
202
284
|
reobserveOptions.fetchPolicy = 'network-only';
|
|
203
285
|
}
|
|
204
|
-
if (__DEV__ && variables && hasOwnProperty$1.call(variables, "variables")) {
|
|
286
|
+
if (globals.__DEV__ && variables && hasOwnProperty$1.call(variables, "variables")) {
|
|
205
287
|
var queryDef = utilities.getQueryDefinition(this.query);
|
|
206
288
|
var vars = queryDef.variableDefinitions;
|
|
207
289
|
if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
|
|
208
|
-
__DEV__ && globals.invariant.warn("Called refetch(".concat(JSON.stringify(variables), ") for query ").concat(((_a = queryDef.name) === null || _a === void 0 ? void 0 : _a.value) || JSON.stringify(queryDef), ", which does not declare a $variables variable.\nDid you mean to call refetch(variables) instead of refetch({ variables })?"));
|
|
290
|
+
globals.__DEV__ && globals.invariant.warn("Called refetch(".concat(JSON.stringify(variables), ") for query ").concat(((_a = queryDef.name) === null || _a === void 0 ? void 0 : _a.value) || JSON.stringify(queryDef), ", which does not declare a $variables variable.\nDid you mean to call refetch(variables) instead of refetch({ variables })?"));
|
|
209
291
|
}
|
|
210
292
|
}
|
|
211
293
|
if (variables && !equality.equal(this.options.variables, variables)) {
|
|
@@ -289,7 +371,7 @@ var ObservableQuery = (function (_super) {
|
|
|
289
371
|
options.onError(err);
|
|
290
372
|
return;
|
|
291
373
|
}
|
|
292
|
-
__DEV__ && globals.invariant.error('Unhandled GraphQL subscription error', err);
|
|
374
|
+
globals.__DEV__ && globals.invariant.error('Unhandled GraphQL subscription error', err);
|
|
293
375
|
},
|
|
294
376
|
});
|
|
295
377
|
this.subscriptions.add(subscription);
|
|
@@ -387,7 +469,7 @@ var ObservableQuery = (function (_super) {
|
|
|
387
469
|
pollingInfo.interval === pollInterval) {
|
|
388
470
|
return;
|
|
389
471
|
}
|
|
390
|
-
__DEV__ ? globals.invariant(pollInterval, 'Attempted to start a polling query without a polling interval.') : globals.invariant(pollInterval,
|
|
472
|
+
globals.__DEV__ ? globals.invariant(pollInterval, 'Attempted to start a polling query without a polling interval.') : globals.invariant(pollInterval, 13);
|
|
391
473
|
var info = pollingInfo || (this.pollingInfo = {});
|
|
392
474
|
info.interval = pollInterval;
|
|
393
475
|
var maybeFetch = function () {
|
|
@@ -421,7 +503,7 @@ var ObservableQuery = (function (_super) {
|
|
|
421
503
|
}
|
|
422
504
|
return this.last;
|
|
423
505
|
};
|
|
424
|
-
ObservableQuery.prototype.
|
|
506
|
+
ObservableQuery.prototype.reobserveAsConcast = function (newOptions, newNetworkStatus) {
|
|
425
507
|
var _this = this;
|
|
426
508
|
this.isTornDown = false;
|
|
427
509
|
var useDisposableConcast = newNetworkStatus === exports.NetworkStatus.refetch ||
|
|
@@ -464,7 +546,10 @@ var ObservableQuery = (function (_super) {
|
|
|
464
546
|
this.observer = observer;
|
|
465
547
|
}
|
|
466
548
|
concast.addObserver(observer);
|
|
467
|
-
return concast
|
|
549
|
+
return concast;
|
|
550
|
+
};
|
|
551
|
+
ObservableQuery.prototype.reobserve = function (newOptions, newNetworkStatus) {
|
|
552
|
+
return this.reobserveAsConcast(newOptions, newNetworkStatus).promise;
|
|
468
553
|
};
|
|
469
554
|
ObservableQuery.prototype.observe = function () {
|
|
470
555
|
this.reportResult(this.getCurrentResult(false), this.variables);
|
|
@@ -522,17 +607,18 @@ function reobserveCacheFirst(obsQuery) {
|
|
|
522
607
|
return obsQuery.reobserve();
|
|
523
608
|
}
|
|
524
609
|
function defaultSubscriptionObserverErrorCallback(error) {
|
|
525
|
-
__DEV__ && globals.invariant.error('Unhandled error', error.message, error.stack);
|
|
610
|
+
globals.__DEV__ && globals.invariant.error('Unhandled error', error.message, error.stack);
|
|
526
611
|
}
|
|
527
612
|
function logMissingFieldErrors(missing) {
|
|
528
|
-
if (__DEV__ && missing) {
|
|
529
|
-
__DEV__ && globals.invariant.debug("Missing cache result fields: ".concat(JSON.stringify(missing)), missing);
|
|
613
|
+
if (globals.__DEV__ && missing) {
|
|
614
|
+
globals.__DEV__ && globals.invariant.debug("Missing cache result fields: ".concat(JSON.stringify(missing)), missing);
|
|
530
615
|
}
|
|
531
616
|
}
|
|
532
617
|
|
|
533
618
|
var LocalState = (function () {
|
|
534
619
|
function LocalState(_a) {
|
|
535
620
|
var cache = _a.cache, client = _a.client, resolvers = _a.resolvers, fragmentMatcher = _a.fragmentMatcher;
|
|
621
|
+
this.selectionsToResolveCache = new WeakMap();
|
|
536
622
|
this.cache = cache;
|
|
537
623
|
if (client) {
|
|
538
624
|
this.client = client;
|
|
@@ -588,8 +674,12 @@ var LocalState = (function () {
|
|
|
588
674
|
}
|
|
589
675
|
return null;
|
|
590
676
|
};
|
|
591
|
-
LocalState.prototype.serverQuery = function (document) {
|
|
592
|
-
|
|
677
|
+
LocalState.prototype.serverQuery = function (document, options) {
|
|
678
|
+
if (options === void 0) { options = Object.create(null); }
|
|
679
|
+
var _a = options.removeClientFields, removeClientFields = _a === void 0 ? true : _a;
|
|
680
|
+
return removeClientFields
|
|
681
|
+
? utilities.removeClientSetsFromDocument(document)
|
|
682
|
+
: document;
|
|
593
683
|
};
|
|
594
684
|
LocalState.prototype.prepareContext = function (context) {
|
|
595
685
|
var cache = this.cache;
|
|
@@ -643,13 +733,13 @@ var LocalState = (function () {
|
|
|
643
733
|
if (fragmentMatcher === void 0) { fragmentMatcher = function () { return true; }; }
|
|
644
734
|
if (onlyRunForcedResolvers === void 0) { onlyRunForcedResolvers = false; }
|
|
645
735
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
646
|
-
var mainDefinition, fragments, fragmentMap, definitionOperation, defaultOperationType, _a, cache, client, execContext;
|
|
736
|
+
var mainDefinition, fragments, fragmentMap, selectionsToResolve, definitionOperation, defaultOperationType, _a, cache, client, execContext, isClientFieldDescendant;
|
|
647
737
|
return tslib.__generator(this, function (_b) {
|
|
648
738
|
mainDefinition = utilities.getMainDefinition(document);
|
|
649
739
|
fragments = utilities.getFragmentDefinitions(document);
|
|
650
740
|
fragmentMap = utilities.createFragmentMap(fragments);
|
|
651
|
-
|
|
652
|
-
|
|
741
|
+
selectionsToResolve = this.collectSelectionsToResolve(mainDefinition, fragmentMap);
|
|
742
|
+
definitionOperation = mainDefinition.operation;
|
|
653
743
|
defaultOperationType = definitionOperation
|
|
654
744
|
? definitionOperation.charAt(0).toUpperCase() +
|
|
655
745
|
definitionOperation.slice(1)
|
|
@@ -662,16 +752,18 @@ var LocalState = (function () {
|
|
|
662
752
|
fragmentMatcher: fragmentMatcher,
|
|
663
753
|
defaultOperationType: defaultOperationType,
|
|
664
754
|
exportedVariables: {},
|
|
755
|
+
selectionsToResolve: selectionsToResolve,
|
|
665
756
|
onlyRunForcedResolvers: onlyRunForcedResolvers,
|
|
666
757
|
};
|
|
667
|
-
|
|
758
|
+
isClientFieldDescendant = false;
|
|
759
|
+
return [2, this.resolveSelectionSet(mainDefinition.selectionSet, isClientFieldDescendant, rootValue, execContext).then(function (result) { return ({
|
|
668
760
|
result: result,
|
|
669
761
|
exportedVariables: execContext.exportedVariables,
|
|
670
762
|
}); })];
|
|
671
763
|
});
|
|
672
764
|
});
|
|
673
765
|
};
|
|
674
|
-
LocalState.prototype.resolveSelectionSet = function (selectionSet, rootValue, execContext) {
|
|
766
|
+
LocalState.prototype.resolveSelectionSet = function (selectionSet, isClientFieldDescendant, rootValue, execContext) {
|
|
675
767
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
676
768
|
var fragmentMap, context, variables, resultsToMerge, execute;
|
|
677
769
|
var _this = this;
|
|
@@ -681,11 +773,14 @@ var LocalState = (function () {
|
|
|
681
773
|
execute = function (selection) { return tslib.__awaiter(_this, void 0, void 0, function () {
|
|
682
774
|
var fragment, typeCondition;
|
|
683
775
|
return tslib.__generator(this, function (_a) {
|
|
776
|
+
if (!isClientFieldDescendant && !execContext.selectionsToResolve.has(selection)) {
|
|
777
|
+
return [2];
|
|
778
|
+
}
|
|
684
779
|
if (!utilities.shouldInclude(selection, variables)) {
|
|
685
780
|
return [2];
|
|
686
781
|
}
|
|
687
782
|
if (utilities.isField(selection)) {
|
|
688
|
-
return [2, this.resolveField(selection, rootValue, execContext).then(function (fieldResult) {
|
|
783
|
+
return [2, this.resolveField(selection, isClientFieldDescendant, rootValue, execContext).then(function (fieldResult) {
|
|
689
784
|
var _a;
|
|
690
785
|
if (typeof fieldResult !== 'undefined') {
|
|
691
786
|
resultsToMerge.push((_a = {},
|
|
@@ -699,12 +794,12 @@ var LocalState = (function () {
|
|
|
699
794
|
}
|
|
700
795
|
else {
|
|
701
796
|
fragment = fragmentMap[selection.name.value];
|
|
702
|
-
__DEV__ ? globals.invariant(fragment, "No fragment named ".concat(selection.name.value)) : globals.invariant(fragment, 11);
|
|
797
|
+
globals.__DEV__ ? globals.invariant(fragment, "No fragment named ".concat(selection.name.value)) : globals.invariant(fragment, 11);
|
|
703
798
|
}
|
|
704
799
|
if (fragment && fragment.typeCondition) {
|
|
705
800
|
typeCondition = fragment.typeCondition.name.value;
|
|
706
801
|
if (execContext.fragmentMatcher(rootValue, typeCondition, context)) {
|
|
707
|
-
return [2, this.resolveSelectionSet(fragment.selectionSet, rootValue, execContext).then(function (fragmentResult) {
|
|
802
|
+
return [2, this.resolveSelectionSet(fragment.selectionSet, isClientFieldDescendant, rootValue, execContext).then(function (fragmentResult) {
|
|
708
803
|
resultsToMerge.push(fragmentResult);
|
|
709
804
|
})];
|
|
710
805
|
}
|
|
@@ -718,11 +813,14 @@ var LocalState = (function () {
|
|
|
718
813
|
});
|
|
719
814
|
});
|
|
720
815
|
};
|
|
721
|
-
LocalState.prototype.resolveField = function (field, rootValue, execContext) {
|
|
816
|
+
LocalState.prototype.resolveField = function (field, isClientFieldDescendant, rootValue, execContext) {
|
|
722
817
|
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
723
818
|
var variables, fieldName, aliasedFieldName, aliasUsed, defaultResult, resultPromise, resolverType, resolverMap, resolve;
|
|
724
819
|
var _this = this;
|
|
725
820
|
return tslib.__generator(this, function (_a) {
|
|
821
|
+
if (!rootValue) {
|
|
822
|
+
return [2, null];
|
|
823
|
+
}
|
|
726
824
|
variables = execContext.variables;
|
|
727
825
|
fieldName = field.name.value;
|
|
728
826
|
aliasedFieldName = utilities.resultKeyNameFromField(field);
|
|
@@ -746,6 +844,7 @@ var LocalState = (function () {
|
|
|
746
844
|
}
|
|
747
845
|
}
|
|
748
846
|
return [2, resultPromise.then(function (result) {
|
|
847
|
+
var _a, _b;
|
|
749
848
|
if (result === void 0) { result = defaultResult; }
|
|
750
849
|
if (field.directives) {
|
|
751
850
|
field.directives.forEach(function (directive) {
|
|
@@ -764,30 +863,70 @@ var LocalState = (function () {
|
|
|
764
863
|
if (result == null) {
|
|
765
864
|
return result;
|
|
766
865
|
}
|
|
866
|
+
var isClientField = (_b = (_a = field.directives) === null || _a === void 0 ? void 0 : _a.some(function (d) { return d.name.value === 'client'; })) !== null && _b !== void 0 ? _b : false;
|
|
767
867
|
if (Array.isArray(result)) {
|
|
768
|
-
return _this.resolveSubSelectedArray(field, result, execContext);
|
|
868
|
+
return _this.resolveSubSelectedArray(field, isClientFieldDescendant || isClientField, result, execContext);
|
|
769
869
|
}
|
|
770
870
|
if (field.selectionSet) {
|
|
771
|
-
return _this.resolveSelectionSet(field.selectionSet, result, execContext);
|
|
871
|
+
return _this.resolveSelectionSet(field.selectionSet, isClientFieldDescendant || isClientField, result, execContext);
|
|
772
872
|
}
|
|
773
873
|
})];
|
|
774
874
|
});
|
|
775
875
|
});
|
|
776
876
|
};
|
|
777
|
-
LocalState.prototype.resolveSubSelectedArray = function (field, result, execContext) {
|
|
877
|
+
LocalState.prototype.resolveSubSelectedArray = function (field, isClientFieldDescendant, result, execContext) {
|
|
778
878
|
var _this = this;
|
|
779
879
|
return Promise.all(result.map(function (item) {
|
|
780
880
|
if (item === null) {
|
|
781
881
|
return null;
|
|
782
882
|
}
|
|
783
883
|
if (Array.isArray(item)) {
|
|
784
|
-
return _this.resolveSubSelectedArray(field, item, execContext);
|
|
884
|
+
return _this.resolveSubSelectedArray(field, isClientFieldDescendant, item, execContext);
|
|
785
885
|
}
|
|
786
886
|
if (field.selectionSet) {
|
|
787
|
-
return _this.resolveSelectionSet(field.selectionSet, item, execContext);
|
|
887
|
+
return _this.resolveSelectionSet(field.selectionSet, isClientFieldDescendant, item, execContext);
|
|
788
888
|
}
|
|
789
889
|
}));
|
|
790
890
|
};
|
|
891
|
+
LocalState.prototype.collectSelectionsToResolve = function (mainDefinition, fragmentMap) {
|
|
892
|
+
var isSingleASTNode = function (node) { return !Array.isArray(node); };
|
|
893
|
+
var selectionsToResolveCache = this.selectionsToResolveCache;
|
|
894
|
+
function collectByDefinition(definitionNode) {
|
|
895
|
+
if (!selectionsToResolveCache.has(definitionNode)) {
|
|
896
|
+
var matches_1 = new Set();
|
|
897
|
+
selectionsToResolveCache.set(definitionNode, matches_1);
|
|
898
|
+
graphql.visit(definitionNode, {
|
|
899
|
+
Directive: function (node, _, __, ___, ancestors) {
|
|
900
|
+
if (node.name.value === 'client') {
|
|
901
|
+
ancestors.forEach(function (node) {
|
|
902
|
+
if (isSingleASTNode(node) && graphql.isSelectionNode(node)) {
|
|
903
|
+
matches_1.add(node);
|
|
904
|
+
}
|
|
905
|
+
});
|
|
906
|
+
}
|
|
907
|
+
},
|
|
908
|
+
FragmentSpread: function (spread, _, __, ___, ancestors) {
|
|
909
|
+
var fragment = fragmentMap[spread.name.value];
|
|
910
|
+
globals.__DEV__ ? globals.invariant(fragment, "No fragment named ".concat(spread.name.value)) : globals.invariant(fragment, 12);
|
|
911
|
+
var fragmentSelections = collectByDefinition(fragment);
|
|
912
|
+
if (fragmentSelections.size > 0) {
|
|
913
|
+
ancestors.forEach(function (node) {
|
|
914
|
+
if (isSingleASTNode(node) && graphql.isSelectionNode(node)) {
|
|
915
|
+
matches_1.add(node);
|
|
916
|
+
}
|
|
917
|
+
});
|
|
918
|
+
matches_1.add(spread);
|
|
919
|
+
fragmentSelections.forEach(function (selection) {
|
|
920
|
+
matches_1.add(selection);
|
|
921
|
+
});
|
|
922
|
+
}
|
|
923
|
+
}
|
|
924
|
+
});
|
|
925
|
+
}
|
|
926
|
+
return selectionsToResolveCache.get(definitionNode);
|
|
927
|
+
}
|
|
928
|
+
return collectByDefinition(mainDefinition);
|
|
929
|
+
};
|
|
791
930
|
return LocalState;
|
|
792
931
|
}());
|
|
793
932
|
|
|
@@ -990,22 +1129,8 @@ var QueryInfo = (function () {
|
|
|
990
1129
|
: [];
|
|
991
1130
|
this.reset();
|
|
992
1131
|
if ('incremental' in result && utilities.isNonEmptyArray(result.incremental)) {
|
|
993
|
-
var
|
|
994
|
-
result.
|
|
995
|
-
var data = _a.data, path = _a.path, errors = _a.errors;
|
|
996
|
-
for (var i = path.length - 1; i >= 0; --i) {
|
|
997
|
-
var key = path[i];
|
|
998
|
-
var isNumericKey = !isNaN(+key);
|
|
999
|
-
var parent_1 = isNumericKey ? [] : {};
|
|
1000
|
-
parent_1[key] = data;
|
|
1001
|
-
data = parent_1;
|
|
1002
|
-
}
|
|
1003
|
-
if (errors) {
|
|
1004
|
-
graphQLErrors.push.apply(graphQLErrors, errors);
|
|
1005
|
-
}
|
|
1006
|
-
mergedData_1 = merger.merge(mergedData_1, data);
|
|
1007
|
-
});
|
|
1008
|
-
result.data = mergedData_1;
|
|
1132
|
+
var mergedData = utilities.mergeIncrementalData(this.getDiff().result, result);
|
|
1133
|
+
result.data = mergedData;
|
|
1009
1134
|
}
|
|
1010
1135
|
else if ('hasNext' in result && result.hasNext) {
|
|
1011
1136
|
var diff = this.getDiff();
|
|
@@ -1112,7 +1237,7 @@ var QueryManager = (function () {
|
|
|
1112
1237
|
this.queries.forEach(function (_info, queryId) {
|
|
1113
1238
|
_this.stopQueryNoBroadcast(queryId);
|
|
1114
1239
|
});
|
|
1115
|
-
this.cancelPendingFetches(__DEV__ ? new globals.InvariantError('QueryManager stopped while query was in flight') : new globals.InvariantError(
|
|
1240
|
+
this.cancelPendingFetches(globals.__DEV__ ? new globals.InvariantError('QueryManager stopped while query was in flight') : new globals.InvariantError(14));
|
|
1116
1241
|
};
|
|
1117
1242
|
QueryManager.prototype.cancelPendingFetches = function (error) {
|
|
1118
1243
|
this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
|
|
@@ -1126,10 +1251,10 @@ var QueryManager = (function () {
|
|
|
1126
1251
|
return tslib.__generator(this, function (_j) {
|
|
1127
1252
|
switch (_j.label) {
|
|
1128
1253
|
case 0:
|
|
1129
|
-
__DEV__ ? globals.invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.') : globals.invariant(mutation,
|
|
1130
|
-
__DEV__ ? globals.invariant(fetchPolicy === 'network-only' ||
|
|
1254
|
+
globals.__DEV__ ? globals.invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.') : globals.invariant(mutation, 15);
|
|
1255
|
+
globals.__DEV__ ? globals.invariant(fetchPolicy === 'network-only' ||
|
|
1131
1256
|
fetchPolicy === 'no-cache', "Mutations support only 'network-only' or 'no-cache' fetchPolicy strings. The default `network-only` behavior automatically writes mutation results to the cache. Passing `no-cache` skips the cache write.") : globals.invariant(fetchPolicy === 'network-only' ||
|
|
1132
|
-
fetchPolicy === 'no-cache',
|
|
1257
|
+
fetchPolicy === 'no-cache', 16);
|
|
1133
1258
|
mutationId = this.generateMutationId();
|
|
1134
1259
|
_h = this.transform(mutation), document = _h.document, hasClientExports = _h.hasClientExports;
|
|
1135
1260
|
mutation = this.cache.transformForLink(document);
|
|
@@ -1166,7 +1291,7 @@ var QueryManager = (function () {
|
|
|
1166
1291
|
return utilities.asyncMap(self.getObservableFromLink(mutation, tslib.__assign(tslib.__assign({}, context), { optimisticResponse: optimisticResponse }), variables, false), function (result) {
|
|
1167
1292
|
if (utilities.graphQLResultHasError(result) && errorPolicy === 'none') {
|
|
1168
1293
|
throw new errors.ApolloError({
|
|
1169
|
-
graphQLErrors: result
|
|
1294
|
+
graphQLErrors: utilities.getGraphQLErrorsFromResult(result),
|
|
1170
1295
|
});
|
|
1171
1296
|
}
|
|
1172
1297
|
if (mutationStoreValue) {
|
|
@@ -1200,7 +1325,9 @@ var QueryManager = (function () {
|
|
|
1200
1325
|
}).subscribe({
|
|
1201
1326
|
next: function (storeResult) {
|
|
1202
1327
|
self.broadcastQueries();
|
|
1203
|
-
|
|
1328
|
+
if (!('hasNext' in storeResult) || storeResult.hasNext === false) {
|
|
1329
|
+
resolve(storeResult);
|
|
1330
|
+
}
|
|
1204
1331
|
},
|
|
1205
1332
|
error: function (err) {
|
|
1206
1333
|
if (mutationStoreValue) {
|
|
@@ -1228,12 +1355,36 @@ var QueryManager = (function () {
|
|
|
1228
1355
|
var cacheWrites = [];
|
|
1229
1356
|
var skipCache = mutation.fetchPolicy === "no-cache";
|
|
1230
1357
|
if (!skipCache && shouldWriteResult(result, mutation.errorPolicy)) {
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1358
|
+
if (!utilities.isExecutionPatchIncrementalResult(result)) {
|
|
1359
|
+
cacheWrites.push({
|
|
1360
|
+
result: result.data,
|
|
1361
|
+
dataId: 'ROOT_MUTATION',
|
|
1362
|
+
query: mutation.document,
|
|
1363
|
+
variables: mutation.variables,
|
|
1364
|
+
});
|
|
1365
|
+
}
|
|
1366
|
+
if (utilities.isExecutionPatchIncrementalResult(result) && utilities.isNonEmptyArray(result.incremental)) {
|
|
1367
|
+
var diff = cache.diff({
|
|
1368
|
+
id: "ROOT_MUTATION",
|
|
1369
|
+
query: this.transform(mutation.document).asQuery,
|
|
1370
|
+
variables: mutation.variables,
|
|
1371
|
+
optimistic: false,
|
|
1372
|
+
returnPartialData: true,
|
|
1373
|
+
});
|
|
1374
|
+
var mergedData = void 0;
|
|
1375
|
+
if (diff.result) {
|
|
1376
|
+
mergedData = mergeIncrementalData(diff.result, result);
|
|
1377
|
+
}
|
|
1378
|
+
if (typeof mergedData !== 'undefined') {
|
|
1379
|
+
result.data = mergedData;
|
|
1380
|
+
cacheWrites.push({
|
|
1381
|
+
result: mergedData,
|
|
1382
|
+
dataId: 'ROOT_MUTATION',
|
|
1383
|
+
query: mutation.document,
|
|
1384
|
+
variables: mutation.variables,
|
|
1385
|
+
});
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1237
1388
|
var updateQueries_1 = mutation.updateQueries;
|
|
1238
1389
|
if (updateQueries_1) {
|
|
1239
1390
|
this.queries.forEach(function (_a, queryId) {
|
|
@@ -1280,6 +1431,8 @@ var QueryManager = (function () {
|
|
|
1280
1431
|
cacheWrites.forEach(function (write) { return cache.write(write); });
|
|
1281
1432
|
}
|
|
1282
1433
|
var update = mutation.update;
|
|
1434
|
+
var isFinalResult = !utilities.isExecutionPatchResult(result) ||
|
|
1435
|
+
(utilities.isExecutionPatchIncrementalResult(result) && !result.hasNext);
|
|
1283
1436
|
if (update) {
|
|
1284
1437
|
if (!skipCache) {
|
|
1285
1438
|
var diff = cache.diff({
|
|
@@ -1289,16 +1442,24 @@ var QueryManager = (function () {
|
|
|
1289
1442
|
optimistic: false,
|
|
1290
1443
|
returnPartialData: true,
|
|
1291
1444
|
});
|
|
1292
|
-
if (diff.complete
|
|
1445
|
+
if (diff.complete) {
|
|
1293
1446
|
result = tslib.__assign(tslib.__assign({}, result), { data: diff.result });
|
|
1447
|
+
if ('incremental' in result) {
|
|
1448
|
+
delete result.incremental;
|
|
1449
|
+
}
|
|
1450
|
+
if ('hasNext' in result) {
|
|
1451
|
+
delete result.hasNext;
|
|
1452
|
+
}
|
|
1294
1453
|
}
|
|
1295
1454
|
}
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1455
|
+
if (isFinalResult) {
|
|
1456
|
+
update(cache, result, {
|
|
1457
|
+
context: mutation.context,
|
|
1458
|
+
variables: mutation.variables,
|
|
1459
|
+
});
|
|
1460
|
+
}
|
|
1300
1461
|
}
|
|
1301
|
-
if (!skipCache && !mutation.keepRootFields) {
|
|
1462
|
+
if (!skipCache && !mutation.keepRootFields && isFinalResult) {
|
|
1302
1463
|
cache.modify({
|
|
1303
1464
|
id: 'ROOT_MUTATION',
|
|
1304
1465
|
fields: function (value, _a) {
|
|
@@ -1329,7 +1490,7 @@ var QueryManager = (function () {
|
|
|
1329
1490
|
_this.markMutationResult(tslib.__assign(tslib.__assign({}, mutation), { result: { data: data } }), cache);
|
|
1330
1491
|
}
|
|
1331
1492
|
catch (error) {
|
|
1332
|
-
__DEV__ && globals.invariant.error(error);
|
|
1493
|
+
globals.__DEV__ && globals.invariant.error(error);
|
|
1333
1494
|
}
|
|
1334
1495
|
}, mutation.mutationId);
|
|
1335
1496
|
};
|
|
@@ -1357,11 +1518,13 @@ var QueryManager = (function () {
|
|
|
1357
1518
|
};
|
|
1358
1519
|
QueryManager.prototype.transform = function (document) {
|
|
1359
1520
|
var transformCache = this.transformCache;
|
|
1521
|
+
var _a = (this.defaultOptions.transformQuery || Object.create(null)).removeClientFields, removeClientFields = _a === void 0 ? true : _a;
|
|
1360
1522
|
if (!transformCache.has(document)) {
|
|
1361
1523
|
var transformed = this.cache.transformDocument(document);
|
|
1362
1524
|
var noConnection = utilities.removeConnectionDirectiveFromDocument(transformed);
|
|
1363
1525
|
var clientQuery = this.localState.clientQuery(transformed);
|
|
1364
|
-
var serverQuery = noConnection &&
|
|
1526
|
+
var serverQuery = noConnection &&
|
|
1527
|
+
this.localState.serverQuery(noConnection, { removeClientFields: removeClientFields });
|
|
1365
1528
|
var cacheEntry_1 = {
|
|
1366
1529
|
document: transformed,
|
|
1367
1530
|
hasClientExports: utilities.hasClientExports(transformed),
|
|
@@ -1414,11 +1577,11 @@ var QueryManager = (function () {
|
|
|
1414
1577
|
QueryManager.prototype.query = function (options, queryId) {
|
|
1415
1578
|
var _this = this;
|
|
1416
1579
|
if (queryId === void 0) { queryId = this.generateQueryId(); }
|
|
1417
|
-
__DEV__ ? globals.invariant(options.query, 'query option is required. You must specify your GraphQL document ' +
|
|
1418
|
-
'in the query option.') : globals.invariant(options.query,
|
|
1419
|
-
__DEV__ ? globals.invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.') : globals.invariant(options.query.kind === 'Document',
|
|
1420
|
-
__DEV__ ? globals.invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.') : globals.invariant(!options.returnPartialData,
|
|
1421
|
-
__DEV__ ? globals.invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.') : globals.invariant(!options.pollInterval,
|
|
1580
|
+
globals.__DEV__ ? globals.invariant(options.query, 'query option is required. You must specify your GraphQL document ' +
|
|
1581
|
+
'in the query option.') : globals.invariant(options.query, 17);
|
|
1582
|
+
globals.__DEV__ ? globals.invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.') : globals.invariant(options.query.kind === 'Document', 18);
|
|
1583
|
+
globals.__DEV__ ? globals.invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.') : globals.invariant(!options.returnPartialData, 19);
|
|
1584
|
+
globals.__DEV__ ? globals.invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.') : globals.invariant(!options.pollInterval, 20);
|
|
1422
1585
|
return this.fetchQuery(queryId, options).finally(function () { return _this.stopQuery(queryId); });
|
|
1423
1586
|
};
|
|
1424
1587
|
QueryManager.prototype.generateQueryId = function () {
|
|
@@ -1443,7 +1606,7 @@ var QueryManager = (function () {
|
|
|
1443
1606
|
if (options === void 0) { options = {
|
|
1444
1607
|
discardWatches: true,
|
|
1445
1608
|
}; }
|
|
1446
|
-
this.cancelPendingFetches(__DEV__ ? new globals.InvariantError('Store reset while query was in flight (not completed in link chain)') : new globals.InvariantError(
|
|
1609
|
+
this.cancelPendingFetches(globals.__DEV__ ? new globals.InvariantError('Store reset while query was in flight (not completed in link chain)') : new globals.InvariantError(21));
|
|
1447
1610
|
this.queries.forEach(function (queryInfo) {
|
|
1448
1611
|
if (queryInfo.observableQuery) {
|
|
1449
1612
|
queryInfo.networkStatus = exports.NetworkStatus.loading;
|
|
@@ -1516,10 +1679,10 @@ var QueryManager = (function () {
|
|
|
1516
1679
|
queries.set(queryId, oq);
|
|
1517
1680
|
});
|
|
1518
1681
|
}
|
|
1519
|
-
if (__DEV__ && queryNamesAndDocs.size) {
|
|
1682
|
+
if (globals.__DEV__ && queryNamesAndDocs.size) {
|
|
1520
1683
|
queryNamesAndDocs.forEach(function (included, nameOrDoc) {
|
|
1521
1684
|
if (!included) {
|
|
1522
|
-
__DEV__ && globals.invariant.warn("Unknown query ".concat(typeof nameOrDoc === "string" ? "named " : "").concat(JSON.stringify(nameOrDoc, null, 2), " requested in refetchQueries options.include array"));
|
|
1685
|
+
globals.__DEV__ && globals.invariant.warn("Unknown query ".concat(typeof nameOrDoc === "string" ? "named " : "").concat(JSON.stringify(nameOrDoc, null, 2), " requested in refetchQueries options.include array"));
|
|
1523
1686
|
}
|
|
1524
1687
|
});
|
|
1525
1688
|
}
|
|
@@ -1666,17 +1829,8 @@ var QueryManager = (function () {
|
|
|
1666
1829
|
var requestId = queryInfo.lastRequestId = this.generateRequestId();
|
|
1667
1830
|
var linkDocument = this.cache.transformForLink(this.transform(queryInfo.document).document);
|
|
1668
1831
|
return utilities.asyncMap(this.getObservableFromLink(linkDocument, options.context, options.variables), function (result) {
|
|
1669
|
-
var graphQLErrors = utilities.
|
|
1670
|
-
|
|
1671
|
-
: [];
|
|
1672
|
-
if ('incremental' in result && utilities.isNonEmptyArray(result.incremental)) {
|
|
1673
|
-
result.incremental.forEach(function (incrementalResult) {
|
|
1674
|
-
if (incrementalResult.errors) {
|
|
1675
|
-
graphQLErrors.push.apply(graphQLErrors, incrementalResult.errors);
|
|
1676
|
-
}
|
|
1677
|
-
});
|
|
1678
|
-
}
|
|
1679
|
-
var hasErrors = utilities.isNonEmptyArray(graphQLErrors);
|
|
1832
|
+
var graphQLErrors = utilities.getGraphQLErrorsFromResult(result);
|
|
1833
|
+
var hasErrors = graphQLErrors.length > 0;
|
|
1680
1834
|
if (requestId >= queryInfo.lastRequestId) {
|
|
1681
1835
|
if (hasErrors && options.errorPolicy === "none") {
|
|
1682
1836
|
throw queryInfo.markError(new errors.ApolloError({
|
|
@@ -1825,7 +1979,7 @@ var QueryManager = (function () {
|
|
|
1825
1979
|
var resultsFromCache = function (diff, networkStatus) {
|
|
1826
1980
|
if (networkStatus === void 0) { networkStatus = queryInfo.networkStatus || exports.NetworkStatus.loading; }
|
|
1827
1981
|
var data = diff.result;
|
|
1828
|
-
if (__DEV__ &&
|
|
1982
|
+
if (globals.__DEV__ &&
|
|
1829
1983
|
!returnPartialData &&
|
|
1830
1984
|
!equality.equal(data, {})) {
|
|
1831
1985
|
logMissingFieldErrors(diff.missing);
|
|
@@ -1840,6 +1994,11 @@ var QueryManager = (function () {
|
|
|
1840
1994
|
onlyRunForcedResolvers: true,
|
|
1841
1995
|
}).then(function (resolved) { return fromData(resolved.data || void 0); });
|
|
1842
1996
|
}
|
|
1997
|
+
if (errorPolicy === 'none' &&
|
|
1998
|
+
networkStatus === exports.NetworkStatus.refetch &&
|
|
1999
|
+
Array.isArray(diff.missing)) {
|
|
2000
|
+
return fromData(void 0);
|
|
2001
|
+
}
|
|
1843
2002
|
return fromData(data);
|
|
1844
2003
|
};
|
|
1845
2004
|
var cacheWriteBehavior = fetchPolicy === "no-cache" ? 0 :
|
|
@@ -1933,7 +2092,7 @@ var ApolloClient = (function () {
|
|
|
1933
2092
|
this.clearStoreCallbacks = [];
|
|
1934
2093
|
var uri = options.uri, credentials = options.credentials, headers = options.headers, cache = options.cache, _a = options.ssrMode, ssrMode = _a === void 0 ? false : _a, _b = options.ssrForceFetchDelay, ssrForceFetchDelay = _b === void 0 ? 0 : _b, _c = options.connectToDevTools, connectToDevTools = _c === void 0 ? typeof window === 'object' &&
|
|
1935
2094
|
!window.__APOLLO_CLIENT__ &&
|
|
1936
|
-
__DEV__ : _c, _d = options.queryDeduplication, queryDeduplication = _d === void 0 ? true : _d, defaultOptions = options.defaultOptions, _e = options.assumeImmutableResults, assumeImmutableResults = _e === void 0 ? false : _e, resolvers = options.resolvers, typeDefs = options.typeDefs, fragmentMatcher = options.fragmentMatcher, clientAwarenessName = options.name, clientAwarenessVersion = options.version;
|
|
2095
|
+
globals.__DEV__ : _c, _d = options.queryDeduplication, queryDeduplication = _d === void 0 ? true : _d, defaultOptions = options.defaultOptions, _e = options.assumeImmutableResults, assumeImmutableResults = _e === void 0 ? false : _e, resolvers = options.resolvers, typeDefs = options.typeDefs, fragmentMatcher = options.fragmentMatcher, clientAwarenessName = options.name, clientAwarenessVersion = options.version;
|
|
1937
2096
|
var link = options.link;
|
|
1938
2097
|
if (!link) {
|
|
1939
2098
|
link = uri
|
|
@@ -1941,7 +2100,7 @@ var ApolloClient = (function () {
|
|
|
1941
2100
|
: core.ApolloLink.empty();
|
|
1942
2101
|
}
|
|
1943
2102
|
if (!cache) {
|
|
1944
|
-
throw __DEV__ ? new globals.InvariantError("To initialize Apollo Client, you must specify a 'cache' property " +
|
|
2103
|
+
throw globals.__DEV__ ? new globals.InvariantError("To initialize Apollo Client, you must specify a 'cache' property " +
|
|
1945
2104
|
"in the options object. \n" +
|
|
1946
2105
|
"For more information, please visit: https://go.apollo.dev/c/docs") : new globals.InvariantError(9);
|
|
1947
2106
|
}
|
|
@@ -1962,7 +2121,7 @@ var ApolloClient = (function () {
|
|
|
1962
2121
|
if (connectToDevTools && typeof window === 'object') {
|
|
1963
2122
|
window.__APOLLO_CLIENT__ = this;
|
|
1964
2123
|
}
|
|
1965
|
-
if (!hasSuggestedDevtools && connectToDevTools && __DEV__) {
|
|
2124
|
+
if (!hasSuggestedDevtools && connectToDevTools && globals.__DEV__) {
|
|
1966
2125
|
hasSuggestedDevtools = true;
|
|
1967
2126
|
if (typeof window !== 'undefined' &&
|
|
1968
2127
|
window.document &&
|
|
@@ -1981,7 +2140,7 @@ var ApolloClient = (function () {
|
|
|
1981
2140
|
}
|
|
1982
2141
|
}
|
|
1983
2142
|
if (url) {
|
|
1984
|
-
__DEV__ && globals.invariant.log("Download the Apollo DevTools for a better development " +
|
|
2143
|
+
globals.__DEV__ && globals.invariant.log("Download the Apollo DevTools for a better development " +
|
|
1985
2144
|
"experience: " + url);
|
|
1986
2145
|
}
|
|
1987
2146
|
}
|
|
@@ -2037,7 +2196,7 @@ var ApolloClient = (function () {
|
|
|
2037
2196
|
if (this.defaultOptions.query) {
|
|
2038
2197
|
options = utilities.mergeOptions(this.defaultOptions.query, options);
|
|
2039
2198
|
}
|
|
2040
|
-
__DEV__ ? globals.invariant(options.fetchPolicy !== 'cache-and-network', 'The cache-and-network fetchPolicy does not work with client.query, because ' +
|
|
2199
|
+
globals.__DEV__ ? globals.invariant(options.fetchPolicy !== 'cache-and-network', 'The cache-and-network fetchPolicy does not work with client.query, because ' +
|
|
2041
2200
|
'client.query can only return a single result. Please use client.watchQuery ' +
|
|
2042
2201
|
'to receive multiple results from the cache and the network, or consider ' +
|
|
2043
2202
|
'using a different fetchPolicy, such as cache-first or network-only.') : globals.invariant(options.fetchPolicy !== 'cache-and-network', 10);
|
|
@@ -2064,12 +2223,18 @@ var ApolloClient = (function () {
|
|
|
2064
2223
|
return this.cache.readFragment(options, optimistic);
|
|
2065
2224
|
};
|
|
2066
2225
|
ApolloClient.prototype.writeQuery = function (options) {
|
|
2067
|
-
this.cache.writeQuery(options);
|
|
2068
|
-
|
|
2226
|
+
var ref = this.cache.writeQuery(options);
|
|
2227
|
+
if (options.broadcast !== false) {
|
|
2228
|
+
this.queryManager.broadcastQueries();
|
|
2229
|
+
}
|
|
2230
|
+
return ref;
|
|
2069
2231
|
};
|
|
2070
2232
|
ApolloClient.prototype.writeFragment = function (options) {
|
|
2071
|
-
this.cache.writeFragment(options);
|
|
2072
|
-
|
|
2233
|
+
var ref = this.cache.writeFragment(options);
|
|
2234
|
+
if (options.broadcast !== false) {
|
|
2235
|
+
this.queryManager.broadcastQueries();
|
|
2236
|
+
}
|
|
2237
|
+
return ref;
|
|
2073
2238
|
};
|
|
2074
2239
|
ApolloClient.prototype.__actionHookForDevTools = function (cb) {
|
|
2075
2240
|
this.devToolsHookCb = cb;
|
|
@@ -2123,7 +2288,7 @@ var ApolloClient = (function () {
|
|
|
2123
2288
|
result.queries = queries;
|
|
2124
2289
|
result.results = results;
|
|
2125
2290
|
result.catch(function (error) {
|
|
2126
|
-
__DEV__ && globals.invariant.debug("In client.refetchQueries, Promise.all promise rejected with error ".concat(error));
|
|
2291
|
+
globals.__DEV__ && globals.invariant.debug("In client.refetchQueries, Promise.all promise rejected with error ".concat(error));
|
|
2127
2292
|
});
|
|
2128
2293
|
return result;
|
|
2129
2294
|
};
|
|
@@ -2155,18 +2320,18 @@ var ApolloClient = (function () {
|
|
|
2155
2320
|
return ApolloClient;
|
|
2156
2321
|
}());
|
|
2157
2322
|
|
|
2158
|
-
tsInvariant.setVerbosity(globals.
|
|
2323
|
+
tsInvariant.setVerbosity(globals.__DEV__ ? "log" : "silent");
|
|
2159
2324
|
|
|
2325
|
+
exports.Observable = utilities.Observable;
|
|
2326
|
+
exports.isReference = utilities.isReference;
|
|
2327
|
+
exports.makeReference = utilities.makeReference;
|
|
2328
|
+
exports.mergeOptions = utilities.mergeOptions;
|
|
2160
2329
|
exports.ApolloCache = cache.ApolloCache;
|
|
2161
2330
|
exports.Cache = cache.Cache;
|
|
2162
2331
|
exports.InMemoryCache = cache.InMemoryCache;
|
|
2163
2332
|
exports.MissingFieldError = cache.MissingFieldError;
|
|
2164
2333
|
exports.defaultDataIdFromObject = cache.defaultDataIdFromObject;
|
|
2165
2334
|
exports.makeVar = cache.makeVar;
|
|
2166
|
-
exports.Observable = utilities.Observable;
|
|
2167
|
-
exports.isReference = utilities.isReference;
|
|
2168
|
-
exports.makeReference = utilities.makeReference;
|
|
2169
|
-
exports.mergeOptions = utilities.mergeOptions;
|
|
2170
2335
|
exports.ApolloError = errors.ApolloError;
|
|
2171
2336
|
exports.isApolloError = errors.isApolloError;
|
|
2172
2337
|
exports.fromError = utils.fromError;
|