@apollo/client 3.8.0-alpha.11 → 3.8.0-alpha.13

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 (205) hide show
  1. package/apollo-client.cjs +594 -397
  2. package/apollo-client.cjs.map +1 -1
  3. package/apollo-client.min.cjs +1 -1
  4. package/core/ApolloClient.d.ts.map +1 -1
  5. package/core/ApolloClient.js.map +1 -1
  6. package/core/ObservableQuery.d.ts +2 -1
  7. package/core/ObservableQuery.d.ts.map +1 -1
  8. package/core/ObservableQuery.js +30 -19
  9. package/core/ObservableQuery.js.map +1 -1
  10. package/core/QueryManager.d.ts +2 -0
  11. package/core/QueryManager.d.ts.map +1 -1
  12. package/core/QueryManager.js +60 -48
  13. package/core/QueryManager.js.map +1 -1
  14. package/core/core.cjs +175 -82
  15. package/core/core.cjs.map +1 -1
  16. package/core/core.cjs.native.js +175 -82
  17. package/core/equalByQuery.d.ts +4 -0
  18. package/core/equalByQuery.d.ts.map +1 -0
  19. package/{react/hooks/compareResults.js → core/equalByQuery.js} +14 -10
  20. package/core/equalByQuery.js.map +1 -0
  21. package/core/index.d.ts +1 -1
  22. package/core/index.d.ts.map +1 -1
  23. package/core/index.js +1 -1
  24. package/core/index.js.map +1 -1
  25. package/errors/errors.cjs +17 -17
  26. package/errors/errors.cjs.map +1 -1
  27. package/errors/errors.cjs.native.js +17 -17
  28. package/errors/index.d.ts +24 -8
  29. package/errors/index.d.ts.map +1 -1
  30. package/errors/index.js +17 -19
  31. package/errors/index.js.map +1 -1
  32. package/invariantErrorCodes.js +29 -34
  33. package/link/batch-http/batch-http.cjs +23 -2
  34. package/link/batch-http/batch-http.cjs.map +1 -1
  35. package/link/batch-http/batch-http.cjs.native.js +23 -2
  36. package/link/batch-http/batchHttpLink.d.ts.map +1 -1
  37. package/link/batch-http/batchHttpLink.js +7 -2
  38. package/link/batch-http/batchHttpLink.js.map +1 -1
  39. package/link/core/types.d.ts +4 -0
  40. package/link/core/types.d.ts.map +1 -1
  41. package/link/core/types.js.map +1 -1
  42. package/link/http/createHttpLink.d.ts.map +1 -1
  43. package/link/http/createHttpLink.js +21 -20
  44. package/link/http/createHttpLink.js.map +1 -1
  45. package/link/http/http.cjs +59 -30
  46. package/link/http/http.cjs.map +1 -1
  47. package/link/http/http.cjs.native.js +59 -30
  48. package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -1
  49. package/link/http/parseAndCheckHttpResponse.js +34 -14
  50. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  51. package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
  52. package/link/http/selectHttpOptionsAndBody.js +2 -1
  53. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  54. package/link/persisted-queries/index.d.ts.map +1 -1
  55. package/link/persisted-queries/index.js +12 -13
  56. package/link/persisted-queries/index.js.map +1 -1
  57. package/link/persisted-queries/persisted-queries.cjs +12 -13
  58. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  59. package/link/persisted-queries/persisted-queries.cjs.native.js +12 -13
  60. package/link/subscriptions/index.d.ts.map +1 -1
  61. package/link/subscriptions/index.js +10 -5
  62. package/link/subscriptions/index.js.map +1 -1
  63. package/link/subscriptions/subscriptions.cjs +9 -4
  64. package/link/subscriptions/subscriptions.cjs.map +1 -1
  65. package/link/subscriptions/subscriptions.cjs.native.js +9 -4
  66. package/link/utils/filterOperationVariables.d.ts +5 -0
  67. package/link/utils/filterOperationVariables.d.ts.map +1 -0
  68. package/link/utils/filterOperationVariables.js +18 -0
  69. package/link/utils/filterOperationVariables.js.map +1 -0
  70. package/link/utils/index.d.ts +1 -0
  71. package/link/utils/index.d.ts.map +1 -1
  72. package/link/utils/index.js +1 -0
  73. package/link/utils/index.js.map +1 -1
  74. package/link/utils/throwServerError.d.ts +1 -1
  75. package/link/utils/throwServerError.d.ts.map +1 -1
  76. package/link/utils/throwServerError.js.map +1 -1
  77. package/link/utils/utils.cjs +18 -0
  78. package/link/utils/utils.cjs.map +1 -1
  79. package/link/utils/utils.cjs.native.js +18 -0
  80. package/package.json +24 -23
  81. package/react/cache/QuerySubscription.d.ts +11 -4
  82. package/react/cache/QuerySubscription.d.ts.map +1 -1
  83. package/react/cache/QuerySubscription.js +53 -35
  84. package/react/cache/QuerySubscription.js.map +1 -1
  85. package/react/cache/SuspenseCache.d.ts +3 -2
  86. package/react/cache/SuspenseCache.d.ts.map +1 -1
  87. package/react/cache/SuspenseCache.js +6 -7
  88. package/react/cache/SuspenseCache.js.map +1 -1
  89. package/react/context/ApolloConsumer.js +1 -1
  90. package/react/context/ApolloProvider.js +1 -1
  91. package/react/context/context.cjs +2 -2
  92. package/react/context/context.cjs.map +1 -1
  93. package/react/context/context.cjs.native.js +2 -2
  94. package/react/hoc/hoc-utils.js +1 -1
  95. package/react/hoc/hoc.cjs +2 -2
  96. package/react/hoc/hoc.cjs.map +1 -1
  97. package/react/hoc/hoc.cjs.native.js +2 -2
  98. package/react/hoc/withApollo.js +1 -1
  99. package/react/hooks/hooks.cjs +118 -146
  100. package/react/hooks/hooks.cjs.map +1 -1
  101. package/react/hooks/hooks.cjs.native.js +118 -146
  102. package/react/hooks/internal/__use.d.ts +3 -1
  103. package/react/hooks/internal/__use.d.ts.map +1 -1
  104. package/react/hooks/internal/__use.js +16 -12
  105. package/react/hooks/internal/__use.js.map +1 -1
  106. package/react/hooks/useApolloClient.js +1 -1
  107. package/react/hooks/useFragment.d.ts +2 -1
  108. package/react/hooks/useFragment.d.ts.map +1 -1
  109. package/react/hooks/useFragment.js.map +1 -1
  110. package/react/hooks/useLazyQuery.d.ts.map +1 -1
  111. package/react/hooks/useLazyQuery.js +13 -22
  112. package/react/hooks/useLazyQuery.js.map +1 -1
  113. package/react/hooks/useQuery.d.ts +3 -3
  114. package/react/hooks/useQuery.d.ts.map +1 -1
  115. package/react/hooks/useQuery.js +26 -25
  116. package/react/hooks/useQuery.js.map +1 -1
  117. package/react/hooks/useSubscription.d.ts.map +1 -1
  118. package/react/hooks/useSubscription.js +25 -13
  119. package/react/hooks/useSubscription.js.map +1 -1
  120. package/react/hooks/useSuspenseCache.js +1 -1
  121. package/react/hooks/useSuspenseQuery.d.ts +15 -3
  122. package/react/hooks/useSuspenseQuery.d.ts.map +1 -1
  123. package/react/hooks/useSuspenseQuery.js +39 -53
  124. package/react/hooks/useSuspenseQuery.js.map +1 -1
  125. package/react/index.d.ts +1 -1
  126. package/react/index.d.ts.map +1 -1
  127. package/react/index.js +1 -1
  128. package/react/index.js.map +1 -1
  129. package/react/parser/index.js +5 -5
  130. package/react/parser/parser.cjs +5 -5
  131. package/react/parser/parser.cjs.map +1 -1
  132. package/react/parser/parser.cjs.native.js +5 -5
  133. package/react/react.cjs +58 -54
  134. package/react/react.cjs.map +1 -1
  135. package/react/react.cjs.native.js +58 -54
  136. package/react/types/types.d.ts +2 -3
  137. package/react/types/types.d.ts.map +1 -1
  138. package/react/types/types.js.map +1 -1
  139. package/testing/core/core.cjs +1 -1
  140. package/testing/core/core.cjs.map +1 -1
  141. package/testing/core/core.cjs.native.js +1 -1
  142. package/testing/core/mocking/mockLink.js +1 -1
  143. package/testing/core/mocking/mockSubscriptionLink.d.ts +1 -1
  144. package/testing/react/MockedProvider.d.ts +1 -1
  145. package/testing/react/MockedProvider.d.ts.map +1 -1
  146. package/testing/react/MockedProvider.js +7 -6
  147. package/testing/react/MockedProvider.js.map +1 -1
  148. package/testing/testing.cjs +8 -124
  149. package/testing/testing.cjs.map +1 -1
  150. package/testing/testing.cjs.native.js +8 -124
  151. package/utilities/common/incrementalResult.d.ts +2 -1
  152. package/utilities/common/incrementalResult.d.ts.map +1 -1
  153. package/utilities/common/incrementalResult.js +4 -0
  154. package/utilities/common/incrementalResult.js.map +1 -1
  155. package/utilities/common/mergeOptions.d.ts +1 -1
  156. package/utilities/common/mergeOptions.d.ts.map +1 -1
  157. package/utilities/common/mergeOptions.js.map +1 -1
  158. package/utilities/common/objects.d.ts +1 -0
  159. package/utilities/common/objects.d.ts.map +1 -1
  160. package/utilities/common/objects.js +6 -0
  161. package/utilities/common/objects.js.map +1 -1
  162. package/utilities/common/omitDeep.d.ts +3 -0
  163. package/utilities/common/omitDeep.d.ts.map +1 -0
  164. package/utilities/common/omitDeep.js +42 -0
  165. package/utilities/common/omitDeep.js.map +1 -0
  166. package/utilities/common/stripTypename.d.ts +2 -0
  167. package/utilities/common/stripTypename.d.ts.map +1 -0
  168. package/utilities/common/stripTypename.js +5 -0
  169. package/utilities/common/stripTypename.js.map +1 -0
  170. package/utilities/graphql/directives.js +4 -4
  171. package/utilities/graphql/fragments.js +3 -3
  172. package/utilities/graphql/getFromAST.js +8 -8
  173. package/utilities/graphql/storeUtils.d.ts.map +1 -1
  174. package/utilities/graphql/storeUtils.js +2 -1
  175. package/utilities/graphql/storeUtils.js.map +1 -1
  176. package/utilities/graphql/transform.d.ts.map +1 -1
  177. package/utilities/graphql/transform.js +26 -16
  178. package/utilities/graphql/transform.js.map +1 -1
  179. package/utilities/index.d.ts +5 -0
  180. package/utilities/index.d.ts.map +1 -1
  181. package/utilities/index.js +3 -0
  182. package/utilities/index.js.map +1 -1
  183. package/utilities/promises/decoration.d.ts +2 -0
  184. package/utilities/promises/decoration.d.ts.map +1 -1
  185. package/utilities/promises/decoration.js +12 -0
  186. package/utilities/promises/decoration.js.map +1 -1
  187. package/utilities/types/DeepOmit.d.ts +10 -0
  188. package/utilities/types/DeepOmit.d.ts.map +1 -0
  189. package/utilities/types/DeepOmit.js +2 -0
  190. package/utilities/types/DeepOmit.js.map +1 -0
  191. package/utilities/types/DeepPartial.d.ts +12 -0
  192. package/utilities/types/DeepPartial.d.ts.map +1 -0
  193. package/utilities/types/DeepPartial.js +2 -0
  194. package/utilities/types/DeepPartial.js.map +1 -0
  195. package/utilities/types/Primitive.d.ts +2 -0
  196. package/utilities/types/Primitive.d.ts.map +1 -0
  197. package/utilities/types/Primitive.js +2 -0
  198. package/utilities/types/Primitive.js.map +1 -0
  199. package/utilities/utilities.cjs +141 -31
  200. package/utilities/utilities.cjs.map +1 -1
  201. package/utilities/utilities.cjs.native.js +141 -31
  202. package/version.js +1 -1
  203. package/react/hooks/compareResults.d.ts +0 -3
  204. package/react/hooks/compareResults.d.ts.map +0 -1
  205. package/react/hooks/compareResults.js.map +0 -1
package/core/core.cjs CHANGED
@@ -6,7 +6,7 @@ var globals = require('../utilities/globals');
6
6
  var tslib = require('tslib');
7
7
  var core = require('../link/core');
8
8
  var http = require('../link/http');
9
- var equality = require('@wry/equality');
9
+ var equal = require('@wry/equality');
10
10
  var utilities = require('../utilities');
11
11
  var cache = require('../cache');
12
12
  var errors = require('../errors');
@@ -15,16 +15,20 @@ 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.11';
18
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
19
19
 
20
- function isNonEmptyArray(value) {
21
- return Array.isArray(value) && value.length > 0;
22
- }
20
+ var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
21
+
22
+ var version = '3.8.0-alpha.13';
23
23
 
24
24
  function isNonNullObject(obj) {
25
25
  return obj !== null && typeof obj === 'object';
26
26
  }
27
27
 
28
+ function isNonEmptyArray(value) {
29
+ return Array.isArray(value) && value.length > 0;
30
+ }
31
+
28
32
  var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
29
33
  var defaultReconciler = function (target, source, property) {
30
34
  return this.merge(target[property], source[property]);
@@ -116,6 +120,73 @@ exports.NetworkStatus = void 0;
116
120
  function isNetworkRequestInFlight(networkStatus) {
117
121
  return networkStatus ? networkStatus < 7 : false;
118
122
  }
123
+ function isNetworkRequestSettled(networkStatus) {
124
+ return networkStatus === 7 || networkStatus === 8;
125
+ }
126
+
127
+ function equalByQuery(query, _a, _b, variables) {
128
+ var aData = _a.data, aRest = tslib.__rest(_a, ["data"]);
129
+ var bData = _b.data, bRest = tslib.__rest(_b, ["data"]);
130
+ return equal__default(aRest, bRest) && equalBySelectionSet(utilities.getMainDefinition(query).selectionSet, aData, bData, {
131
+ fragmentMap: utilities.createFragmentMap(utilities.getFragmentDefinitions(query)),
132
+ variables: variables,
133
+ });
134
+ }
135
+ function equalBySelectionSet(selectionSet, aResult, bResult, context) {
136
+ if (aResult === bResult) {
137
+ return true;
138
+ }
139
+ var seenSelections = new Set();
140
+ return selectionSet.selections.every(function (selection) {
141
+ if (seenSelections.has(selection))
142
+ return true;
143
+ seenSelections.add(selection);
144
+ if (!utilities.shouldInclude(selection, context.variables))
145
+ return true;
146
+ if (selectionHasNonreactiveDirective(selection))
147
+ return true;
148
+ if (utilities.isField(selection)) {
149
+ var resultKey = utilities.resultKeyNameFromField(selection);
150
+ var aResultChild = aResult && aResult[resultKey];
151
+ var bResultChild = bResult && bResult[resultKey];
152
+ var childSelectionSet = selection.selectionSet;
153
+ if (!childSelectionSet) {
154
+ return equal__default(aResultChild, bResultChild);
155
+ }
156
+ var aChildIsArray = Array.isArray(aResultChild);
157
+ var bChildIsArray = Array.isArray(bResultChild);
158
+ if (aChildIsArray !== bChildIsArray)
159
+ return false;
160
+ if (aChildIsArray && bChildIsArray) {
161
+ var length_1 = aResultChild.length;
162
+ if (bResultChild.length !== length_1) {
163
+ return false;
164
+ }
165
+ for (var i = 0; i < length_1; ++i) {
166
+ if (!equalBySelectionSet(childSelectionSet, aResultChild[i], bResultChild[i], context)) {
167
+ return false;
168
+ }
169
+ }
170
+ return true;
171
+ }
172
+ return equalBySelectionSet(childSelectionSet, aResultChild, bResultChild, context);
173
+ }
174
+ else {
175
+ var fragment = utilities.getFragmentFromSelection(selection, context.fragmentMap);
176
+ if (fragment) {
177
+ if (selectionHasNonreactiveDirective(fragment))
178
+ return true;
179
+ return equalBySelectionSet(fragment.selectionSet, aResult, bResult, context);
180
+ }
181
+ }
182
+ });
183
+ }
184
+ function selectionHasNonreactiveDirective(selection) {
185
+ return !!selection.directives && selection.directives.some(directiveIsNonreactive);
186
+ }
187
+ function directiveIsNonreactive(dir) {
188
+ return dir.name.value === "nonreactive";
189
+ }
119
190
 
120
191
  var assign = Object.assign, hasOwnProperty$1 = Object.hasOwnProperty;
121
192
  var ObservableQuery = (function (_super) {
@@ -211,7 +282,7 @@ var ObservableQuery = (function (_super) {
211
282
  if (diff.complete || this.options.returnPartialData) {
212
283
  result.data = diff.result;
213
284
  }
214
- if (equality.equal(result.data, {})) {
285
+ if (equal.equal(result.data, {})) {
215
286
  result.data = void 0;
216
287
  }
217
288
  if (diff.complete) {
@@ -242,15 +313,21 @@ var ObservableQuery = (function (_super) {
242
313
  return result;
243
314
  };
244
315
  ObservableQuery.prototype.isDifferentFromLastResult = function (newResult, variables) {
245
- return (!this.last ||
246
- !equality.equal(this.last.result, newResult) ||
247
- (variables && !equality.equal(this.last.variables, variables)));
316
+ if (!this.last) {
317
+ return true;
318
+ }
319
+ var query = this.options.query;
320
+ var resultIsDifferent = this.queryManager.transform(query).hasNonreactiveDirective
321
+ ? !equalByQuery(query, this.last.result, newResult, this.variables)
322
+ : !equal.equal(this.last.result, newResult);
323
+ return (resultIsDifferent ||
324
+ (variables && !equal.equal(this.last.variables, variables)));
248
325
  };
249
326
  ObservableQuery.prototype.getLast = function (key, variablesMustMatch) {
250
327
  var last = this.last;
251
328
  if (last &&
252
329
  last[key] &&
253
- (!variablesMustMatch || equality.equal(last.variables, this.variables))) {
330
+ (!variablesMustMatch || equal.equal(last.variables, this.variables))) {
254
331
  return last[key];
255
332
  }
256
333
  };
@@ -289,7 +366,7 @@ var ObservableQuery = (function (_super) {
289
366
  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 })?"));
290
367
  }
291
368
  }
292
- if (variables && !equality.equal(this.options.variables, variables)) {
369
+ if (variables && !equal.equal(this.options.variables, variables)) {
293
370
  reobserveOptions.variables = this.options.variables = tslib.__assign(tslib.__assign({}, this.options.variables), variables);
294
371
  }
295
372
  this.queryInfo.resetLastWrite();
@@ -384,7 +461,7 @@ var ObservableQuery = (function (_super) {
384
461
  return this.reobserve(newOptions);
385
462
  };
386
463
  ObservableQuery.prototype.setVariables = function (variables) {
387
- if (equality.equal(this.variables, variables)) {
464
+ if (equal.equal(this.variables, variables)) {
388
465
  return this.observers.size
389
466
  ? this.result()
390
467
  : Promise.resolve();
@@ -449,7 +526,7 @@ var ObservableQuery = (function (_super) {
449
526
  };
450
527
  ObservableQuery.prototype.fetch = function (options, newNetworkStatus) {
451
528
  this.queryManager.setObservableQuery(this);
452
- return this.queryManager.fetchQueryObservable(this.queryId, options, newNetworkStatus);
529
+ return this.queryManager['fetchConcastWithInfo'](this.queryId, options, newNetworkStatus);
453
530
  };
454
531
  ObservableQuery.prototype.updatePolling = function () {
455
532
  var _this = this;
@@ -494,15 +571,15 @@ var ObservableQuery = (function (_super) {
494
571
  };
495
572
  ObservableQuery.prototype.updateLastResult = function (newResult, variables) {
496
573
  if (variables === void 0) { variables = this.variables; }
497
- this.last = tslib.__assign(tslib.__assign({}, this.last), { result: this.queryManager.assumeImmutableResults
498
- ? newResult
499
- : utilities.cloneDeep(newResult), variables: variables });
500
- if (!utilities.isNonEmptyArray(newResult.errors)) {
501
- delete this.last.error;
574
+ var error = this.getLastError();
575
+ if (error && this.last && !equal.equal(variables, this.last.variables)) {
576
+ error = void 0;
502
577
  }
503
- return this.last;
578
+ return this.last = tslib.__assign({ result: this.queryManager.assumeImmutableResults
579
+ ? newResult
580
+ : utilities.cloneDeep(newResult), variables: variables }, (error ? { error: error } : null));
504
581
  };
505
- ObservableQuery.prototype.reobserve = function (newOptions, newNetworkStatus) {
582
+ ObservableQuery.prototype.reobserveAsConcast = function (newOptions, newNetworkStatus) {
506
583
  var _this = this;
507
584
  this.isTornDown = false;
508
585
  var useDisposableConcast = newNetworkStatus === exports.NetworkStatus.refetch ||
@@ -518,7 +595,7 @@ var ObservableQuery = (function (_super) {
518
595
  this.updatePolling();
519
596
  if (newOptions &&
520
597
  newOptions.variables &&
521
- !equality.equal(newOptions.variables, oldVariables) &&
598
+ !equal.equal(newOptions.variables, oldVariables) &&
522
599
  options.fetchPolicy !== "standby" &&
523
600
  options.fetchPolicy === oldFetchPolicy) {
524
601
  this.applyNextFetchPolicy("variables-changed", options);
@@ -528,7 +605,7 @@ var ObservableQuery = (function (_super) {
528
605
  }
529
606
  }
530
607
  var variables = options.variables && tslib.__assign({}, options.variables);
531
- var concast = this.fetch(options, newNetworkStatus);
608
+ var _a = this.fetch(options, newNetworkStatus), concast = _a.concast, fromLink = _a.fromLink;
532
609
  var observer = {
533
610
  next: function (result) {
534
611
  _this.reportResult(result, variables);
@@ -537,7 +614,7 @@ var ObservableQuery = (function (_super) {
537
614
  _this.reportError(error, variables);
538
615
  },
539
616
  };
540
- if (!useDisposableConcast) {
617
+ if (!useDisposableConcast && (fromLink || !this.concast)) {
541
618
  if (this.concast && this.observer) {
542
619
  this.concast.removeObserver(this.observer);
543
620
  }
@@ -545,18 +622,22 @@ var ObservableQuery = (function (_super) {
545
622
  this.observer = observer;
546
623
  }
547
624
  concast.addObserver(observer);
548
- return concast.promise;
625
+ return concast;
626
+ };
627
+ ObservableQuery.prototype.reobserve = function (newOptions, newNetworkStatus) {
628
+ return this.reobserveAsConcast(newOptions, newNetworkStatus).promise;
549
629
  };
550
630
  ObservableQuery.prototype.observe = function () {
551
631
  this.reportResult(this.getCurrentResult(false), this.variables);
552
632
  };
553
633
  ObservableQuery.prototype.reportResult = function (result, variables) {
554
634
  var lastError = this.getLastError();
555
- if (lastError || this.isDifferentFromLastResult(result, variables)) {
556
- if (lastError || !result.partial || this.options.returnPartialData) {
557
- this.updateLastResult(result, variables);
558
- }
559
- utilities.iterateObserversSafely(this.observers, 'next', result);
635
+ var isDifferent = this.isDifferentFromLastResult(result, variables);
636
+ if (lastError || !result.partial || this.options.returnPartialData) {
637
+ this.updateLastResult(result, variables);
638
+ }
639
+ if (lastError || isDifferent) {
640
+ utilities.iterateObserversSafely(this.observers, "next", result);
560
641
  }
561
642
  };
562
643
  ObservableQuery.prototype.reportError = function (error, variables) {
@@ -965,10 +1046,10 @@ var QueryInfo = (function () {
965
1046
  var networkStatus = query.networkStatus || exports.NetworkStatus.loading;
966
1047
  if (this.variables &&
967
1048
  this.networkStatus !== exports.NetworkStatus.loading &&
968
- !equality.equal(this.variables, query.variables)) {
1049
+ !equal.equal(this.variables, query.variables)) {
969
1050
  networkStatus = exports.NetworkStatus.setVariables;
970
1051
  }
971
- if (!equality.equal(query.variables, this.variables)) {
1052
+ if (!equal.equal(query.variables, this.variables)) {
972
1053
  this.lastDiff = void 0;
973
1054
  }
974
1055
  Object.assign(this, {
@@ -993,7 +1074,7 @@ var QueryInfo = (function () {
993
1074
  QueryInfo.prototype.getDiff = function (variables) {
994
1075
  if (variables === void 0) { variables = this.variables; }
995
1076
  var options = this.getDiffOptions(variables);
996
- if (this.lastDiff && equality.equal(options, this.lastDiff.options)) {
1077
+ if (this.lastDiff && equal.equal(options, this.lastDiff.options)) {
997
1078
  return this.lastDiff.diff;
998
1079
  }
999
1080
  this.updateWatch(this.variables = variables);
@@ -1027,7 +1108,7 @@ var QueryInfo = (function () {
1027
1108
  var oldDiff = this.lastDiff && this.lastDiff.diff;
1028
1109
  this.updateLastDiff(diff);
1029
1110
  if (!this.dirty &&
1030
- !equality.equal(oldDiff && oldDiff.result, diff && diff.result)) {
1111
+ !equal.equal(oldDiff && oldDiff.result, diff && diff.result)) {
1031
1112
  this.dirty = true;
1032
1113
  if (!this.notifyTimeout) {
1033
1114
  this.notifyTimeout = setTimeout(function () { return _this.notify(); }, 0);
@@ -1102,7 +1183,7 @@ var QueryInfo = (function () {
1102
1183
  }
1103
1184
  var watchOptions = tslib.__assign(tslib.__assign({}, this.getDiffOptions(variables)), { watcher: this, callback: function (diff) { return _this.setDiff(diff); } });
1104
1185
  if (!this.lastWatch ||
1105
- !equality.equal(watchOptions, this.lastWatch)) {
1186
+ !equal.equal(watchOptions, this.lastWatch)) {
1106
1187
  this.cancel();
1107
1188
  this.cancel = this.cache.watch(this.lastWatch = watchOptions);
1108
1189
  }
@@ -1114,8 +1195,8 @@ var QueryInfo = (function () {
1114
1195
  var lastWrite = this.lastWrite;
1115
1196
  return !(lastWrite &&
1116
1197
  lastWrite.dmCount === destructiveMethodCounts.get(this.cache) &&
1117
- equality.equal(variables, lastWrite.variables) &&
1118
- equality.equal(result.data, lastWrite.result.data));
1198
+ equal.equal(variables, lastWrite.variables) &&
1199
+ equal.equal(result.data, lastWrite.result.data));
1119
1200
  };
1120
1201
  QueryInfo.prototype.markResult = function (result, document, options, cacheWriteBehavior) {
1121
1202
  var _this = this;
@@ -1517,14 +1598,17 @@ var QueryManager = (function () {
1517
1598
  var _a = (this.defaultOptions.transformQuery || Object.create(null)).removeClientFields, removeClientFields = _a === void 0 ? true : _a;
1518
1599
  if (!transformCache.has(document)) {
1519
1600
  var transformed = this.cache.transformDocument(document);
1520
- var noConnection = utilities.removeConnectionDirectiveFromDocument(transformed);
1601
+ var serverQuery = utilities.removeDirectivesFromDocument([
1602
+ removeClientFields ? { name: 'client', remove: true } : {},
1603
+ { name: 'connection' },
1604
+ { name: 'nonreactive' },
1605
+ ], transformed);
1521
1606
  var clientQuery = this.localState.clientQuery(transformed);
1522
- var serverQuery = noConnection &&
1523
- this.localState.serverQuery(noConnection, { removeClientFields: removeClientFields });
1524
1607
  var cacheEntry_1 = {
1525
1608
  document: transformed,
1526
1609
  hasClientExports: utilities.hasClientExports(transformed),
1527
1610
  hasForcedResolvers: this.localState.shouldForceResolvers(transformed),
1611
+ hasNonreactiveDirective: utilities.hasDirectives(['nonreactive'], transformed),
1528
1612
  clientQuery: clientQuery,
1529
1613
  serverQuery: serverQuery,
1530
1614
  defaultVars: utilities.getDefaultValues(utilities.getOperationDefinition(transformed)),
@@ -1722,10 +1806,17 @@ var QueryManager = (function () {
1722
1806
  }
1723
1807
  _this.broadcastQueries();
1724
1808
  }
1725
- if (utilities.graphQLResultHasError(result)) {
1726
- throw new errors.ApolloError({
1727
- graphQLErrors: result.errors,
1728
- });
1809
+ var hasErrors = utilities.graphQLResultHasError(result);
1810
+ var hasProtocolErrors = errors.graphQLResultHasProtocolErrors(result);
1811
+ if (hasErrors || hasProtocolErrors) {
1812
+ var errors$1 = {};
1813
+ if (hasErrors) {
1814
+ errors$1.graphQLErrors = result.errors;
1815
+ }
1816
+ if (hasProtocolErrors) {
1817
+ errors$1.protocolErrors = result.extensions[errors.PROTOCOL_ERRORS_SYMBOL];
1818
+ }
1819
+ throw new errors.ApolloError(errors$1);
1729
1820
  }
1730
1821
  return result;
1731
1822
  });
@@ -1857,6 +1948,9 @@ var QueryManager = (function () {
1857
1948
  });
1858
1949
  };
1859
1950
  QueryManager.prototype.fetchQueryObservable = function (queryId, options, networkStatus) {
1951
+ return this.fetchConcastWithInfo(queryId, options, networkStatus).concast;
1952
+ };
1953
+ QueryManager.prototype.fetchConcastWithInfo = function (queryId, options, networkStatus) {
1860
1954
  var _this = this;
1861
1955
  if (networkStatus === void 0) { networkStatus = exports.NetworkStatus.loading; }
1862
1956
  var query = this.transform(options.query).document;
@@ -1875,24 +1969,36 @@ var QueryManager = (function () {
1875
1969
  });
1876
1970
  var fromVariables = function (variables) {
1877
1971
  normalized.variables = variables;
1878
- var concastSources = _this.fetchQueryByPolicy(queryInfo, normalized, networkStatus);
1972
+ var sourcesWithInfo = _this.fetchQueryByPolicy(queryInfo, normalized, networkStatus);
1879
1973
  if (normalized.fetchPolicy !== "standby" &&
1880
- concastSources.length > 0 &&
1974
+ sourcesWithInfo.sources.length > 0 &&
1881
1975
  queryInfo.observableQuery) {
1882
1976
  queryInfo.observableQuery["applyNextFetchPolicy"]("after-fetch", options);
1883
1977
  }
1884
- return concastSources;
1978
+ return sourcesWithInfo;
1885
1979
  };
1886
1980
  var cleanupCancelFn = function () { return _this.fetchCancelFns.delete(queryId); };
1887
1981
  this.fetchCancelFns.set(queryId, function (reason) {
1888
1982
  cleanupCancelFn();
1889
1983
  setTimeout(function () { return concast.cancel(reason); });
1890
1984
  });
1891
- var concast = new utilities.Concast(this.transform(normalized.query).hasClientExports
1892
- ? this.localState.addExportedVariables(normalized.query, normalized.variables, normalized.context).then(fromVariables)
1893
- : fromVariables(normalized.variables));
1985
+ var concast, containsDataFromLink;
1986
+ if (this.transform(normalized.query).hasClientExports) {
1987
+ concast = new utilities.Concast(this.localState
1988
+ .addExportedVariables(normalized.query, normalized.variables, normalized.context)
1989
+ .then(fromVariables).then(function (sourcesWithInfo) { return sourcesWithInfo.sources; }));
1990
+ containsDataFromLink = true;
1991
+ }
1992
+ else {
1993
+ var sourcesWithInfo = fromVariables(normalized.variables);
1994
+ containsDataFromLink = sourcesWithInfo.fromLink;
1995
+ concast = new utilities.Concast(sourcesWithInfo.sources);
1996
+ }
1894
1997
  concast.promise.then(cleanupCancelFn, cleanupCancelFn);
1895
- return concast;
1998
+ return {
1999
+ concast: concast,
2000
+ fromLink: containsDataFromLink,
2001
+ };
1896
2002
  };
1897
2003
  QueryManager.prototype.refetchQueries = function (_a) {
1898
2004
  var _this = this;
@@ -1977,7 +2083,7 @@ var QueryManager = (function () {
1977
2083
  var data = diff.result;
1978
2084
  if (globals.__DEV__ &&
1979
2085
  !returnPartialData &&
1980
- !equality.equal(data, {})) {
2086
+ !equal.equal(data, {})) {
1981
2087
  logMissingFieldErrors(diff.missing);
1982
2088
  }
1983
2089
  var fromData = function (data) { return utilities.Observable.of(tslib.__assign({ data: data, loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus }, (diff.complete ? null : { partial: true }))); };
@@ -2016,54 +2122,40 @@ var QueryManager = (function () {
2016
2122
  case "cache-first": {
2017
2123
  var diff = readCache();
2018
2124
  if (diff.complete) {
2019
- return [
2020
- resultsFromCache(diff, queryInfo.markReady()),
2021
- ];
2125
+ return { fromLink: false, sources: [resultsFromCache(diff, queryInfo.markReady())] };
2022
2126
  }
2023
2127
  if (returnPartialData || shouldNotify) {
2024
- return [
2025
- resultsFromCache(diff),
2026
- resultsFromLink(),
2027
- ];
2128
+ return { fromLink: true, sources: [resultsFromCache(diff), resultsFromLink()] };
2028
2129
  }
2029
- return [
2030
- resultsFromLink(),
2031
- ];
2130
+ return { fromLink: true, sources: [resultsFromLink()] };
2032
2131
  }
2033
2132
  case "cache-and-network": {
2034
2133
  var diff = readCache();
2035
2134
  if (diff.complete || returnPartialData || shouldNotify) {
2036
- return [
2037
- resultsFromCache(diff),
2038
- resultsFromLink(),
2039
- ];
2135
+ return { fromLink: true, sources: [resultsFromCache(diff), resultsFromLink()] };
2040
2136
  }
2041
- return [
2042
- resultsFromLink(),
2043
- ];
2137
+ return { fromLink: true, sources: [resultsFromLink()] };
2044
2138
  }
2045
2139
  case "cache-only":
2046
- return [
2047
- resultsFromCache(readCache(), queryInfo.markReady()),
2048
- ];
2140
+ return { fromLink: false, sources: [resultsFromCache(readCache(), queryInfo.markReady())] };
2049
2141
  case "network-only":
2050
2142
  if (shouldNotify) {
2051
- return [
2052
- resultsFromCache(readCache()),
2053
- resultsFromLink(),
2054
- ];
2143
+ return { fromLink: true, sources: [resultsFromCache(readCache()), resultsFromLink()] };
2055
2144
  }
2056
- return [resultsFromLink()];
2145
+ return { fromLink: true, sources: [resultsFromLink()] };
2057
2146
  case "no-cache":
2058
2147
  if (shouldNotify) {
2059
- return [
2060
- resultsFromCache(queryInfo.getDiff()),
2061
- resultsFromLink(),
2062
- ];
2148
+ return {
2149
+ fromLink: true,
2150
+ sources: [
2151
+ resultsFromCache(queryInfo.getDiff()),
2152
+ resultsFromLink(),
2153
+ ],
2154
+ };
2063
2155
  }
2064
- return [resultsFromLink()];
2156
+ return { fromLink: true, sources: [resultsFromLink()] };
2065
2157
  case "standby":
2066
- return [];
2158
+ return { fromLink: false, sources: [] };
2067
2159
  }
2068
2160
  };
2069
2161
  QueryManager.prototype.getQuery = function (queryId) {
@@ -2342,6 +2434,7 @@ exports.gql = graphqlTag.gql;
2342
2434
  exports.resetCaches = graphqlTag.resetCaches;
2343
2435
  exports.ApolloClient = ApolloClient;
2344
2436
  exports.ObservableQuery = ObservableQuery;
2437
+ exports.isNetworkRequestSettled = isNetworkRequestSettled;
2345
2438
  for (var k in core) {
2346
2439
  if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = core[k];
2347
2440
  }