@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.
Files changed (240) hide show
  1. package/README.md +2 -2
  2. package/apollo-client.cjs.js +92 -107
  3. package/apollo-client.cjs.js.map +1 -1
  4. package/apollo-client.cjs.min.js +1 -0
  5. package/cache/cache.cjs.js +20 -22
  6. package/cache/cache.cjs.js.map +1 -1
  7. package/cache/index.d.ts +1 -0
  8. package/cache/index.d.ts.map +1 -1
  9. package/cache/index.js +1 -3
  10. package/cache/index.js.map +1 -1
  11. package/cache/inmemory/entityStore.js +2 -2
  12. package/cache/inmemory/entityStore.js.map +1 -1
  13. package/cache/inmemory/object-canon.d.ts +1 -0
  14. package/cache/inmemory/object-canon.d.ts.map +1 -1
  15. package/cache/inmemory/object-canon.js +1 -0
  16. package/cache/inmemory/object-canon.js.map +1 -1
  17. package/cache/inmemory/policies.d.ts.map +1 -1
  18. package/cache/inmemory/policies.js +4 -4
  19. package/cache/inmemory/policies.js.map +1 -1
  20. package/cache/inmemory/readFromStore.d.ts.map +1 -1
  21. package/cache/inmemory/readFromStore.js +4 -4
  22. package/cache/inmemory/readFromStore.js.map +1 -1
  23. package/cache/inmemory/writeToStore.d.ts.map +1 -1
  24. package/cache/inmemory/writeToStore.js +2 -2
  25. package/cache/inmemory/writeToStore.js.map +1 -1
  26. package/core/ApolloClient.d.ts.map +1 -1
  27. package/core/ApolloClient.js +3 -3
  28. package/core/ApolloClient.js.map +1 -1
  29. package/core/LocalState.d.ts.map +1 -1
  30. package/core/LocalState.js +2 -2
  31. package/core/LocalState.js.map +1 -1
  32. package/core/ObservableQuery.d.ts.map +1 -1
  33. package/core/ObservableQuery.js +19 -6
  34. package/core/ObservableQuery.js.map +1 -1
  35. package/core/QueryManager.d.ts.map +1 -1
  36. package/core/QueryManager.js +10 -10
  37. package/core/QueryManager.js.map +1 -1
  38. package/core/core.cjs.js +49 -35
  39. package/core/core.cjs.js.map +1 -1
  40. package/core/index.js +1 -1
  41. package/core/index.js.map +1 -1
  42. package/errors/errors.cjs.js +1 -2
  43. package/errors/errors.cjs.js.map +1 -1
  44. package/errors/index.d.ts +1 -0
  45. package/errors/index.d.ts.map +1 -1
  46. package/errors/index.js +1 -3
  47. package/errors/index.js.map +1 -1
  48. package/invariantErrorCodes.js +56 -81
  49. package/link/core/ApolloLink.js +2 -2
  50. package/link/core/ApolloLink.js.map +1 -1
  51. package/link/core/core.cjs.js +4 -6
  52. package/link/core/core.cjs.js.map +1 -1
  53. package/link/core/index.d.ts +1 -0
  54. package/link/core/index.d.ts.map +1 -1
  55. package/link/core/index.js +1 -3
  56. package/link/core/index.js.map +1 -1
  57. package/link/http/checkFetcher.js +2 -2
  58. package/link/http/checkFetcher.js.map +1 -1
  59. package/link/http/createHttpLink.d.ts +1 -0
  60. package/link/http/createHttpLink.d.ts.map +1 -1
  61. package/link/http/createHttpLink.js +1 -0
  62. package/link/http/createHttpLink.js.map +1 -1
  63. package/link/http/http.cjs.js +3 -3
  64. package/link/http/http.cjs.js.map +1 -1
  65. package/link/http/index.d.ts +1 -0
  66. package/link/http/index.d.ts.map +1 -1
  67. package/link/http/index.js +1 -0
  68. package/link/http/index.js.map +1 -1
  69. package/link/http/serializeFetchParameter.d.ts +1 -1
  70. package/link/http/serializeFetchParameter.d.ts.map +1 -1
  71. package/link/http/serializeFetchParameter.js +2 -2
  72. package/link/http/serializeFetchParameter.js.map +1 -1
  73. package/link/persisted-queries/index.d.ts +1 -1
  74. package/link/persisted-queries/index.d.ts.map +1 -1
  75. package/link/persisted-queries/index.js +4 -4
  76. package/link/persisted-queries/index.js.map +1 -1
  77. package/link/persisted-queries/persisted-queries.cjs.js +8 -5
  78. package/link/persisted-queries/persisted-queries.cjs.js.map +1 -1
  79. package/link/utils/index.d.ts +1 -0
  80. package/link/utils/index.d.ts.map +1 -1
  81. package/link/utils/index.js +1 -0
  82. package/link/utils/index.js.map +1 -1
  83. package/link/utils/toPromise.d.ts.map +1 -1
  84. package/link/utils/toPromise.js +1 -1
  85. package/link/utils/toPromise.js.map +1 -1
  86. package/link/utils/utils.cjs.js +3 -3
  87. package/link/utils/utils.cjs.js.map +1 -1
  88. package/link/utils/validateOperation.d.ts.map +1 -1
  89. package/link/utils/validateOperation.js +2 -2
  90. package/link/utils/validateOperation.js.map +1 -1
  91. package/package.json +11 -11
  92. package/react/context/ApolloConsumer.d.ts.map +1 -1
  93. package/react/context/ApolloConsumer.js +2 -2
  94. package/react/context/ApolloConsumer.js.map +1 -1
  95. package/react/context/ApolloContext.d.ts +2 -1
  96. package/react/context/ApolloContext.d.ts.map +1 -1
  97. package/react/context/ApolloContext.js +11 -5
  98. package/react/context/ApolloContext.js.map +1 -1
  99. package/react/context/ApolloProvider.d.ts.map +1 -1
  100. package/react/context/ApolloProvider.js +2 -2
  101. package/react/context/ApolloProvider.js.map +1 -1
  102. package/react/context/context.cjs.js +15 -9
  103. package/react/context/context.cjs.js.map +1 -1
  104. package/react/context/index.d.ts +1 -0
  105. package/react/context/index.d.ts.map +1 -1
  106. package/react/context/index.js +1 -0
  107. package/react/context/index.js.map +1 -1
  108. package/react/data/OperationData.d.ts.map +1 -1
  109. package/react/data/OperationData.js +3 -3
  110. package/react/data/OperationData.js.map +1 -1
  111. package/react/data/QueryData.d.ts.map +1 -1
  112. package/react/data/QueryData.js +1 -3
  113. package/react/data/QueryData.js.map +1 -1
  114. package/react/data/data.cjs.js +6 -8
  115. package/react/data/data.cjs.js.map +1 -1
  116. package/react/data/index.d.ts +1 -0
  117. package/react/data/index.d.ts.map +1 -1
  118. package/react/data/index.js +1 -0
  119. package/react/data/index.js.map +1 -1
  120. package/react/hoc/hoc-utils.d.ts.map +1 -1
  121. package/react/hoc/hoc-utils.js +2 -2
  122. package/react/hoc/hoc-utils.js.map +1 -1
  123. package/react/hoc/hoc.cjs.js +5 -5
  124. package/react/hoc/hoc.cjs.js.map +1 -1
  125. package/react/hoc/index.d.ts +1 -0
  126. package/react/hoc/index.d.ts.map +1 -1
  127. package/react/hoc/index.js +1 -0
  128. package/react/hoc/index.js.map +1 -1
  129. package/react/hoc/withApollo.d.ts.map +1 -1
  130. package/react/hoc/withApollo.js +2 -2
  131. package/react/hoc/withApollo.js.map +1 -1
  132. package/react/hooks/hooks.cjs.js +3 -3
  133. package/react/hooks/hooks.cjs.js.map +1 -1
  134. package/react/hooks/index.d.ts +1 -0
  135. package/react/hooks/index.d.ts.map +1 -1
  136. package/react/hooks/index.js +1 -0
  137. package/react/hooks/index.js.map +1 -1
  138. package/react/hooks/useApolloClient.d.ts.map +1 -1
  139. package/react/hooks/useApolloClient.js +2 -2
  140. package/react/hooks/useApolloClient.js.map +1 -1
  141. package/react/hooks/useSubscription.d.ts +1 -0
  142. package/react/hooks/useSubscription.d.ts.map +1 -1
  143. package/react/hooks/useSubscription.js +1 -0
  144. package/react/hooks/useSubscription.js.map +1 -1
  145. package/react/hooks/utils/useAfterFastRefresh.d.ts +1 -0
  146. package/react/hooks/utils/useAfterFastRefresh.d.ts.map +1 -1
  147. package/react/hooks/utils/useAfterFastRefresh.js +1 -0
  148. package/react/hooks/utils/useAfterFastRefresh.js.map +1 -1
  149. package/react/hooks/utils/useBaseQuery.d.ts +1 -0
  150. package/react/hooks/utils/useBaseQuery.d.ts.map +1 -1
  151. package/react/hooks/utils/useBaseQuery.js +1 -0
  152. package/react/hooks/utils/useBaseQuery.js.map +1 -1
  153. package/react/index.d.ts +1 -0
  154. package/react/index.d.ts.map +1 -1
  155. package/react/index.js +1 -3
  156. package/react/index.js.map +1 -1
  157. package/react/parser/index.d.ts.map +1 -1
  158. package/react/parser/index.js +5 -5
  159. package/react/parser/index.js.map +1 -1
  160. package/react/parser/parser.cjs.js +10 -10
  161. package/react/parser/parser.cjs.js.map +1 -1
  162. package/react/react.cjs.js +2 -3
  163. package/react/react.cjs.js.map +1 -1
  164. package/testing/index.d.ts +1 -0
  165. package/testing/index.d.ts.map +1 -1
  166. package/testing/index.js +1 -3
  167. package/testing/index.js.map +1 -1
  168. package/testing/testing.cjs.js +3 -5
  169. package/testing/testing.cjs.js.map +1 -1
  170. package/utilities/common/canUse.d.ts +1 -0
  171. package/utilities/common/canUse.d.ts.map +1 -1
  172. package/utilities/common/canUse.js +2 -0
  173. package/utilities/common/canUse.js.map +1 -1
  174. package/utilities/common/mergeDeep.js +1 -1
  175. package/utilities/common/mergeDeep.js.map +1 -1
  176. package/utilities/globals/DEV.js +2 -2
  177. package/utilities/globals/DEV.js.map +1 -1
  178. package/utilities/{common → globals}/global.d.ts +0 -0
  179. package/utilities/globals/global.d.ts.map +1 -0
  180. package/utilities/{common → globals}/global.js +0 -0
  181. package/utilities/globals/global.js.map +1 -0
  182. package/utilities/globals/globals.cjs.js +57 -0
  183. package/utilities/globals/globals.cjs.js.map +1 -0
  184. package/utilities/globals/index.d.ts +5 -2
  185. package/utilities/globals/index.d.ts.map +1 -1
  186. package/utilities/globals/index.js +8 -1
  187. package/utilities/globals/index.js.map +1 -1
  188. package/utilities/{common → globals}/maybe.d.ts +0 -0
  189. package/utilities/globals/maybe.d.ts.map +1 -0
  190. package/utilities/{common → globals}/maybe.js +0 -0
  191. package/utilities/globals/maybe.js.map +1 -0
  192. package/utilities/globals/package.json +7 -0
  193. package/utilities/graphql/directives.d.ts.map +1 -1
  194. package/utilities/graphql/directives.js +5 -5
  195. package/utilities/graphql/directives.js.map +1 -1
  196. package/utilities/graphql/fragments.d.ts.map +1 -1
  197. package/utilities/graphql/fragments.js +5 -5
  198. package/utilities/graphql/fragments.js.map +1 -1
  199. package/utilities/graphql/getFromAST.d.ts.map +1 -1
  200. package/utilities/graphql/getFromAST.js +9 -9
  201. package/utilities/graphql/getFromAST.js.map +1 -1
  202. package/utilities/graphql/storeUtils.d.ts.map +1 -1
  203. package/utilities/graphql/storeUtils.js +2 -2
  204. package/utilities/graphql/storeUtils.js.map +1 -1
  205. package/utilities/graphql/transform.d.ts.map +1 -1
  206. package/utilities/graphql/transform.js +2 -2
  207. package/utilities/graphql/transform.js.map +1 -1
  208. package/utilities/index.d.ts +1 -3
  209. package/utilities/index.d.ts.map +1 -1
  210. package/utilities/index.js +1 -5
  211. package/utilities/index.js.map +1 -1
  212. package/utilities/observables/Concast.js +1 -1
  213. package/utilities/observables/Concast.js.map +1 -1
  214. package/utilities/observables/subclassing.d.ts.map +1 -1
  215. package/utilities/observables/subclassing.js +2 -1
  216. package/utilities/observables/subclassing.js.map +1 -1
  217. package/utilities/package.json +1 -3
  218. package/utilities/policies/pagination.d.ts +1 -1
  219. package/utilities/policies/pagination.d.ts.map +1 -1
  220. package/utilities/policies/pagination.js +9 -4
  221. package/utilities/policies/pagination.js.map +1 -1
  222. package/utilities/testing/mocking/mockFetch.js +1 -1
  223. package/utilities/testing/mocking/mockFetch.js.map +1 -1
  224. package/utilities/testing/mocking/mockLink.d.ts.map +1 -1
  225. package/utilities/testing/mocking/mockLink.js +2 -2
  226. package/utilities/testing/mocking/mockLink.js.map +1 -1
  227. package/utilities/testing/mocking/mockWatchQuery.js +1 -1
  228. package/utilities/testing/mocking/mockWatchQuery.js.map +1 -1
  229. package/utilities/testing/observableToPromise.js +1 -1
  230. package/utilities/testing/observableToPromise.js.map +1 -1
  231. package/utilities/utilities.cjs.js +42 -74
  232. package/utilities/utilities.cjs.js.map +1 -1
  233. package/version.js +1 -1
  234. package/apollo-core.cjs.js +0 -5768
  235. package/apollo-core.cjs.js.map +0 -1
  236. package/apollo-core.cjs.min.js +0 -1
  237. package/utilities/common/global.d.ts.map +0 -1
  238. package/utilities/common/global.js.map +0 -1
  239. package/utilities/common/maybe.d.ts.map +0 -1
  240. 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 utilities = require('../utilities');
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.8';
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
- if (!this.queryManager.transform(this.options.query).hasForcedResolvers) {
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__ && tsInvariant.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.");
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__ && tsInvariant.invariant.error('Unhandled GraphQL subscription error', err);
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__ ? tsInvariant.invariant(pollInterval, 'Attempted to start a polling query without a polling interval.') : tsInvariant.invariant(pollInterval, 13);
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
- : Object.assign(this.options, utilities.compact(newOptions));
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__ && tsInvariant.invariant.error('Unhandled error', error.message, error.stack);
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__ && tsInvariant.invariant.debug("Missing cache result fields: " + missing.map(function (m) { return m.path.join('.'); }).join(', '), missing);
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__ ? tsInvariant.invariant(fragment, "No fragment named " + selection.name.value) : tsInvariant.invariant(fragment, 12);
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 tsInvariant.InvariantError('QueryManager stopped while query was in flight') : new tsInvariant.InvariantError(14));
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__ ? tsInvariant.invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.') : tsInvariant.invariant(mutation, 15);
1020
- __DEV__ ? tsInvariant.invariant(fetchPolicy === 'network-only' ||
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.") : tsInvariant.invariant(fetchPolicy === 'network-only' ||
1022
- fetchPolicy === 'no-cache', 16);
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__ && tsInvariant.invariant.error(error);
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__ ? tsInvariant.invariant(options.query, 'query option is required. You must specify your GraphQL document ' +
1307
- 'in the query option.') : tsInvariant.invariant(options.query, 17);
1308
- __DEV__ ? tsInvariant.invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.') : tsInvariant.invariant(options.query.kind === 'Document', 18);
1309
- __DEV__ ? tsInvariant.invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.') : tsInvariant.invariant(!options.returnPartialData, 19);
1310
- __DEV__ ? tsInvariant.invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.') : tsInvariant.invariant(!options.pollInterval, 20);
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 tsInvariant.InvariantError('Store reset while query was in flight (not completed in link chain)') : new tsInvariant.InvariantError(21));
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
- tsInvariant.invariant(oq.queryId === queryId);
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__ && tsInvariant.invariant.warn("Unknown query " + (typeof nameOrDoc === "string" ? "named " : "") + JSON.stringify(nameOrDoc, null, 2) + " requested in refetchQueries options.include array");
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
- Promise.resolve().then(function () { return concast.cancel(reason); });
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 tsInvariant.InvariantError("To initialize Apollo Client, you must specify a 'cache' property " +
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 tsInvariant.InvariantError(10);
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__ && tsInvariant.invariant.log("Download the Apollo DevTools for a better development " +
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__ ? tsInvariant.invariant(options.fetchPolicy !== 'cache-and-network', 'The cache-and-network fetchPolicy does not work with client.query, because ' +
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.') : tsInvariant.invariant(options.fetchPolicy !== 'cache-and-network', 11);
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__ && tsInvariant.invariant.debug("In client.refetchQueries, Promise.all promise rejected with error " + error);
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(utilities.DEV ? "log" : "silent");
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;