@apollo/client 3.4.8 → 3.4.12
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 +2 -2
- package/apollo-client.cjs.js +92 -107
- package/apollo-client.cjs.js.map +1 -1
- package/apollo-client.cjs.min.js +1 -0
- package/cache/cache.cjs.js +20 -22
- package/cache/cache.cjs.js.map +1 -1
- package/cache/index.d.ts +1 -0
- package/cache/index.d.ts.map +1 -1
- package/cache/index.js +1 -3
- package/cache/index.js.map +1 -1
- package/cache/inmemory/entityStore.js +2 -2
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/object-canon.d.ts +1 -0
- package/cache/inmemory/object-canon.d.ts.map +1 -1
- package/cache/inmemory/object-canon.js +1 -0
- package/cache/inmemory/object-canon.js.map +1 -1
- package/cache/inmemory/policies.d.ts.map +1 -1
- package/cache/inmemory/policies.js +4 -4
- package/cache/inmemory/policies.js.map +1 -1
- package/cache/inmemory/readFromStore.d.ts.map +1 -1
- package/cache/inmemory/readFromStore.js +4 -4
- package/cache/inmemory/readFromStore.js.map +1 -1
- package/cache/inmemory/writeToStore.d.ts.map +1 -1
- package/cache/inmemory/writeToStore.js +2 -2
- package/cache/inmemory/writeToStore.js.map +1 -1
- package/core/ApolloClient.d.ts.map +1 -1
- package/core/ApolloClient.js +3 -3
- package/core/ApolloClient.js.map +1 -1
- package/core/LocalState.d.ts.map +1 -1
- package/core/LocalState.js +2 -2
- package/core/LocalState.js.map +1 -1
- package/core/ObservableQuery.d.ts.map +1 -1
- package/core/ObservableQuery.js +19 -6
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryManager.d.ts.map +1 -1
- package/core/QueryManager.js +10 -10
- package/core/QueryManager.js.map +1 -1
- package/core/core.cjs.js +49 -35
- package/core/core.cjs.js.map +1 -1
- package/core/index.js +1 -1
- package/core/index.js.map +1 -1
- package/errors/errors.cjs.js +1 -2
- package/errors/errors.cjs.js.map +1 -1
- package/errors/index.d.ts +1 -0
- package/errors/index.d.ts.map +1 -1
- package/errors/index.js +1 -3
- package/errors/index.js.map +1 -1
- package/invariantErrorCodes.js +56 -81
- package/link/core/ApolloLink.js +2 -2
- package/link/core/ApolloLink.js.map +1 -1
- package/link/core/core.cjs.js +4 -6
- package/link/core/core.cjs.js.map +1 -1
- package/link/core/index.d.ts +1 -0
- package/link/core/index.d.ts.map +1 -1
- package/link/core/index.js +1 -3
- package/link/core/index.js.map +1 -1
- package/link/http/checkFetcher.js +2 -2
- package/link/http/checkFetcher.js.map +1 -1
- package/link/http/createHttpLink.d.ts +1 -0
- package/link/http/createHttpLink.d.ts.map +1 -1
- package/link/http/createHttpLink.js +1 -0
- package/link/http/createHttpLink.js.map +1 -1
- package/link/http/http.cjs.js +3 -3
- package/link/http/http.cjs.js.map +1 -1
- package/link/http/index.d.ts +1 -0
- package/link/http/index.d.ts.map +1 -1
- package/link/http/index.js +1 -0
- package/link/http/index.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/http/serializeFetchParameter.js.map +1 -1
- package/link/persisted-queries/index.d.ts +1 -1
- package/link/persisted-queries/index.d.ts.map +1 -1
- package/link/persisted-queries/index.js +4 -4
- package/link/persisted-queries/index.js.map +1 -1
- package/link/persisted-queries/persisted-queries.cjs.js +8 -5
- package/link/persisted-queries/persisted-queries.cjs.js.map +1 -1
- package/link/utils/index.d.ts +1 -0
- package/link/utils/index.d.ts.map +1 -1
- package/link/utils/index.js +1 -0
- package/link/utils/index.js.map +1 -1
- package/link/utils/toPromise.d.ts.map +1 -1
- package/link/utils/toPromise.js +1 -1
- package/link/utils/toPromise.js.map +1 -1
- package/link/utils/utils.cjs.js +3 -3
- package/link/utils/utils.cjs.js.map +1 -1
- package/link/utils/validateOperation.d.ts.map +1 -1
- package/link/utils/validateOperation.js +2 -2
- package/link/utils/validateOperation.js.map +1 -1
- package/package.json +11 -11
- package/react/context/ApolloConsumer.d.ts.map +1 -1
- package/react/context/ApolloConsumer.js +2 -2
- package/react/context/ApolloConsumer.js.map +1 -1
- package/react/context/ApolloContext.d.ts +2 -1
- package/react/context/ApolloContext.d.ts.map +1 -1
- package/react/context/ApolloContext.js +11 -5
- package/react/context/ApolloContext.js.map +1 -1
- package/react/context/ApolloProvider.d.ts.map +1 -1
- package/react/context/ApolloProvider.js +2 -2
- package/react/context/ApolloProvider.js.map +1 -1
- package/react/context/context.cjs.js +15 -9
- package/react/context/context.cjs.js.map +1 -1
- package/react/context/index.d.ts +1 -0
- package/react/context/index.d.ts.map +1 -1
- package/react/context/index.js +1 -0
- package/react/context/index.js.map +1 -1
- package/react/data/OperationData.d.ts.map +1 -1
- package/react/data/OperationData.js +3 -3
- package/react/data/OperationData.js.map +1 -1
- package/react/data/QueryData.d.ts.map +1 -1
- package/react/data/QueryData.js +1 -3
- package/react/data/QueryData.js.map +1 -1
- package/react/data/data.cjs.js +6 -8
- package/react/data/data.cjs.js.map +1 -1
- package/react/data/index.d.ts +1 -0
- package/react/data/index.d.ts.map +1 -1
- package/react/data/index.js +1 -0
- package/react/data/index.js.map +1 -1
- package/react/hoc/hoc-utils.d.ts.map +1 -1
- package/react/hoc/hoc-utils.js +2 -2
- package/react/hoc/hoc-utils.js.map +1 -1
- package/react/hoc/hoc.cjs.js +5 -5
- package/react/hoc/hoc.cjs.js.map +1 -1
- package/react/hoc/index.d.ts +1 -0
- package/react/hoc/index.d.ts.map +1 -1
- package/react/hoc/index.js +1 -0
- package/react/hoc/index.js.map +1 -1
- package/react/hoc/withApollo.d.ts.map +1 -1
- package/react/hoc/withApollo.js +2 -2
- package/react/hoc/withApollo.js.map +1 -1
- package/react/hooks/hooks.cjs.js +3 -3
- package/react/hooks/hooks.cjs.js.map +1 -1
- package/react/hooks/index.d.ts +1 -0
- package/react/hooks/index.d.ts.map +1 -1
- package/react/hooks/index.js +1 -0
- package/react/hooks/index.js.map +1 -1
- package/react/hooks/useApolloClient.d.ts.map +1 -1
- package/react/hooks/useApolloClient.js +2 -2
- package/react/hooks/useApolloClient.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +1 -0
- package/react/hooks/useSubscription.d.ts.map +1 -1
- package/react/hooks/useSubscription.js +1 -0
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/utils/useAfterFastRefresh.d.ts +1 -0
- package/react/hooks/utils/useAfterFastRefresh.d.ts.map +1 -1
- package/react/hooks/utils/useAfterFastRefresh.js +1 -0
- package/react/hooks/utils/useAfterFastRefresh.js.map +1 -1
- package/react/hooks/utils/useBaseQuery.d.ts +1 -0
- package/react/hooks/utils/useBaseQuery.d.ts.map +1 -1
- package/react/hooks/utils/useBaseQuery.js +1 -0
- package/react/hooks/utils/useBaseQuery.js.map +1 -1
- package/react/index.d.ts +1 -0
- package/react/index.d.ts.map +1 -1
- package/react/index.js +1 -3
- package/react/index.js.map +1 -1
- package/react/parser/index.d.ts.map +1 -1
- package/react/parser/index.js +5 -5
- package/react/parser/index.js.map +1 -1
- package/react/parser/parser.cjs.js +10 -10
- package/react/parser/parser.cjs.js.map +1 -1
- package/react/react.cjs.js +2 -3
- package/react/react.cjs.js.map +1 -1
- package/testing/index.d.ts +1 -0
- package/testing/index.d.ts.map +1 -1
- package/testing/index.js +1 -3
- package/testing/index.js.map +1 -1
- package/testing/testing.cjs.js +3 -5
- package/testing/testing.cjs.js.map +1 -1
- package/utilities/common/canUse.d.ts +1 -0
- package/utilities/common/canUse.d.ts.map +1 -1
- package/utilities/common/canUse.js +2 -0
- package/utilities/common/canUse.js.map +1 -1
- package/utilities/common/mergeDeep.js +1 -1
- package/utilities/common/mergeDeep.js.map +1 -1
- package/utilities/globals/DEV.js +2 -2
- package/utilities/globals/DEV.js.map +1 -1
- package/utilities/{common → globals}/global.d.ts +0 -0
- package/utilities/globals/global.d.ts.map +1 -0
- package/utilities/{common → globals}/global.js +0 -0
- package/utilities/globals/global.js.map +1 -0
- package/utilities/globals/globals.cjs.js +57 -0
- package/utilities/globals/globals.cjs.js.map +1 -0
- package/utilities/globals/index.d.ts +5 -2
- package/utilities/globals/index.d.ts.map +1 -1
- package/utilities/globals/index.js +8 -1
- package/utilities/globals/index.js.map +1 -1
- package/utilities/{common → globals}/maybe.d.ts +0 -0
- package/utilities/globals/maybe.d.ts.map +1 -0
- package/utilities/{common → globals}/maybe.js +0 -0
- package/utilities/globals/maybe.js.map +1 -0
- package/utilities/globals/package.json +7 -0
- package/utilities/graphql/directives.d.ts.map +1 -1
- package/utilities/graphql/directives.js +5 -5
- package/utilities/graphql/directives.js.map +1 -1
- package/utilities/graphql/fragments.d.ts.map +1 -1
- package/utilities/graphql/fragments.js +5 -5
- package/utilities/graphql/fragments.js.map +1 -1
- package/utilities/graphql/getFromAST.d.ts.map +1 -1
- package/utilities/graphql/getFromAST.js +9 -9
- package/utilities/graphql/getFromAST.js.map +1 -1
- package/utilities/graphql/storeUtils.d.ts.map +1 -1
- package/utilities/graphql/storeUtils.js +2 -2
- package/utilities/graphql/storeUtils.js.map +1 -1
- package/utilities/graphql/transform.d.ts.map +1 -1
- package/utilities/graphql/transform.js +2 -2
- package/utilities/graphql/transform.js.map +1 -1
- package/utilities/index.d.ts +1 -3
- package/utilities/index.d.ts.map +1 -1
- package/utilities/index.js +1 -5
- package/utilities/index.js.map +1 -1
- package/utilities/observables/Concast.js +1 -1
- package/utilities/observables/Concast.js.map +1 -1
- package/utilities/observables/subclassing.d.ts.map +1 -1
- package/utilities/observables/subclassing.js +2 -1
- package/utilities/observables/subclassing.js.map +1 -1
- package/utilities/package.json +1 -3
- package/utilities/policies/pagination.d.ts +1 -1
- package/utilities/policies/pagination.d.ts.map +1 -1
- package/utilities/policies/pagination.js +9 -4
- package/utilities/policies/pagination.js.map +1 -1
- package/utilities/testing/mocking/mockFetch.js +1 -1
- package/utilities/testing/mocking/mockFetch.js.map +1 -1
- package/utilities/testing/mocking/mockLink.d.ts.map +1 -1
- package/utilities/testing/mocking/mockLink.js +2 -2
- package/utilities/testing/mocking/mockLink.js.map +1 -1
- package/utilities/testing/mocking/mockWatchQuery.js +1 -1
- package/utilities/testing/mocking/mockWatchQuery.js.map +1 -1
- package/utilities/testing/observableToPromise.js +1 -1
- package/utilities/testing/observableToPromise.js.map +1 -1
- package/utilities/utilities.cjs.js +42 -74
- package/utilities/utilities.cjs.js.map +1 -1
- package/version.js +1 -1
- package/apollo-core.cjs.js +0 -5768
- package/apollo-core.cjs.js.map +0 -1
- package/apollo-core.cjs.min.js +0 -1
- package/utilities/common/global.d.ts.map +0 -1
- package/utilities/common/global.js.map +0 -1
- package/utilities/common/maybe.d.ts.map +0 -1
- package/utilities/common/maybe.js.map +0 -1
package/core/core.cjs.js
CHANGED
|
@@ -2,19 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var globals = require('../utilities/globals');
|
|
6
6
|
var tslib = require('tslib');
|
|
7
|
-
var tsInvariant = require('ts-invariant');
|
|
8
7
|
var core = require('../link/core');
|
|
8
|
+
var utilities = require('../utilities');
|
|
9
9
|
var http = require('../link/http');
|
|
10
10
|
var equality = require('@wry/equality');
|
|
11
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
|
+
var tsInvariant = require('ts-invariant');
|
|
15
16
|
var graphqlTag = require('graphql-tag');
|
|
16
17
|
|
|
17
|
-
var version = '3.4.
|
|
18
|
+
var version = '3.4.12';
|
|
18
19
|
|
|
19
20
|
exports.NetworkStatus = void 0;
|
|
20
21
|
(function (NetworkStatus) {
|
|
@@ -30,6 +31,7 @@ function isNetworkRequestInFlight(networkStatus) {
|
|
|
30
31
|
return networkStatus ? networkStatus < 7 : false;
|
|
31
32
|
}
|
|
32
33
|
|
|
34
|
+
var assign = Object.assign, hasOwnProperty$1 = Object.hasOwnProperty;
|
|
33
35
|
var warnedAboutUpdateQuery = false;
|
|
34
36
|
var ObservableQuery = (function (_super) {
|
|
35
37
|
tslib.__extends(ObservableQuery, _super);
|
|
@@ -106,7 +108,12 @@ var ObservableQuery = (function (_super) {
|
|
|
106
108
|
(lastResult && lastResult.networkStatus) ||
|
|
107
109
|
exports.NetworkStatus.ready;
|
|
108
110
|
var result = tslib.__assign(tslib.__assign({}, lastResult), { loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus });
|
|
109
|
-
|
|
111
|
+
var _a = this.options.fetchPolicy, fetchPolicy = _a === void 0 ? "cache-first" : _a;
|
|
112
|
+
var shouldReturnCachedData = lastResult || (fetchPolicy !== 'network-only' &&
|
|
113
|
+
fetchPolicy !== 'no-cache' &&
|
|
114
|
+
fetchPolicy !== 'standby');
|
|
115
|
+
if (shouldReturnCachedData &&
|
|
116
|
+
!this.queryManager.transform(this.options.query).hasForcedResolvers) {
|
|
110
117
|
var diff = this.queryInfo.getDiff();
|
|
111
118
|
if (diff.complete || this.options.returnPartialData) {
|
|
112
119
|
result.data = diff.result;
|
|
@@ -114,7 +121,6 @@ var ObservableQuery = (function (_super) {
|
|
|
114
121
|
if (equality.equal(result.data, {})) {
|
|
115
122
|
result.data = void 0;
|
|
116
123
|
}
|
|
117
|
-
var _a = this.options.fetchPolicy, fetchPolicy = _a === void 0 ? "cache-first" : _a;
|
|
118
124
|
if (diff.complete) {
|
|
119
125
|
if (result.networkStatus === exports.NetworkStatus.loading &&
|
|
120
126
|
(fetchPolicy === 'cache-first' ||
|
|
@@ -166,6 +172,7 @@ var ObservableQuery = (function (_super) {
|
|
|
166
172
|
this.queryManager.resetErrors(this.queryId);
|
|
167
173
|
};
|
|
168
174
|
ObservableQuery.prototype.refetch = function (variables) {
|
|
175
|
+
var _a;
|
|
169
176
|
var reobserveOptions = {
|
|
170
177
|
pollInterval: 0,
|
|
171
178
|
};
|
|
@@ -176,6 +183,13 @@ var ObservableQuery = (function (_super) {
|
|
|
176
183
|
else if (fetchPolicy !== 'cache-and-network') {
|
|
177
184
|
reobserveOptions.fetchPolicy = 'network-only';
|
|
178
185
|
}
|
|
186
|
+
if (__DEV__ && variables && hasOwnProperty$1.call(variables, "variables")) {
|
|
187
|
+
var queryDef = utilities.getQueryDefinition(this.options.query);
|
|
188
|
+
var vars = queryDef.variableDefinitions;
|
|
189
|
+
if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
|
|
190
|
+
__DEV__ && globals.invariant.warn("Called refetch(" + JSON.stringify(variables) + ") for query " + (((_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 })?");
|
|
191
|
+
}
|
|
192
|
+
}
|
|
179
193
|
if (variables && !equality.equal(this.options.variables, variables)) {
|
|
180
194
|
reobserveOptions.variables = this.options.variables = tslib.__assign(tslib.__assign({}, this.options.variables), variables);
|
|
181
195
|
}
|
|
@@ -196,7 +210,7 @@ var ObservableQuery = (function (_super) {
|
|
|
196
210
|
if (updateQuery) {
|
|
197
211
|
if (__DEV__ &&
|
|
198
212
|
!warnedAboutUpdateQuery) {
|
|
199
|
-
__DEV__ &&
|
|
213
|
+
__DEV__ && globals.invariant.warn("The updateQuery callback for fetchMore is deprecated, and will be removed\nin the next major version of Apollo Client.\n\nPlease convert updateQuery functions to field policies with appropriate\nread and merge functions, or use/adapt a helper function (such as\nconcatPagination, offsetLimitPagination, or relayStylePagination) from\n@apollo/client/utilities.\n\nThe field policy system handles pagination more effectively than a\nhand-written updateQuery function, and you only need to define the policy\nonce, rather than every time you call fetchMore.");
|
|
200
214
|
warnedAboutUpdateQuery = true;
|
|
201
215
|
}
|
|
202
216
|
_this.updateQuery(function (previous) { return updateQuery(previous, {
|
|
@@ -243,7 +257,7 @@ var ObservableQuery = (function (_super) {
|
|
|
243
257
|
options.onError(err);
|
|
244
258
|
return;
|
|
245
259
|
}
|
|
246
|
-
__DEV__ &&
|
|
260
|
+
__DEV__ && globals.invariant.error('Unhandled GraphQL subscription error', err);
|
|
247
261
|
},
|
|
248
262
|
});
|
|
249
263
|
this.subscriptions.add(subscription);
|
|
@@ -320,7 +334,7 @@ var ObservableQuery = (function (_super) {
|
|
|
320
334
|
pollingInfo.interval === pollInterval) {
|
|
321
335
|
return;
|
|
322
336
|
}
|
|
323
|
-
__DEV__ ?
|
|
337
|
+
__DEV__ ? globals.invariant(pollInterval, 'Attempted to start a polling query without a polling interval.') : globals.invariant(pollInterval, 12);
|
|
324
338
|
var info = pollingInfo || (this.pollingInfo = {});
|
|
325
339
|
info.interval = pollInterval;
|
|
326
340
|
var maybeFetch = function () {
|
|
@@ -363,7 +377,7 @@ var ObservableQuery = (function (_super) {
|
|
|
363
377
|
var oldVariables = this.options.variables;
|
|
364
378
|
var options = useDisposableConcast
|
|
365
379
|
? utilities.compact(this.options, newOptions)
|
|
366
|
-
:
|
|
380
|
+
: assign(this.options, utilities.compact(newOptions));
|
|
367
381
|
if (!useDisposableConcast) {
|
|
368
382
|
this.updatePolling();
|
|
369
383
|
if (newOptions &&
|
|
@@ -432,11 +446,11 @@ var ObservableQuery = (function (_super) {
|
|
|
432
446
|
}(utilities.Observable));
|
|
433
447
|
utilities.fixObservableSubclass(ObservableQuery);
|
|
434
448
|
function defaultSubscriptionObserverErrorCallback(error) {
|
|
435
|
-
__DEV__ &&
|
|
449
|
+
__DEV__ && globals.invariant.error('Unhandled error', error.message, error.stack);
|
|
436
450
|
}
|
|
437
451
|
function logMissingFieldErrors(missing) {
|
|
438
452
|
if (__DEV__ && utilities.isNonEmptyArray(missing)) {
|
|
439
|
-
__DEV__ &&
|
|
453
|
+
__DEV__ && globals.invariant.debug("Missing cache result fields: " + missing.map(function (m) { return m.path.join('.'); }).join(', '), missing);
|
|
440
454
|
}
|
|
441
455
|
}
|
|
442
456
|
function applyNextFetchPolicy(options) {
|
|
@@ -617,7 +631,7 @@ var LocalState = (function () {
|
|
|
617
631
|
}
|
|
618
632
|
else {
|
|
619
633
|
fragment = fragmentMap[selection.name.value];
|
|
620
|
-
__DEV__ ?
|
|
634
|
+
__DEV__ ? globals.invariant(fragment, "No fragment named " + selection.name.value) : globals.invariant(fragment, 11);
|
|
621
635
|
}
|
|
622
636
|
if (fragment && fragment.typeCondition) {
|
|
623
637
|
typeCondition = fragment.typeCondition.name.value;
|
|
@@ -1003,7 +1017,7 @@ var QueryManager = (function () {
|
|
|
1003
1017
|
this.queries.forEach(function (_info, queryId) {
|
|
1004
1018
|
_this.stopQueryNoBroadcast(queryId);
|
|
1005
1019
|
});
|
|
1006
|
-
this.cancelPendingFetches(__DEV__ ? new
|
|
1020
|
+
this.cancelPendingFetches(__DEV__ ? new globals.InvariantError('QueryManager stopped while query was in flight') : new globals.InvariantError(13));
|
|
1007
1021
|
};
|
|
1008
1022
|
QueryManager.prototype.cancelPendingFetches = function (error) {
|
|
1009
1023
|
this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
|
|
@@ -1016,10 +1030,10 @@ var QueryManager = (function () {
|
|
|
1016
1030
|
return tslib.__generator(this, function (_f) {
|
|
1017
1031
|
switch (_f.label) {
|
|
1018
1032
|
case 0:
|
|
1019
|
-
__DEV__ ?
|
|
1020
|
-
__DEV__ ?
|
|
1021
|
-
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.") :
|
|
1022
|
-
fetchPolicy === 'no-cache',
|
|
1033
|
+
__DEV__ ? globals.invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.') : globals.invariant(mutation, 14);
|
|
1034
|
+
__DEV__ ? globals.invariant(fetchPolicy === 'network-only' ||
|
|
1035
|
+
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' ||
|
|
1036
|
+
fetchPolicy === 'no-cache', 15);
|
|
1023
1037
|
mutationId = this.generateMutationId();
|
|
1024
1038
|
mutation = this.transform(mutation).document;
|
|
1025
1039
|
variables = this.getVariables(mutation, variables);
|
|
@@ -1218,7 +1232,7 @@ var QueryManager = (function () {
|
|
|
1218
1232
|
_this.markMutationResult(tslib.__assign(tslib.__assign({}, mutation), { result: { data: data } }), cache);
|
|
1219
1233
|
}
|
|
1220
1234
|
catch (error) {
|
|
1221
|
-
__DEV__ &&
|
|
1235
|
+
__DEV__ && globals.invariant.error(error);
|
|
1222
1236
|
}
|
|
1223
1237
|
}, mutation.mutationId);
|
|
1224
1238
|
};
|
|
@@ -1303,11 +1317,11 @@ var QueryManager = (function () {
|
|
|
1303
1317
|
QueryManager.prototype.query = function (options, queryId) {
|
|
1304
1318
|
var _this = this;
|
|
1305
1319
|
if (queryId === void 0) { queryId = this.generateQueryId(); }
|
|
1306
|
-
__DEV__ ?
|
|
1307
|
-
'in the query option.') :
|
|
1308
|
-
__DEV__ ?
|
|
1309
|
-
__DEV__ ?
|
|
1310
|
-
__DEV__ ?
|
|
1320
|
+
__DEV__ ? globals.invariant(options.query, 'query option is required. You must specify your GraphQL document ' +
|
|
1321
|
+
'in the query option.') : globals.invariant(options.query, 16);
|
|
1322
|
+
__DEV__ ? globals.invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.') : globals.invariant(options.query.kind === 'Document', 17);
|
|
1323
|
+
__DEV__ ? globals.invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.') : globals.invariant(!options.returnPartialData, 18);
|
|
1324
|
+
__DEV__ ? globals.invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.') : globals.invariant(!options.pollInterval, 19);
|
|
1311
1325
|
return this.fetchQuery(queryId, options).finally(function () { return _this.stopQuery(queryId); });
|
|
1312
1326
|
};
|
|
1313
1327
|
QueryManager.prototype.generateQueryId = function () {
|
|
@@ -1329,7 +1343,7 @@ var QueryManager = (function () {
|
|
|
1329
1343
|
queryInfo.stop();
|
|
1330
1344
|
};
|
|
1331
1345
|
QueryManager.prototype.clearStore = function () {
|
|
1332
|
-
this.cancelPendingFetches(__DEV__ ? new
|
|
1346
|
+
this.cancelPendingFetches(__DEV__ ? new globals.InvariantError('Store reset while query was in flight (not completed in link chain)') : new globals.InvariantError(20));
|
|
1333
1347
|
this.queries.forEach(function (queryInfo) {
|
|
1334
1348
|
if (queryInfo.observableQuery) {
|
|
1335
1349
|
queryInfo.networkStatus = exports.NetworkStatus.loading;
|
|
@@ -1402,7 +1416,7 @@ var QueryManager = (function () {
|
|
|
1402
1416
|
queryInfo: queryInfo,
|
|
1403
1417
|
options: tslib.__assign(tslib.__assign({}, options), { fetchPolicy: "network-only" }),
|
|
1404
1418
|
});
|
|
1405
|
-
|
|
1419
|
+
globals.invariant(oq.queryId === queryId);
|
|
1406
1420
|
queryInfo.setObservableQuery(oq);
|
|
1407
1421
|
queries.set(queryId, oq);
|
|
1408
1422
|
});
|
|
@@ -1410,7 +1424,7 @@ var QueryManager = (function () {
|
|
|
1410
1424
|
if (__DEV__ && queryNamesAndDocs.size) {
|
|
1411
1425
|
queryNamesAndDocs.forEach(function (included, nameOrDoc) {
|
|
1412
1426
|
if (!included) {
|
|
1413
|
-
__DEV__ &&
|
|
1427
|
+
__DEV__ && globals.invariant.warn("Unknown query " + (typeof nameOrDoc === "string" ? "named " : "") + JSON.stringify(nameOrDoc, null, 2) + " requested in refetchQueries options.include array");
|
|
1414
1428
|
}
|
|
1415
1429
|
});
|
|
1416
1430
|
}
|
|
@@ -1604,7 +1618,7 @@ var QueryManager = (function () {
|
|
|
1604
1618
|
return _this.fetchQueryByPolicy(queryInfo, normalized, networkStatus);
|
|
1605
1619
|
};
|
|
1606
1620
|
this.fetchCancelFns.set(queryId, function (reason) {
|
|
1607
|
-
|
|
1621
|
+
setTimeout(function () { return concast.cancel(reason); });
|
|
1608
1622
|
});
|
|
1609
1623
|
var concast = new utilities.Concast(this.transform(normalized.query).hasClientExports
|
|
1610
1624
|
? this.localState.addExportedVariables(normalized.query, normalized.variables, normalized.context).then(fromVariables)
|
|
@@ -1820,9 +1834,9 @@ var ApolloClient = (function () {
|
|
|
1820
1834
|
: core.ApolloLink.empty();
|
|
1821
1835
|
}
|
|
1822
1836
|
if (!cache) {
|
|
1823
|
-
throw __DEV__ ? new
|
|
1837
|
+
throw __DEV__ ? new globals.InvariantError("To initialize Apollo Client, you must specify a 'cache' property " +
|
|
1824
1838
|
"in the options object. \n" +
|
|
1825
|
-
"For more information, please visit: https://go.apollo.dev/c/docs") : new
|
|
1839
|
+
"For more information, please visit: https://go.apollo.dev/c/docs") : new globals.InvariantError(9);
|
|
1826
1840
|
}
|
|
1827
1841
|
this.link = link;
|
|
1828
1842
|
this.cache = cache;
|
|
@@ -1860,7 +1874,7 @@ var ApolloClient = (function () {
|
|
|
1860
1874
|
}
|
|
1861
1875
|
}
|
|
1862
1876
|
if (url) {
|
|
1863
|
-
__DEV__ &&
|
|
1877
|
+
__DEV__ && globals.invariant.log("Download the Apollo DevTools for a better development " +
|
|
1864
1878
|
"experience: " + url);
|
|
1865
1879
|
}
|
|
1866
1880
|
}
|
|
@@ -1915,10 +1929,10 @@ var ApolloClient = (function () {
|
|
|
1915
1929
|
if (this.defaultOptions.query) {
|
|
1916
1930
|
options = mergeOptions(this.defaultOptions.query, options);
|
|
1917
1931
|
}
|
|
1918
|
-
__DEV__ ?
|
|
1932
|
+
__DEV__ ? globals.invariant(options.fetchPolicy !== 'cache-and-network', 'The cache-and-network fetchPolicy does not work with client.query, because ' +
|
|
1919
1933
|
'client.query can only return a single result. Please use client.watchQuery ' +
|
|
1920
1934
|
'to receive multiple results from the cache and the network, or consider ' +
|
|
1921
|
-
'using a different fetchPolicy, such as cache-first or network-only.') :
|
|
1935
|
+
'using a different fetchPolicy, such as cache-first or network-only.') : globals.invariant(options.fetchPolicy !== 'cache-and-network', 10);
|
|
1922
1936
|
if (this.disableNetworkFetches && options.fetchPolicy === 'network-only') {
|
|
1923
1937
|
options = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: 'cache-first' });
|
|
1924
1938
|
}
|
|
@@ -1997,7 +2011,7 @@ var ApolloClient = (function () {
|
|
|
1997
2011
|
result.queries = queries;
|
|
1998
2012
|
result.results = results;
|
|
1999
2013
|
result.catch(function (error) {
|
|
2000
|
-
__DEV__ &&
|
|
2014
|
+
__DEV__ && globals.invariant.debug("In client.refetchQueries, Promise.all promise rejected with error " + error);
|
|
2001
2015
|
});
|
|
2002
2016
|
return result;
|
|
2003
2017
|
};
|
|
@@ -2029,12 +2043,11 @@ var ApolloClient = (function () {
|
|
|
2029
2043
|
return ApolloClient;
|
|
2030
2044
|
}());
|
|
2031
2045
|
|
|
2032
|
-
tsInvariant.setVerbosity(
|
|
2046
|
+
tsInvariant.setVerbosity(globals.DEV ? "log" : "silent");
|
|
2033
2047
|
|
|
2034
2048
|
exports.Observable = utilities.Observable;
|
|
2035
2049
|
exports.isReference = utilities.isReference;
|
|
2036
2050
|
exports.makeReference = utilities.makeReference;
|
|
2037
|
-
exports.setLogVerbosity = tsInvariant.setVerbosity;
|
|
2038
2051
|
exports.ApolloCache = cache.ApolloCache;
|
|
2039
2052
|
exports.Cache = cache.Cache;
|
|
2040
2053
|
exports.InMemoryCache = cache.InMemoryCache;
|
|
@@ -2047,6 +2060,7 @@ exports.fromError = utils.fromError;
|
|
|
2047
2060
|
exports.fromPromise = utils.fromPromise;
|
|
2048
2061
|
exports.throwServerError = utils.throwServerError;
|
|
2049
2062
|
exports.toPromise = utils.toPromise;
|
|
2063
|
+
exports.setLogVerbosity = tsInvariant.setVerbosity;
|
|
2050
2064
|
exports.disableExperimentalFragmentVariables = graphqlTag.disableExperimentalFragmentVariables;
|
|
2051
2065
|
exports.disableFragmentWarnings = graphqlTag.disableFragmentWarnings;
|
|
2052
2066
|
exports.enableExperimentalFragmentVariables = graphqlTag.enableExperimentalFragmentVariables;
|