@apollo/client 3.4.5 → 3.4.9

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 (132) hide show
  1. package/apollo-client.cjs.js +1010 -114
  2. package/apollo-client.cjs.js.map +1 -1
  3. package/apollo-core.cjs.js +5772 -0
  4. package/apollo-core.cjs.js.map +1 -0
  5. package/apollo-core.cjs.min.js +1 -0
  6. package/cache/cache.cjs.js +22 -19
  7. package/cache/cache.cjs.js.map +1 -1
  8. package/cache/index.d.ts.map +1 -1
  9. package/cache/index.js +2 -3
  10. package/cache/index.js.map +1 -1
  11. package/cache/inmemory/entityStore.js +1 -1
  12. package/cache/inmemory/policies.js +12 -9
  13. package/cache/inmemory/policies.js.map +1 -1
  14. package/cache/inmemory/readFromStore.js +3 -3
  15. package/cache/inmemory/writeToStore.d.ts +1 -1
  16. package/cache/inmemory/writeToStore.d.ts.map +1 -1
  17. package/cache/inmemory/writeToStore.js +4 -4
  18. package/cache/inmemory/writeToStore.js.map +1 -1
  19. package/core/ApolloClient.js +2 -2
  20. package/core/LocalState.js +1 -1
  21. package/core/ObservableQuery.d.ts +9 -6
  22. package/core/ObservableQuery.d.ts.map +1 -1
  23. package/core/ObservableQuery.js +70 -45
  24. package/core/ObservableQuery.js.map +1 -1
  25. package/core/QueryManager.d.ts +3 -3
  26. package/core/QueryManager.d.ts.map +1 -1
  27. package/core/QueryManager.js +20 -19
  28. package/core/QueryManager.js.map +1 -1
  29. package/core/core.cjs.js +94 -66
  30. package/core/core.cjs.js.map +1 -1
  31. package/core/index.d.ts.map +1 -1
  32. package/core/index.js +2 -1
  33. package/core/index.js.map +1 -1
  34. package/core/watchQueryOptions.d.ts +2 -1
  35. package/core/watchQueryOptions.d.ts.map +1 -1
  36. package/core/watchQueryOptions.js.map +1 -1
  37. package/errors/errors.cjs.js +1 -2
  38. package/errors/errors.cjs.js.map +1 -1
  39. package/errors/index.d.ts.map +1 -1
  40. package/errors/index.js +2 -3
  41. package/errors/index.js.map +1 -1
  42. package/invariantErrorCodes.js +59 -82
  43. package/link/core/ApolloLink.js +1 -1
  44. package/link/core/core.cjs.js +3 -3
  45. package/link/core/core.cjs.js.map +1 -1
  46. package/link/core/index.d.ts.map +1 -1
  47. package/link/core/index.js +2 -3
  48. package/link/core/index.js.map +1 -1
  49. package/link/http/checkFetcher.js +1 -1
  50. package/link/http/createHttpLink.d.ts.map +1 -1
  51. package/link/http/createHttpLink.js +7 -5
  52. package/link/http/createHttpLink.js.map +1 -1
  53. package/link/http/http.cjs.js +11 -8
  54. package/link/http/http.cjs.js.map +1 -1
  55. package/link/http/index.d.ts.map +1 -1
  56. package/link/http/index.js +2 -0
  57. package/link/http/index.js.map +1 -1
  58. package/link/http/serializeFetchParameter.js +1 -1
  59. package/link/persisted-queries/index.d.ts.map +1 -1
  60. package/link/persisted-queries/index.js +4 -2
  61. package/link/persisted-queries/index.js.map +1 -1
  62. package/link/persisted-queries/persisted-queries.cjs.js +4 -3
  63. package/link/persisted-queries/persisted-queries.cjs.js.map +1 -1
  64. package/link/utils/index.d.ts.map +1 -1
  65. package/link/utils/index.js +2 -0
  66. package/link/utils/index.js.map +1 -1
  67. package/link/utils/utils.cjs.js +3 -1
  68. package/link/utils/utils.cjs.js.map +1 -1
  69. package/link/utils/validateOperation.js +1 -1
  70. package/package.json +8 -8
  71. package/react/context/ApolloConsumer.js +1 -1
  72. package/react/context/ApolloProvider.js +1 -1
  73. package/react/context/context.cjs.js +5 -3
  74. package/react/context/context.cjs.js.map +1 -1
  75. package/react/context/index.d.ts.map +1 -1
  76. package/react/context/index.js +2 -0
  77. package/react/context/index.js.map +1 -1
  78. package/react/data/OperationData.js +2 -2
  79. package/react/data/QueryData.d.ts.map +1 -1
  80. package/react/data/QueryData.js +8 -8
  81. package/react/data/QueryData.js.map +1 -1
  82. package/react/data/data.cjs.js +13 -10
  83. package/react/data/data.cjs.js.map +1 -1
  84. package/react/data/index.d.ts.map +1 -1
  85. package/react/data/index.js +2 -0
  86. package/react/data/index.js.map +1 -1
  87. package/react/hoc/hoc-utils.js +1 -1
  88. package/react/hoc/hoc.cjs.js +5 -2
  89. package/react/hoc/hoc.cjs.js.map +1 -1
  90. package/react/hoc/index.d.ts.map +1 -1
  91. package/react/hoc/index.js +2 -0
  92. package/react/hoc/index.js.map +1 -1
  93. package/react/hoc/withApollo.js +1 -1
  94. package/react/hooks/hooks.cjs.js +4 -1
  95. package/react/hooks/hooks.cjs.js.map +1 -1
  96. package/react/hooks/index.d.ts.map +1 -1
  97. package/react/hooks/index.js +2 -0
  98. package/react/hooks/index.js.map +1 -1
  99. package/react/hooks/useApolloClient.js +1 -1
  100. package/react/index.d.ts.map +1 -1
  101. package/react/index.js +2 -3
  102. package/react/index.js.map +1 -1
  103. package/react/parser/index.d.ts.map +1 -1
  104. package/react/parser/index.js +6 -4
  105. package/react/parser/index.js.map +1 -1
  106. package/react/parser/parser.cjs.js +6 -4
  107. package/react/parser/parser.cjs.js.map +1 -1
  108. package/react/react.cjs.js +1 -2
  109. package/react/react.cjs.js.map +1 -1
  110. package/testing/index.js +2 -3
  111. package/testing/index.js.map +1 -1
  112. package/testing/testing.cjs.js +3 -3
  113. package/testing/testing.cjs.js.map +1 -1
  114. package/utilities/globals/index.d.ts +1 -0
  115. package/utilities/globals/index.d.ts.map +1 -1
  116. package/utilities/globals/index.js +4 -0
  117. package/utilities/globals/index.js.map +1 -1
  118. package/utilities/graphql/directives.js +4 -4
  119. package/utilities/graphql/fragments.js +3 -3
  120. package/utilities/graphql/getFromAST.js +8 -8
  121. package/utilities/graphql/storeUtils.js +1 -1
  122. package/utilities/index.d.ts +3 -2
  123. package/utilities/index.d.ts.map +1 -1
  124. package/utilities/index.js +4 -4
  125. package/utilities/index.js.map +1 -1
  126. package/utilities/observables/Concast.js +1 -1
  127. package/utilities/observables/Concast.js.map +1 -1
  128. package/utilities/testing/mocking/mockLink.js +1 -1
  129. package/utilities/utilities.cjs.js +23 -18
  130. package/utilities/utilities.cjs.js.map +1 -1
  131. package/version.js +1 -1
  132. package/apollo-client.cjs.min.js +0 -1
package/core/core.cjs.js CHANGED
@@ -14,7 +14,7 @@ var graphql = require('graphql');
14
14
  var utils = require('../link/utils');
15
15
  var graphqlTag = require('graphql-tag');
16
16
 
17
- var version = '3.4.5';
17
+ var version = '3.4.9';
18
18
 
19
19
  exports.NetworkStatus = void 0;
20
20
  (function (NetworkStatus) {
@@ -45,11 +45,12 @@ var ObservableQuery = (function (_super) {
45
45
  catch (_a) { }
46
46
  var first = !_this.observers.size;
47
47
  _this.observers.add(observer);
48
- if (_this.lastError) {
49
- observer.error && observer.error(_this.lastError);
48
+ var last = _this.last;
49
+ if (last && last.error) {
50
+ observer.error && observer.error(last.error);
50
51
  }
51
- else if (_this.lastResult) {
52
- observer.next && observer.next(_this.lastResult);
52
+ else if (last && last.result) {
53
+ observer.next && observer.next(last.result);
53
54
  }
54
55
  if (first) {
55
56
  _this.reobserve().catch(function () { });
@@ -62,18 +63,6 @@ var ObservableQuery = (function (_super) {
62
63
  }) || this;
63
64
  _this.observers = new Set();
64
65
  _this.subscriptions = new Set();
65
- _this.observer = {
66
- next: function (result) {
67
- if (_this.lastError || _this.isDifferentFromLastResult(result)) {
68
- _this.updateLastResult(result);
69
- utilities.iterateObserversSafely(_this.observers, 'next', result);
70
- }
71
- },
72
- error: function (error) {
73
- _this.updateLastResult(tslib.__assign(tslib.__assign({}, _this.lastResult), { error: error, errors: error.graphQLErrors, networkStatus: exports.NetworkStatus.error, loading: false }));
74
- utilities.iterateObserversSafely(_this.observers, 'error', _this.lastError = error);
75
- },
76
- };
77
66
  _this.isTornDown = false;
78
67
  _this.options = options;
79
68
  _this.queryId = queryInfo.queryId || queryManager.generateQueryId();
@@ -112,15 +101,20 @@ var ObservableQuery = (function (_super) {
112
101
  };
113
102
  ObservableQuery.prototype.getCurrentResult = function (saveAsLastResult) {
114
103
  if (saveAsLastResult === void 0) { saveAsLastResult = true; }
115
- var _a = this, lastResult = _a.lastResult, _b = _a.options.fetchPolicy, fetchPolicy = _b === void 0 ? "cache-first" : _b;
104
+ var lastResult = this.getLastResult(true);
116
105
  var networkStatus = this.queryInfo.networkStatus ||
117
106
  (lastResult && lastResult.networkStatus) ||
118
107
  exports.NetworkStatus.ready;
119
108
  var result = tslib.__assign(tslib.__assign({}, lastResult), { loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus });
120
109
  if (!this.queryManager.transform(this.options.query).hasForcedResolvers) {
121
110
  var diff = this.queryInfo.getDiff();
122
- result.data = (diff.complete ||
123
- this.options.returnPartialData) ? diff.result : void 0;
111
+ if (diff.complete || this.options.returnPartialData) {
112
+ result.data = diff.result;
113
+ }
114
+ if (equality.equal(result.data, {})) {
115
+ result.data = void 0;
116
+ }
117
+ var _a = this.options.fetchPolicy, fetchPolicy = _a === void 0 ? "cache-first" : _a;
124
118
  if (diff.complete) {
125
119
  if (result.networkStatus === exports.NetworkStatus.loading &&
126
120
  (fetchPolicy === 'cache-first' ||
@@ -133,12 +127,13 @@ var ObservableQuery = (function (_super) {
133
127
  else if (fetchPolicy !== "no-cache") {
134
128
  result.partial = true;
135
129
  }
136
- if (!diff.complete &&
130
+ if (__DEV__ &&
131
+ !diff.complete &&
137
132
  !this.options.partialRefetch &&
138
133
  !result.loading &&
139
134
  !result.data &&
140
135
  !result.error) {
141
- result.error = new errors.ApolloError({ clientErrors: diff.missing });
136
+ logMissingFieldErrors(diff.missing);
142
137
  }
143
138
  }
144
139
  if (saveAsLastResult) {
@@ -147,18 +142,24 @@ var ObservableQuery = (function (_super) {
147
142
  return result;
148
143
  };
149
144
  ObservableQuery.prototype.isDifferentFromLastResult = function (newResult) {
150
- return !equality.equal(this.lastResultSnapshot, newResult);
145
+ return !this.last || !equality.equal(this.last.result, newResult);
151
146
  };
152
- ObservableQuery.prototype.getLastResult = function () {
153
- return this.lastResult;
147
+ ObservableQuery.prototype.getLast = function (key, variablesMustMatch) {
148
+ var last = this.last;
149
+ if (last &&
150
+ last[key] &&
151
+ (!variablesMustMatch || equality.equal(last.variables, this.variables))) {
152
+ return last[key];
153
+ }
154
+ };
155
+ ObservableQuery.prototype.getLastResult = function (variablesMustMatch) {
156
+ return this.getLast("result", variablesMustMatch);
154
157
  };
155
- ObservableQuery.prototype.getLastError = function () {
156
- return this.lastError;
158
+ ObservableQuery.prototype.getLastError = function (variablesMustMatch) {
159
+ return this.getLast("error", variablesMustMatch);
157
160
  };
158
161
  ObservableQuery.prototype.resetLastResults = function () {
159
- delete this.lastResult;
160
- delete this.lastResultSnapshot;
161
- delete this.lastError;
162
+ delete this.last;
162
163
  this.isTornDown = false;
163
164
  };
164
165
  ObservableQuery.prototype.resetQueryStoreErrors = function () {
@@ -271,12 +272,10 @@ var ObservableQuery = (function (_super) {
271
272
  }, exports.NetworkStatus.setVariables);
272
273
  };
273
274
  ObservableQuery.prototype.updateQuery = function (mapFn) {
274
- var _a;
275
275
  var queryManager = this.queryManager;
276
276
  var result = queryManager.cache.diff({
277
277
  query: this.options.query,
278
278
  variables: this.variables,
279
- previousResult: (_a = this.lastResult) === null || _a === void 0 ? void 0 : _a.data,
280
279
  returnPartialData: true,
281
280
  optimistic: false,
282
281
  }).result;
@@ -321,7 +320,7 @@ var ObservableQuery = (function (_super) {
321
320
  pollingInfo.interval === pollInterval) {
322
321
  return;
323
322
  }
324
- __DEV__ ? tsInvariant.invariant(pollInterval, 'Attempted to start a polling query without a polling interval.') : tsInvariant.invariant(pollInterval, 13);
323
+ __DEV__ ? tsInvariant.invariant(pollInterval, 'Attempted to start a polling query without a polling interval.') : tsInvariant.invariant(pollInterval, 12);
325
324
  var info = pollingInfo || (this.pollingInfo = {});
326
325
  info.interval = pollInterval;
327
326
  var maybeFetch = function () {
@@ -345,18 +344,18 @@ var ObservableQuery = (function (_super) {
345
344
  };
346
345
  poll();
347
346
  };
348
- ObservableQuery.prototype.updateLastResult = function (newResult) {
349
- var previousResult = this.lastResult;
350
- this.lastResult = newResult;
351
- this.lastResultSnapshot = this.queryManager.assumeImmutableResults
352
- ? newResult
353
- : utilities.cloneDeep(newResult);
347
+ ObservableQuery.prototype.updateLastResult = function (newResult, variables) {
348
+ if (variables === void 0) { variables = this.variables; }
349
+ this.last = tslib.__assign(tslib.__assign({}, this.last), { result: this.queryManager.assumeImmutableResults
350
+ ? newResult
351
+ : utilities.cloneDeep(newResult), variables: variables });
354
352
  if (!utilities.isNonEmptyArray(newResult.errors)) {
355
- delete this.lastError;
353
+ delete this.last.error;
356
354
  }
357
- return previousResult;
355
+ return this.last;
358
356
  };
359
357
  ObservableQuery.prototype.reobserve = function (newOptions, newNetworkStatus) {
358
+ var _this = this;
360
359
  this.isTornDown = false;
361
360
  var useDisposableConcast = newNetworkStatus === exports.NetworkStatus.refetch ||
362
361
  newNetworkStatus === exports.NetworkStatus.fetchMore ||
@@ -377,18 +376,39 @@ var ObservableQuery = (function (_super) {
377
376
  }
378
377
  }
379
378
  }
379
+ var variables = options.variables && tslib.__assign({}, options.variables);
380
380
  var concast = this.fetch(options, newNetworkStatus);
381
+ var observer = {
382
+ next: function (result) {
383
+ _this.reportResult(result, variables);
384
+ },
385
+ error: function (error) {
386
+ _this.reportError(error, variables);
387
+ },
388
+ };
381
389
  if (!useDisposableConcast) {
382
- if (this.concast) {
390
+ if (this.concast && this.observer) {
383
391
  this.concast.removeObserver(this.observer, true);
384
392
  }
385
393
  this.concast = concast;
394
+ this.observer = observer;
386
395
  }
387
- concast.addObserver(this.observer);
396
+ concast.addObserver(observer);
388
397
  return concast.promise;
389
398
  };
390
399
  ObservableQuery.prototype.observe = function () {
391
- this.observer.next(this.getCurrentResult(false));
400
+ this.reportResult(this.getCurrentResult(false), this.variables);
401
+ };
402
+ ObservableQuery.prototype.reportResult = function (result, variables) {
403
+ if (this.getLastError() || this.isDifferentFromLastResult(result)) {
404
+ this.updateLastResult(result, variables);
405
+ utilities.iterateObserversSafely(this.observers, 'next', result);
406
+ }
407
+ };
408
+ ObservableQuery.prototype.reportError = function (error, variables) {
409
+ var errorResult = tslib.__assign(tslib.__assign({}, this.getLastResult()), { error: error, errors: error.graphQLErrors, networkStatus: exports.NetworkStatus.error, loading: false });
410
+ this.updateLastResult(errorResult, variables);
411
+ utilities.iterateObserversSafely(this.observers, 'error', this.last.error = error);
392
412
  };
393
413
  ObservableQuery.prototype.hasObservers = function () {
394
414
  return this.observers.size > 0;
@@ -396,9 +416,10 @@ var ObservableQuery = (function (_super) {
396
416
  ObservableQuery.prototype.tearDownQuery = function () {
397
417
  if (this.isTornDown)
398
418
  return;
399
- if (this.concast) {
419
+ if (this.concast && this.observer) {
400
420
  this.concast.removeObserver(this.observer);
401
421
  delete this.concast;
422
+ delete this.observer;
402
423
  }
403
424
  this.stopPolling();
404
425
  this.subscriptions.forEach(function (sub) { return sub.unsubscribe(); });
@@ -413,6 +434,11 @@ utilities.fixObservableSubclass(ObservableQuery);
413
434
  function defaultSubscriptionObserverErrorCallback(error) {
414
435
  __DEV__ && tsInvariant.invariant.error('Unhandled error', error.message, error.stack);
415
436
  }
437
+ function logMissingFieldErrors(missing) {
438
+ if (__DEV__ && utilities.isNonEmptyArray(missing)) {
439
+ __DEV__ && tsInvariant.invariant.debug("Missing cache result fields: " + missing.map(function (m) { return m.path.join('.'); }).join(', '), missing);
440
+ }
441
+ }
416
442
  function applyNextFetchPolicy(options) {
417
443
  var _a = options.fetchPolicy, fetchPolicy = _a === void 0 ? "cache-first" : _a, nextFetchPolicy = options.nextFetchPolicy;
418
444
  if (nextFetchPolicy) {
@@ -591,7 +617,7 @@ var LocalState = (function () {
591
617
  }
592
618
  else {
593
619
  fragment = fragmentMap[selection.name.value];
594
- __DEV__ ? tsInvariant.invariant(fragment, "No fragment named " + selection.name.value) : tsInvariant.invariant(fragment, 12);
620
+ __DEV__ ? tsInvariant.invariant(fragment, "No fragment named " + selection.name.value) : tsInvariant.invariant(fragment, 11);
595
621
  }
596
622
  if (fragment && fragment.typeCondition) {
597
623
  typeCondition = fragment.typeCondition.name.value;
@@ -977,29 +1003,31 @@ var QueryManager = (function () {
977
1003
  this.queries.forEach(function (_info, queryId) {
978
1004
  _this.stopQueryNoBroadcast(queryId);
979
1005
  });
980
- this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('QueryManager stopped while query was in flight') : new tsInvariant.InvariantError(14));
1006
+ this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('QueryManager stopped while query was in flight') : new tsInvariant.InvariantError(13));
981
1007
  };
982
1008
  QueryManager.prototype.cancelPendingFetches = function (error) {
983
1009
  this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
984
1010
  this.fetchCancelFns.clear();
985
1011
  };
986
1012
  QueryManager.prototype.mutate = function (_a) {
987
- var mutation = _a.mutation, variables = _a.variables, optimisticResponse = _a.optimisticResponse, updateQueries = _a.updateQueries, _b = _a.refetchQueries, refetchQueries = _b === void 0 ? [] : _b, _c = _a.awaitRefetchQueries, awaitRefetchQueries = _c === void 0 ? false : _c, updateWithProxyFn = _a.update, onQueryUpdated = _a.onQueryUpdated, _d = _a.errorPolicy, errorPolicy = _d === void 0 ? 'none' : _d, fetchPolicy = _a.fetchPolicy, keepRootFields = _a.keepRootFields, context = _a.context;
1013
+ var mutation = _a.mutation, variables = _a.variables, optimisticResponse = _a.optimisticResponse, updateQueries = _a.updateQueries, _b = _a.refetchQueries, refetchQueries = _b === void 0 ? [] : _b, _c = _a.awaitRefetchQueries, awaitRefetchQueries = _c === void 0 ? false : _c, updateWithProxyFn = _a.update, onQueryUpdated = _a.onQueryUpdated, _d = _a.errorPolicy, errorPolicy = _d === void 0 ? 'none' : _d, _e = _a.fetchPolicy, fetchPolicy = _e === void 0 ? 'network-only' : _e, keepRootFields = _a.keepRootFields, context = _a.context;
988
1014
  return tslib.__awaiter(this, void 0, void 0, function () {
989
1015
  var mutationId, mutationStoreValue, self;
990
- return tslib.__generator(this, function (_e) {
991
- switch (_e.label) {
1016
+ return tslib.__generator(this, function (_f) {
1017
+ switch (_f.label) {
992
1018
  case 0:
993
- __DEV__ ? tsInvariant.invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.') : tsInvariant.invariant(mutation, 15);
994
- __DEV__ ? tsInvariant.invariant(!fetchPolicy || fetchPolicy === 'no-cache', "Mutations only support a 'no-cache' fetchPolicy. If you don't want to disable the cache, remove your fetchPolicy setting to proceed with the default mutation behavior.") : tsInvariant.invariant(!fetchPolicy || fetchPolicy === 'no-cache', 16);
1019
+ __DEV__ ? tsInvariant.invariant(mutation, 'mutation option is required. You must specify your GraphQL document in the mutation option.') : tsInvariant.invariant(mutation, 14);
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', 15);
995
1023
  mutationId = this.generateMutationId();
996
1024
  mutation = this.transform(mutation).document;
997
1025
  variables = this.getVariables(mutation, variables);
998
1026
  if (!this.transform(mutation).hasClientExports) return [3, 2];
999
1027
  return [4, this.localState.addExportedVariables(mutation, variables, context)];
1000
1028
  case 1:
1001
- variables = (_e.sent());
1002
- _e.label = 2;
1029
+ variables = (_f.sent());
1030
+ _f.label = 2;
1003
1031
  case 2:
1004
1032
  mutationStoreValue = this.mutationStore &&
1005
1033
  (this.mutationStore[mutationId] = {
@@ -1276,10 +1304,10 @@ var QueryManager = (function () {
1276
1304
  var _this = this;
1277
1305
  if (queryId === void 0) { queryId = this.generateQueryId(); }
1278
1306
  __DEV__ ? tsInvariant.invariant(options.query, 'query option is required. You must specify your GraphQL document ' +
1279
- 'in the query option.') : tsInvariant.invariant(options.query, 17);
1280
- __DEV__ ? tsInvariant.invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.') : tsInvariant.invariant(options.query.kind === 'Document', 18);
1281
- __DEV__ ? tsInvariant.invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.') : tsInvariant.invariant(!options.returnPartialData, 19);
1282
- __DEV__ ? tsInvariant.invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.') : tsInvariant.invariant(!options.pollInterval, 20);
1307
+ 'in the query option.') : tsInvariant.invariant(options.query, 16);
1308
+ __DEV__ ? tsInvariant.invariant(options.query.kind === 'Document', 'You must wrap the query string in a "gql" tag.') : tsInvariant.invariant(options.query.kind === 'Document', 17);
1309
+ __DEV__ ? tsInvariant.invariant(!options.returnPartialData, 'returnPartialData option only supported on watchQuery.') : tsInvariant.invariant(!options.returnPartialData, 18);
1310
+ __DEV__ ? tsInvariant.invariant(!options.pollInterval, 'pollInterval option only supported on watchQuery.') : tsInvariant.invariant(!options.pollInterval, 19);
1283
1311
  return this.fetchQuery(queryId, options).finally(function () { return _this.stopQuery(queryId); });
1284
1312
  };
1285
1313
  QueryManager.prototype.generateQueryId = function () {
@@ -1301,7 +1329,7 @@ var QueryManager = (function () {
1301
1329
  queryInfo.stop();
1302
1330
  };
1303
1331
  QueryManager.prototype.clearStore = function () {
1304
- this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('Store reset while query was in flight (not completed in link chain)') : new tsInvariant.InvariantError(21));
1332
+ this.cancelPendingFetches(__DEV__ ? new tsInvariant.InvariantError('Store reset while query was in flight (not completed in link chain)') : new tsInvariant.InvariantError(20));
1305
1333
  this.queries.forEach(function (queryInfo) {
1306
1334
  if (queryInfo.observableQuery) {
1307
1335
  queryInfo.networkStatus = exports.NetworkStatus.loading;
@@ -1576,7 +1604,7 @@ var QueryManager = (function () {
1576
1604
  return _this.fetchQueryByPolicy(queryInfo, normalized, networkStatus);
1577
1605
  };
1578
1606
  this.fetchCancelFns.set(queryId, function (reason) {
1579
- Promise.resolve().then(function () { return concast.cancel(reason); });
1607
+ setTimeout(function () { return concast.cancel(reason); });
1580
1608
  });
1581
1609
  var concast = new utilities.Concast(this.transform(normalized.query).hasClientExports
1582
1610
  ? this.localState.addExportedVariables(normalized.query, normalized.variables, normalized.context).then(fromVariables)
@@ -1669,10 +1697,9 @@ var QueryManager = (function () {
1669
1697
  if (networkStatus === void 0) { networkStatus = queryInfo.networkStatus || exports.NetworkStatus.loading; }
1670
1698
  var data = diff.result;
1671
1699
  if (__DEV__ &&
1672
- utilities.isNonEmptyArray(diff.missing) &&
1673
- !equality.equal(data, {}) &&
1674
- !returnPartialData) {
1675
- __DEV__ && tsInvariant.invariant.debug("Missing cache result fields: " + diff.missing.map(function (m) { return m.path.join('.'); }).join(', '), diff.missing);
1700
+ !returnPartialData &&
1701
+ !equality.equal(data, {})) {
1702
+ logMissingFieldErrors(diff.missing);
1676
1703
  }
1677
1704
  var fromData = function (data) { return utilities.Observable.of(tslib.__assign({ data: data, loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus }, (diff.complete ? null : { partial: true }))); };
1678
1705
  if (data && _this.transform(query).hasForcedResolvers) {
@@ -1795,7 +1822,7 @@ var ApolloClient = (function () {
1795
1822
  if (!cache) {
1796
1823
  throw __DEV__ ? new tsInvariant.InvariantError("To initialize Apollo Client, you must specify a 'cache' property " +
1797
1824
  "in the options object. \n" +
1798
- "For more information, please visit: https://go.apollo.dev/c/docs") : new tsInvariant.InvariantError(10);
1825
+ "For more information, please visit: https://go.apollo.dev/c/docs") : new tsInvariant.InvariantError(9);
1799
1826
  }
1800
1827
  this.link = link;
1801
1828
  this.cache = cache;
@@ -1891,7 +1918,7 @@ var ApolloClient = (function () {
1891
1918
  __DEV__ ? tsInvariant.invariant(options.fetchPolicy !== 'cache-and-network', 'The cache-and-network fetchPolicy does not work with client.query, because ' +
1892
1919
  'client.query can only return a single result. Please use client.watchQuery ' +
1893
1920
  'to receive multiple results from the cache and the network, or consider ' +
1894
- 'using a different fetchPolicy, such as cache-first or network-only.') : tsInvariant.invariant(options.fetchPolicy !== 'cache-and-network', 11);
1921
+ 'using a different fetchPolicy, such as cache-first or network-only.') : tsInvariant.invariant(options.fetchPolicy !== 'cache-and-network', 10);
1895
1922
  if (this.disableNetworkFetches && options.fetchPolicy === 'network-only') {
1896
1923
  options = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: 'cache-first' });
1897
1924
  }
@@ -2002,6 +2029,7 @@ var ApolloClient = (function () {
2002
2029
  return ApolloClient;
2003
2030
  }());
2004
2031
 
2032
+ utilities.checkDEV();
2005
2033
  tsInvariant.setVerbosity(utilities.DEV ? "log" : "silent");
2006
2034
 
2007
2035
  exports.Observable = utilities.Observable;