@apollo/client 3.6.0-beta.9 → 3.6.0-rc.0

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 (60) hide show
  1. package/apollo-client.cjs +297 -238
  2. package/apollo-client.cjs.map +1 -1
  3. package/apollo-client.min.cjs +1 -1
  4. package/core/ApolloClient.d.ts +1 -1
  5. package/core/ApolloClient.d.ts.map +1 -1
  6. package/core/ApolloClient.js.map +1 -1
  7. package/core/ObservableQuery.d.ts +7 -2
  8. package/core/ObservableQuery.d.ts.map +1 -1
  9. package/core/ObservableQuery.js +67 -36
  10. package/core/ObservableQuery.js.map +1 -1
  11. package/core/QueryInfo.d.ts.map +1 -1
  12. package/core/QueryInfo.js +4 -2
  13. package/core/QueryInfo.js.map +1 -1
  14. package/core/QueryManager.d.ts.map +1 -1
  15. package/core/QueryManager.js +23 -6
  16. package/core/QueryManager.js.map +1 -1
  17. package/core/core.cjs +92 -44
  18. package/core/core.cjs.map +1 -1
  19. package/core/watchQueryOptions.d.ts +3 -1
  20. package/core/watchQueryOptions.d.ts.map +1 -1
  21. package/core/watchQueryOptions.js.map +1 -1
  22. package/invariantErrorCodes.js +1 -1
  23. package/package.json +15 -13
  24. package/react/hooks/hooks.cjs +186 -176
  25. package/react/hooks/hooks.cjs.map +1 -1
  26. package/react/hooks/index.d.ts +1 -1
  27. package/react/hooks/index.d.ts.map +1 -1
  28. package/react/hooks/index.js +1 -1
  29. package/react/hooks/index.js.map +1 -1
  30. package/react/hooks/useLazyQuery.d.ts +2 -2
  31. package/react/hooks/useLazyQuery.d.ts.map +1 -1
  32. package/react/hooks/useLazyQuery.js +38 -24
  33. package/react/hooks/useLazyQuery.js.map +1 -1
  34. package/react/hooks/useMutation.js.map +1 -1
  35. package/react/hooks/useQuery.d.ts +34 -3
  36. package/react/hooks/useQuery.d.ts.map +1 -1
  37. package/react/hooks/useQuery.js +152 -134
  38. package/react/hooks/useQuery.js.map +1 -1
  39. package/react/ssr/RenderPromises.d.ts +2 -1
  40. package/react/ssr/RenderPromises.d.ts.map +1 -1
  41. package/react/ssr/RenderPromises.js +23 -1
  42. package/react/ssr/RenderPromises.js.map +1 -1
  43. package/react/ssr/ssr.cjs +23 -1
  44. package/react/ssr/ssr.cjs.map +1 -1
  45. package/react/types/types.d.ts +9 -13
  46. package/react/types/types.d.ts.map +1 -1
  47. package/react/types/types.js.map +1 -1
  48. package/testing/core/mocking/mockFetch.js +1 -1
  49. package/testing/core/mocking/mockFetch.js.map +1 -1
  50. package/utilities/graphql/transform.d.ts +2 -2
  51. package/utilities/graphql/transform.d.ts.map +1 -1
  52. package/utilities/graphql/transform.js +1 -1
  53. package/utilities/graphql/transform.js.map +1 -1
  54. package/utilities/utilities.cjs +1 -1
  55. package/utilities/utilities.cjs.map +1 -1
  56. package/version.js +1 -1
  57. package/react/hooks/options.d.ts +0 -3
  58. package/react/hooks/options.d.ts.map +0 -1
  59. package/react/hooks/options.js +0 -20
  60. package/react/hooks/options.js.map +0 -1
package/apollo-client.cjs CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var tslib = require('tslib');
6
6
  var tsInvariant = require('ts-invariant');
7
- var equal = require('@wry/equality');
7
+ var equality = require('@wry/equality');
8
8
  var zenObservableTs = require('zen-observable-ts');
9
9
  require('symbol-observable');
10
10
  var graphql = require('graphql');
@@ -13,8 +13,7 @@ var context = require('@wry/context');
13
13
  var trie = require('@wry/trie');
14
14
  var graphqlTag = require('graphql-tag');
15
15
  var React = require('react');
16
-
17
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
16
+ var index_js = require('use-sync-external-store/shim/index.js');
18
17
 
19
18
  function _interopNamespace(e) {
20
19
  if (e && e.__esModule) return e;
@@ -28,7 +27,6 @@ function _interopNamespace(e) {
28
27
  return Object.freeze(n);
29
28
  }
30
29
 
31
- var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
32
30
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
33
31
 
34
32
  function maybe(thunk) {
@@ -542,7 +540,7 @@ function removeDirectivesFromDocument(directives, doc) {
542
540
  return modifiedDoc;
543
541
  }
544
542
  var addTypenameToDocument = Object.assign(function (doc) {
545
- return graphql.visit(checkDocument(doc), {
543
+ return graphql.visit(doc, {
546
544
  SelectionSet: {
547
545
  enter: function (node, _key, parent) {
548
546
  if (parent &&
@@ -1294,7 +1292,7 @@ var concat = ApolloLink.concat;
1294
1292
 
1295
1293
  var execute = ApolloLink.execute;
1296
1294
 
1297
- var version = '3.6.0-beta.9';
1295
+ var version = '3.6.0-rc.0';
1298
1296
 
1299
1297
  var hasOwnProperty$3 = Object.prototype.hasOwnProperty;
1300
1298
  function parseAndCheckHttpResponse(operations) {
@@ -2162,7 +2160,7 @@ var Layer = (function (_super) {
2162
2160
  }
2163
2161
  else if (ownStoreObject !== parentStoreObject) {
2164
2162
  Object.keys(ownStoreObject).forEach(function (storeFieldName) {
2165
- if (!equal.equal(ownStoreObject[storeFieldName], parentStoreObject[storeFieldName])) {
2163
+ if (!equality.equal(ownStoreObject[storeFieldName], parentStoreObject[storeFieldName])) {
2166
2164
  _this.group.dirty(dataId, storeFieldName);
2167
2165
  }
2168
2166
  });
@@ -2206,7 +2204,7 @@ var Stump = (function (_super) {
2206
2204
  function storeObjectReconciler(existingObject, incomingObject, property) {
2207
2205
  var existingValue = existingObject[property];
2208
2206
  var incomingValue = incomingObject[property];
2209
- return equal.equal(existingValue, incomingValue) ? existingValue : incomingValue;
2207
+ return equality.equal(existingValue, incomingValue) ? existingValue : incomingValue;
2210
2208
  }
2211
2209
  function supportsResultCaching(store) {
2212
2210
  return !!(store instanceof EntityStore && store.group.caching);
@@ -3536,7 +3534,7 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
3536
3534
  return;
3537
3535
  if (isReference(existing))
3538
3536
  return;
3539
- if (equal.equal(existing, incoming))
3537
+ if (equality.equal(existing, incoming))
3540
3538
  return;
3541
3539
  if (Object.keys(existing).every(function (key) { return store.getFieldValue(incoming, key) !== void 0; })) {
3542
3540
  return;
@@ -3850,7 +3848,7 @@ var InMemoryCache = (function (_super) {
3850
3848
  return;
3851
3849
  }
3852
3850
  }
3853
- if (!lastDiff || !equal.equal(lastDiff.result, diff.result)) {
3851
+ if (!lastDiff || !equality.equal(lastDiff.result, diff.result)) {
3854
3852
  c.callback(c.lastDiff = diff, lastDiff);
3855
3853
  }
3856
3854
  };
@@ -3909,7 +3907,6 @@ function isNetworkRequestInFlight(networkStatus) {
3909
3907
  }
3910
3908
 
3911
3909
  var assign = Object.assign, hasOwnProperty$2 = Object.hasOwnProperty;
3912
- var warnedAboutUpdateQuery = false;
3913
3910
  var ObservableQuery = (function (_super) {
3914
3911
  tslib.__extends(ObservableQuery, _super);
3915
3912
  function ObservableQuery(_a) {
@@ -3943,11 +3940,10 @@ var ObservableQuery = (function (_super) {
3943
3940
  _this.observers = new Set();
3944
3941
  _this.subscriptions = new Set();
3945
3942
  _this.isTornDown = false;
3946
- _this.options = options;
3943
+ _this.options = tslib.__assign({ initialFetchPolicy: options.fetchPolicy || "cache-first" }, options);
3947
3944
  _this.queryId = queryInfo.queryId || queryManager.generateQueryId();
3948
3945
  var opDef = getOperationDefinition(options.query);
3949
3946
  _this.queryName = opDef && opDef.name && opDef.name.value;
3950
- _this.initialFetchPolicy = options.fetchPolicy || "cache-first";
3951
3947
  _this.queryManager = queryManager;
3952
3948
  _this.queryInfo = queryInfo;
3953
3949
  return _this;
@@ -3995,7 +3991,7 @@ var ObservableQuery = (function (_super) {
3995
3991
  if (diff.complete || this.options.returnPartialData) {
3996
3992
  result.data = diff.result;
3997
3993
  }
3998
- if (equal.equal(result.data, {})) {
3994
+ if (equality.equal(result.data, {})) {
3999
3995
  result.data = void 0;
4000
3996
  }
4001
3997
  if (diff.complete) {
@@ -4026,13 +4022,13 @@ var ObservableQuery = (function (_super) {
4026
4022
  return result;
4027
4023
  };
4028
4024
  ObservableQuery.prototype.isDifferentFromLastResult = function (newResult) {
4029
- return !this.last || !equal.equal(this.last.result, newResult);
4025
+ return !this.last || !equality.equal(this.last.result, newResult);
4030
4026
  };
4031
4027
  ObservableQuery.prototype.getLast = function (key, variablesMustMatch) {
4032
4028
  var last = this.last;
4033
4029
  if (last &&
4034
4030
  last[key] &&
4035
- (!variablesMustMatch || equal.equal(last.variables, this.variables))) {
4031
+ (!variablesMustMatch || equality.equal(last.variables, this.variables))) {
4036
4032
  return last[key];
4037
4033
  }
4038
4034
  };
@@ -4071,7 +4067,7 @@ var ObservableQuery = (function (_super) {
4071
4067
  __DEV__ && tsInvariant.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 })?"));
4072
4068
  }
4073
4069
  }
4074
- if (variables && !equal.equal(this.options.variables, variables)) {
4070
+ if (variables && !equality.equal(this.options.variables, variables)) {
4075
4071
  reobserveOptions.variables = this.options.variables = tslib.__assign(tslib.__assign({}, this.options.variables), variables);
4076
4072
  }
4077
4073
  this.queryInfo.resetLastWrite();
@@ -4081,35 +4077,49 @@ var ObservableQuery = (function (_super) {
4081
4077
  var _this = this;
4082
4078
  var combinedOptions = tslib.__assign(tslib.__assign({}, (fetchMoreOptions.query ? fetchMoreOptions : tslib.__assign(tslib.__assign(tslib.__assign({}, this.options), fetchMoreOptions), { variables: tslib.__assign(tslib.__assign({}, this.options.variables), fetchMoreOptions.variables) }))), { fetchPolicy: "no-cache" });
4083
4079
  var qid = this.queryManager.generateQueryId();
4080
+ var queryInfo = this.queryInfo;
4081
+ var originalNetworkStatus = queryInfo.networkStatus;
4082
+ queryInfo.networkStatus = exports.NetworkStatus.fetchMore;
4084
4083
  if (combinedOptions.notifyOnNetworkStatusChange) {
4085
- this.queryInfo.networkStatus = exports.NetworkStatus.fetchMore;
4086
4084
  this.observe();
4087
4085
  }
4086
+ var updatedQuerySet = new Set();
4088
4087
  return this.queryManager.fetchQuery(qid, combinedOptions, exports.NetworkStatus.fetchMore).then(function (fetchMoreResult) {
4089
- var data = fetchMoreResult.data;
4090
- var updateQuery = fetchMoreOptions.updateQuery;
4091
- if (updateQuery) {
4092
- if (__DEV__ &&
4093
- !warnedAboutUpdateQuery) {
4094
- __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.");
4095
- warnedAboutUpdateQuery = true;
4096
- }
4097
- _this.updateQuery(function (previous) { return updateQuery(previous, {
4098
- fetchMoreResult: data,
4099
- variables: combinedOptions.variables,
4100
- }); });
4101
- }
4102
- else {
4103
- _this.queryManager.cache.writeQuery({
4104
- query: combinedOptions.query,
4105
- variables: combinedOptions.variables,
4106
- data: data,
4107
- });
4108
- }
4088
+ _this.queryManager.removeQuery(qid);
4089
+ if (queryInfo.networkStatus === exports.NetworkStatus.fetchMore) {
4090
+ queryInfo.networkStatus = originalNetworkStatus;
4091
+ }
4092
+ _this.queryManager.cache.batch({
4093
+ update: function (cache) {
4094
+ var updateQuery = fetchMoreOptions.updateQuery;
4095
+ if (updateQuery) {
4096
+ cache.updateQuery({
4097
+ query: _this.options.query,
4098
+ variables: _this.variables,
4099
+ returnPartialData: true,
4100
+ optimistic: false,
4101
+ }, function (previous) { return updateQuery(previous, {
4102
+ fetchMoreResult: fetchMoreResult.data,
4103
+ variables: combinedOptions.variables,
4104
+ }); });
4105
+ }
4106
+ else {
4107
+ cache.writeQuery({
4108
+ query: combinedOptions.query,
4109
+ variables: combinedOptions.variables,
4110
+ data: fetchMoreResult.data,
4111
+ });
4112
+ }
4113
+ },
4114
+ onWatchUpdated: function (watch) {
4115
+ updatedQuerySet.add(watch.query);
4116
+ },
4117
+ });
4109
4118
  return fetchMoreResult;
4110
4119
  }).finally(function () {
4111
- _this.queryManager.stopQuery(qid);
4112
- _this.reobserve();
4120
+ if (!updatedQuerySet.has(_this.options.query)) {
4121
+ reobserveCacheFirst(_this);
4122
+ }
4113
4123
  });
4114
4124
  };
4115
4125
  ObservableQuery.prototype.subscribeToMore = function (options) {
@@ -4152,7 +4162,7 @@ var ObservableQuery = (function (_super) {
4152
4162
  return this.reobserve(newOptions);
4153
4163
  };
4154
4164
  ObservableQuery.prototype.setVariables = function (variables) {
4155
- if (equal.equal(this.variables, variables)) {
4165
+ if (equality.equal(this.variables, variables)) {
4156
4166
  return this.observers.size
4157
4167
  ? this.result()
4158
4168
  : Promise.resolve();
@@ -4162,7 +4172,7 @@ var ObservableQuery = (function (_super) {
4162
4172
  return Promise.resolve();
4163
4173
  }
4164
4174
  return this.reobserve({
4165
- fetchPolicy: this.initialFetchPolicy,
4175
+ fetchPolicy: this.options.initialFetchPolicy,
4166
4176
  variables: variables,
4167
4177
  }, exports.NetworkStatus.setVariables);
4168
4178
  };
@@ -4195,19 +4205,18 @@ var ObservableQuery = (function (_super) {
4195
4205
  this.updatePolling();
4196
4206
  };
4197
4207
  ObservableQuery.prototype.applyNextFetchPolicy = function (reason, options) {
4198
- if (options === void 0) { options = this.options; }
4199
4208
  if (options.nextFetchPolicy) {
4200
- var _a = options.fetchPolicy, fetchPolicy = _a === void 0 ? "cache-first" : _a;
4209
+ var _a = options.fetchPolicy, fetchPolicy = _a === void 0 ? "cache-first" : _a, _b = options.initialFetchPolicy, initialFetchPolicy = _b === void 0 ? fetchPolicy : _b;
4201
4210
  if (typeof options.nextFetchPolicy === "function") {
4202
4211
  options.fetchPolicy = options.nextFetchPolicy(fetchPolicy, {
4203
4212
  reason: reason,
4204
4213
  options: options,
4205
4214
  observable: this,
4206
- initialPolicy: this.initialFetchPolicy,
4215
+ initialFetchPolicy: initialFetchPolicy,
4207
4216
  });
4208
4217
  }
4209
4218
  else if (reason === "variables-changed") {
4210
- options.fetchPolicy = this.initialFetchPolicy;
4219
+ options.fetchPolicy = initialFetchPolicy;
4211
4220
  }
4212
4221
  else {
4213
4222
  options.fetchPolicy = options.nextFetchPolicy;
@@ -4277,16 +4286,18 @@ var ObservableQuery = (function (_super) {
4277
4286
  newNetworkStatus === exports.NetworkStatus.fetchMore ||
4278
4287
  newNetworkStatus === exports.NetworkStatus.poll;
4279
4288
  var oldVariables = this.options.variables;
4289
+ var oldFetchPolicy = this.options.fetchPolicy;
4290
+ var mergedOptions = mergeOptions(this.options, newOptions || {});
4280
4291
  var options = useDisposableConcast
4281
- ? compact(this.options, newOptions)
4282
- : assign(this.options, compact(newOptions));
4292
+ ? mergedOptions
4293
+ : assign(this.options, mergedOptions);
4283
4294
  if (!useDisposableConcast) {
4284
4295
  this.updatePolling();
4285
4296
  if (newOptions &&
4286
4297
  newOptions.variables &&
4287
- !newOptions.fetchPolicy &&
4288
- !equal.equal(newOptions.variables, oldVariables)) {
4289
- this.applyNextFetchPolicy("variables-changed");
4298
+ !equality.equal(newOptions.variables, oldVariables) &&
4299
+ (!newOptions.fetchPolicy || newOptions.fetchPolicy === oldFetchPolicy)) {
4300
+ this.applyNextFetchPolicy("variables-changed", options);
4290
4301
  if (newNetworkStatus === void 0) {
4291
4302
  newNetworkStatus = exports.NetworkStatus.setVariables;
4292
4303
  }
@@ -4350,6 +4361,23 @@ var ObservableQuery = (function (_super) {
4350
4361
  return ObservableQuery;
4351
4362
  }(zenObservableTs.Observable));
4352
4363
  fixObservableSubclass(ObservableQuery);
4364
+ function reobserveCacheFirst(obsQuery) {
4365
+ var _a = obsQuery.options, fetchPolicy = _a.fetchPolicy, nextFetchPolicy = _a.nextFetchPolicy;
4366
+ if (fetchPolicy === "cache-and-network" ||
4367
+ fetchPolicy === "network-only") {
4368
+ return obsQuery.reobserve({
4369
+ fetchPolicy: "cache-first",
4370
+ nextFetchPolicy: function () {
4371
+ this.nextFetchPolicy = nextFetchPolicy;
4372
+ if (typeof nextFetchPolicy === "function") {
4373
+ return nextFetchPolicy.apply(this, arguments);
4374
+ }
4375
+ return fetchPolicy;
4376
+ },
4377
+ });
4378
+ }
4379
+ return obsQuery.reobserve();
4380
+ }
4353
4381
  function defaultSubscriptionObserverErrorCallback(error) {
4354
4382
  __DEV__ && tsInvariant.invariant.error('Unhandled error', error.message, error.stack);
4355
4383
  }
@@ -4659,10 +4687,10 @@ var QueryInfo = (function () {
4659
4687
  var networkStatus = query.networkStatus || exports.NetworkStatus.loading;
4660
4688
  if (this.variables &&
4661
4689
  this.networkStatus !== exports.NetworkStatus.loading &&
4662
- !equal.equal(this.variables, query.variables)) {
4690
+ !equality.equal(this.variables, query.variables)) {
4663
4691
  networkStatus = exports.NetworkStatus.setVariables;
4664
4692
  }
4665
- if (!equal.equal(query.variables, this.variables)) {
4693
+ if (!equality.equal(query.variables, this.variables)) {
4666
4694
  this.lastDiff = void 0;
4667
4695
  }
4668
4696
  Object.assign(this, {
@@ -4688,7 +4716,7 @@ var QueryInfo = (function () {
4688
4716
  QueryInfo.prototype.getDiff = function (variables) {
4689
4717
  if (variables === void 0) { variables = this.variables; }
4690
4718
  var options = this.getDiffOptions(variables);
4691
- if (this.lastDiff && equal.equal(options, this.lastDiff.options)) {
4719
+ if (this.lastDiff && equality.equal(options, this.lastDiff.options)) {
4692
4720
  return this.lastDiff.diff;
4693
4721
  }
4694
4722
  this.updateWatch(this.variables = variables);
@@ -4722,7 +4750,7 @@ var QueryInfo = (function () {
4722
4750
  var oldDiff = this.lastDiff && this.lastDiff.diff;
4723
4751
  this.updateLastDiff(diff);
4724
4752
  if (!this.dirty &&
4725
- !equal.equal(oldDiff && oldDiff.result, diff && diff.result)) {
4753
+ !equality.equal(oldDiff && oldDiff.result, diff && diff.result)) {
4726
4754
  this.dirty = true;
4727
4755
  if (!this.notifyTimeout) {
4728
4756
  this.notifyTimeout = setTimeout(function () { return _this.notify(); }, 0);
@@ -4740,11 +4768,12 @@ var QueryInfo = (function () {
4740
4768
  if (oq) {
4741
4769
  oq["queryInfo"] = this;
4742
4770
  this.listeners.add(this.oqListener = function () {
4743
- if (_this.getDiff().fromOptimisticTransaction) {
4771
+ var diff = _this.getDiff();
4772
+ if (diff.fromOptimisticTransaction) {
4744
4773
  oq["observe"]();
4745
4774
  }
4746
4775
  else {
4747
- oq.reobserve();
4776
+ reobserveCacheFirst(oq);
4748
4777
  }
4749
4778
  });
4750
4779
  }
@@ -4796,7 +4825,7 @@ var QueryInfo = (function () {
4796
4825
  }
4797
4826
  var watchOptions = tslib.__assign(tslib.__assign({}, this.getDiffOptions(variables)), { watcher: this, callback: function (diff) { return _this.setDiff(diff); } });
4798
4827
  if (!this.lastWatch ||
4799
- !equal.equal(watchOptions, this.lastWatch)) {
4828
+ !equality.equal(watchOptions, this.lastWatch)) {
4800
4829
  this.cancel();
4801
4830
  this.cancel = this.cache.watch(this.lastWatch = watchOptions);
4802
4831
  }
@@ -4808,8 +4837,8 @@ var QueryInfo = (function () {
4808
4837
  var lastWrite = this.lastWrite;
4809
4838
  return !(lastWrite &&
4810
4839
  lastWrite.dmCount === destructiveMethodCounts.get(this.cache) &&
4811
- equal.equal(variables, lastWrite.variables) &&
4812
- equal.equal(result.data, lastWrite.result.data));
4840
+ equality.equal(variables, lastWrite.variables) &&
4841
+ equality.equal(result.data, lastWrite.result.data));
4813
4842
  };
4814
4843
  QueryInfo.prototype.markResult = function (result, options, cacheWriteBehavior) {
4815
4844
  var _this = this;
@@ -5393,8 +5422,10 @@ var QueryManager = (function () {
5393
5422
  };
5394
5423
  QueryManager.prototype.removeQuery = function (queryId) {
5395
5424
  this.fetchCancelFns.delete(queryId);
5396
- this.getQuery(queryId).stop();
5397
- this.queries.delete(queryId);
5425
+ if (this.queries.has(queryId)) {
5426
+ this.getQuery(queryId).stop();
5427
+ this.queries.delete(queryId);
5428
+ }
5398
5429
  };
5399
5430
  QueryManager.prototype.broadcastQueries = function () {
5400
5431
  if (this.onBroadcast)
@@ -5478,10 +5509,11 @@ var QueryManager = (function () {
5478
5509
  var aqr = {
5479
5510
  data: result.data,
5480
5511
  loading: false,
5481
- networkStatus: queryInfo.networkStatus || exports.NetworkStatus.ready,
5512
+ networkStatus: exports.NetworkStatus.ready,
5482
5513
  };
5483
5514
  if (hasErrors && options.errorPolicy !== "ignore") {
5484
5515
  aqr.errors = result.errors;
5516
+ aqr.networkStatus = exports.NetworkStatus.error;
5485
5517
  }
5486
5518
  return aqr;
5487
5519
  }, function (networkError) {
@@ -5599,7 +5631,7 @@ var QueryManager = (function () {
5599
5631
  };
5600
5632
  QueryManager.prototype.fetchQueryByPolicy = function (queryInfo, _a, networkStatus) {
5601
5633
  var _this = this;
5602
- var query = _a.query, variables = _a.variables, fetchPolicy = _a.fetchPolicy, refetchWritePolicy = _a.refetchWritePolicy, errorPolicy = _a.errorPolicy, returnPartialData = _a.returnPartialData, context = _a.context, notifyOnNetworkStatusChange = _a.notifyOnNetworkStatusChange;
5634
+ var query = _a.query, variables = _a.variables, fetchPolicy = _a.fetchPolicy, refetchWritePolicy = _a.refetchWritePolicy, errorPolicy = _a.errorPolicy, returnPartialData = _a.returnPartialData, context = _a.context, notifyOnNetworkStatusChange = _a.notifyOnNetworkStatusChange, fetchBlockingPromise = _a.fetchBlockingPromise;
5603
5635
  var oldNetworkStatus = queryInfo.networkStatus;
5604
5636
  queryInfo.init({
5605
5637
  document: query,
@@ -5612,7 +5644,7 @@ var QueryManager = (function () {
5612
5644
  var data = diff.result;
5613
5645
  if (__DEV__ &&
5614
5646
  !returnPartialData &&
5615
- !equal.equal(data, {})) {
5647
+ !equality.equal(data, {})) {
5616
5648
  logMissingFieldErrors(diff.missing);
5617
5649
  }
5618
5650
  var fromData = function (data) { return zenObservableTs.Observable.of(tslib.__assign({ data: data, loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus }, (diff.complete ? null : { partial: true }))); };
@@ -5632,12 +5664,26 @@ var QueryManager = (function () {
5632
5664
  refetchWritePolicy !== "merge") ? 1
5633
5665
  : 2;
5634
5666
  var resultsFromLink = function () {
5635
- return _this.getResultsFromLink(queryInfo, cacheWriteBehavior, {
5667
+ var get = function () { return _this.getResultsFromLink(queryInfo, cacheWriteBehavior, {
5636
5668
  variables: variables,
5637
5669
  context: context,
5638
5670
  fetchPolicy: fetchPolicy,
5639
5671
  errorPolicy: errorPolicy,
5640
- });
5672
+ }); };
5673
+ return fetchBlockingPromise ? fetchBlockingPromise.then(function (ok) { return ok ? get() : zenObservableTs.Observable.of(); }, function (error) {
5674
+ var apolloError = isApolloError(error)
5675
+ ? error
5676
+ : new ApolloError({ clientErrors: [error] });
5677
+ if (errorPolicy !== "ignore") {
5678
+ queryInfo.markError(apolloError);
5679
+ }
5680
+ return zenObservableTs.Observable.of({
5681
+ loading: false,
5682
+ networkStatus: exports.NetworkStatus.error,
5683
+ error: apolloError,
5684
+ data: readCache().result,
5685
+ });
5686
+ }) : get();
5641
5687
  };
5642
5688
  var shouldNotify = notifyOnNetworkStatusChange &&
5643
5689
  typeof oldNetworkStatus === "number" &&
@@ -6075,26 +6121,9 @@ function verifyDocumentType(document, type) {
6075
6121
  "".concat(requiredOperationName, ", but a ").concat(usedOperationName, " was used instead.")) : tsInvariant.invariant(operation.type === type, 34);
6076
6122
  }
6077
6123
 
6078
- function useNormalizedOptions(optionsOrFunction) {
6079
- var optionsRef = React.useRef();
6080
- var options = optionsRef.current || Object.create(null);
6081
- if (typeof optionsOrFunction === "function") {
6082
- var newOptions = optionsOrFunction(options);
6083
- if (newOptions !== options) {
6084
- Object.assign(options, newOptions, newOptions.variables && {
6085
- variables: tslib.__assign(tslib.__assign({}, options.variables), newOptions.variables),
6086
- });
6087
- }
6088
- }
6089
- else if (optionsOrFunction && !equal__default(optionsOrFunction, options)) {
6090
- options = optionsOrFunction;
6091
- }
6092
- return optionsRef.current = options;
6093
- }
6094
-
6095
6124
  var hasOwnProperty = Object.prototype.hasOwnProperty;
6096
- function useQuery(query, optionsOrFunction) {
6097
- var options = useNormalizedOptions(optionsOrFunction);
6125
+ function useQuery(query, options) {
6126
+ if (options === void 0) { options = Object.create(null); }
6098
6127
  return useInternalState(useApolloClient(options.client), query).useQuery(options);
6099
6128
  }
6100
6129
  function useInternalState(client, query) {
@@ -6115,51 +6144,151 @@ var InternalState = (function () {
6115
6144
  function InternalState(client, query) {
6116
6145
  this.client = client;
6117
6146
  this.query = query;
6147
+ this.ssrDisabledResult = maybeDeepFreeze({
6148
+ loading: true,
6149
+ data: void 0,
6150
+ error: void 0,
6151
+ networkStatus: exports.NetworkStatus.loading,
6152
+ });
6153
+ this.skipStandbyResult = maybeDeepFreeze({
6154
+ loading: false,
6155
+ data: void 0,
6156
+ error: void 0,
6157
+ networkStatus: exports.NetworkStatus.ready,
6158
+ });
6118
6159
  this.toQueryResultCache = new (canUseWeakMap ? WeakMap : Map)();
6119
6160
  verifyDocumentType(query, exports.DocumentType.Query);
6120
6161
  }
6121
6162
  InternalState.prototype.forceUpdate = function () {
6122
6163
  };
6123
6164
  InternalState.prototype.useQuery = function (options) {
6165
+ var _this = this;
6166
+ this.renderPromises = React.useContext(getApolloContext()).renderPromises;
6124
6167
  this.useOptions(options);
6125
6168
  var obsQuery = this.useObservableQuery();
6126
- this.useSubscriptionEffect(obsQuery);
6127
- var result = this.getCurrentResult();
6169
+ var result = index_js.useSyncExternalStore(React.useCallback(function () {
6170
+ if (_this.renderPromises) {
6171
+ return function () { };
6172
+ }
6173
+ var onNext = function () {
6174
+ var previousResult = _this.result;
6175
+ var result = obsQuery.getCurrentResult();
6176
+ if (previousResult &&
6177
+ previousResult.loading === result.loading &&
6178
+ previousResult.networkStatus === result.networkStatus &&
6179
+ equality.equal(previousResult.data, result.data)) {
6180
+ return;
6181
+ }
6182
+ _this.setResult(result);
6183
+ };
6184
+ var onError = function (error) {
6185
+ var last = obsQuery["last"];
6186
+ subscription.unsubscribe();
6187
+ try {
6188
+ obsQuery.resetLastResults();
6189
+ subscription = obsQuery.subscribe(onNext, onError);
6190
+ }
6191
+ finally {
6192
+ obsQuery["last"] = last;
6193
+ }
6194
+ if (!hasOwnProperty.call(error, 'graphQLErrors')) {
6195
+ throw error;
6196
+ }
6197
+ var previousResult = _this.result;
6198
+ if (!previousResult ||
6199
+ (previousResult && previousResult.loading) ||
6200
+ !equality.equal(error, previousResult.error)) {
6201
+ _this.setResult({
6202
+ data: (previousResult && previousResult.data),
6203
+ error: error,
6204
+ loading: false,
6205
+ networkStatus: exports.NetworkStatus.error,
6206
+ });
6207
+ }
6208
+ };
6209
+ var subscription = obsQuery.subscribe(onNext, onError);
6210
+ return function () { return subscription.unsubscribe(); };
6211
+ }, [
6212
+ obsQuery,
6213
+ this.renderPromises,
6214
+ this.client.disableNetworkFetches,
6215
+ ]), function () { return _this.getCurrentResult(); });
6128
6216
  this.unsafeHandlePartialRefetch(result);
6129
6217
  return this.toQueryResult(result);
6130
6218
  };
6131
6219
  InternalState.prototype.useOptions = function (options) {
6132
- this.renderPromises = React.useContext(getApolloContext()).renderPromises;
6220
+ var _a;
6133
6221
  var watchQueryOptions = this.createWatchQueryOptions(this.queryHookOptions = options);
6134
- if (!equal.equal(watchQueryOptions, this.watchQueryOptions)) {
6222
+ var currentWatchQueryOptions = this.watchQueryOptions;
6223
+ var resolveFetchBlockingPromise;
6224
+ if (!equality.equal(watchQueryOptions, currentWatchQueryOptions)) {
6135
6225
  this.watchQueryOptions = watchQueryOptions;
6226
+ if (currentWatchQueryOptions && this.observable) {
6227
+ this.observable.reobserve(tslib.__assign({ fetchBlockingPromise: new Promise(function (resolve) {
6228
+ resolveFetchBlockingPromise = resolve;
6229
+ }) }, watchQueryOptions));
6230
+ this.previousData = ((_a = this.result) === null || _a === void 0 ? void 0 : _a.data) || this.previousData;
6231
+ this.result = void 0;
6232
+ }
6233
+ }
6234
+ useUnblockFetchEffect(this.renderPromises, resolveFetchBlockingPromise);
6235
+ this.ssrDisabled = !!(options.ssr === false ||
6236
+ options.skip);
6237
+ this.onCompleted = options.onCompleted || InternalState.prototype.onCompleted;
6238
+ this.onError = options.onError || InternalState.prototype.onError;
6239
+ if ((this.renderPromises || this.client.disableNetworkFetches) &&
6240
+ this.queryHookOptions.ssr === false) {
6241
+ this.result = this.ssrDisabledResult;
6242
+ }
6243
+ else if (this.queryHookOptions.skip ||
6244
+ this.watchQueryOptions.fetchPolicy === 'standby') {
6245
+ this.result = this.skipStandbyResult;
6246
+ }
6247
+ else if (this.result === this.ssrDisabledResult ||
6248
+ this.result === this.skipStandbyResult) {
6249
+ this.result = void 0;
6136
6250
  }
6137
- this.ssrDisabled = !!(options && (options.ssr === false ||
6138
- options.skip));
6139
- this.onCompleted = options
6140
- && options.onCompleted
6141
- || InternalState.prototype.onCompleted;
6142
- this.onError = options
6143
- && options.onError
6144
- || InternalState.prototype.onError;
6145
6251
  };
6146
6252
  InternalState.prototype.createWatchQueryOptions = function (_a) {
6147
- var _b;
6148
6253
  if (_a === void 0) { _a = {}; }
6149
- var skip = _a.skip; _a.ssr; _a.onCompleted; _a.onError; _a.displayName; var otherOptions = tslib.__rest(_a, ["skip", "ssr", "onCompleted", "onError", "displayName"]);
6150
- var watchQueryOptions = Object.assign(otherOptions, { query: this.query });
6151
- if (skip) {
6152
- watchQueryOptions.fetchPolicy = 'standby';
6254
+ var skip = _a.skip; _a.ssr; _a.onCompleted; _a.onError; _a.displayName; var defaultOptions = _a.defaultOptions, otherOptions = tslib.__rest(_a, ["skip", "ssr", "onCompleted", "onError", "displayName", "defaultOptions"]);
6255
+ var toMerge = [];
6256
+ var globalDefaults = this.client.defaultOptions.watchQuery;
6257
+ if (globalDefaults)
6258
+ toMerge.push(globalDefaults);
6259
+ if (defaultOptions)
6260
+ toMerge.push(defaultOptions);
6261
+ var latestOptions = this.observable && this.observable.options;
6262
+ if (latestOptions && toMerge.length) {
6263
+ var defaults_1 = toMerge.reduce(mergeOptions, Object.create(null));
6264
+ toMerge.length = 1;
6265
+ toMerge[0] = defaults_1;
6266
+ Object.keys(defaults_1).forEach(function (defaultOptionName) {
6267
+ var currentOptionValue = latestOptions[defaultOptionName];
6268
+ if (hasOwnProperty.call(latestOptions, defaultOptionName) &&
6269
+ !equality.equal(defaults_1[defaultOptionName], currentOptionValue)) {
6270
+ defaults_1[defaultOptionName] = defaultOptionName === "variables"
6271
+ ? tslib.__assign(tslib.__assign({}, defaults_1.variables), currentOptionValue) : currentOptionValue;
6272
+ }
6273
+ });
6153
6274
  }
6154
- else if (((_b = watchQueryOptions.context) === null || _b === void 0 ? void 0 : _b.renderPromises) &&
6275
+ toMerge.push(otherOptions);
6276
+ var merged = toMerge.reduce(mergeOptions, Object.create(null));
6277
+ var watchQueryOptions = Object.assign(merged, { query: this.query });
6278
+ if (this.renderPromises &&
6155
6279
  (watchQueryOptions.fetchPolicy === 'network-only' ||
6156
6280
  watchQueryOptions.fetchPolicy === 'cache-and-network')) {
6157
6281
  watchQueryOptions.fetchPolicy = 'cache-first';
6158
6282
  }
6159
6283
  else if (!watchQueryOptions.fetchPolicy) {
6160
- var defaultOptions = this.client.defaultOptions.watchQuery;
6161
- watchQueryOptions.fetchPolicy =
6162
- defaultOptions && defaultOptions.fetchPolicy || 'cache-first';
6284
+ watchQueryOptions.fetchPolicy = 'cache-first';
6285
+ }
6286
+ if (skip) {
6287
+ var _b = watchQueryOptions.initialFetchPolicy, initialFetchPolicy = _b === void 0 ? watchQueryOptions.fetchPolicy : _b;
6288
+ Object.assign(watchQueryOptions, {
6289
+ initialFetchPolicy: initialFetchPolicy,
6290
+ fetchPolicy: 'standby',
6291
+ });
6163
6292
  }
6164
6293
  if (!watchQueryOptions.variables) {
6165
6294
  watchQueryOptions.variables = {};
@@ -6169,14 +6298,18 @@ var InternalState = (function () {
6169
6298
  InternalState.prototype.onCompleted = function (data) { };
6170
6299
  InternalState.prototype.onError = function (error) { };
6171
6300
  InternalState.prototype.useObservableQuery = function () {
6172
- var _this = this;
6301
+ var resolveFetchBlockingPromise;
6173
6302
  var obsQuery = this.observable =
6174
6303
  this.renderPromises
6175
6304
  && this.renderPromises.getSSRObservable(this.watchQueryOptions)
6176
6305
  || this.observable
6177
- || this.client.watchQuery(this.watchQueryOptions);
6306
+ || this.client.watchQuery(tslib.__assign({ fetchBlockingPromise: new Promise(function (resolve) {
6307
+ resolveFetchBlockingPromise = resolve;
6308
+ }) }, this.watchQueryOptions));
6309
+ useUnblockFetchEffect(this.renderPromises, resolveFetchBlockingPromise);
6178
6310
  this.obsQueryFields = React.useMemo(function () { return ({
6179
6311
  refetch: obsQuery.refetch.bind(obsQuery),
6312
+ reobserve: obsQuery.reobserve.bind(obsQuery),
6180
6313
  fetchMore: obsQuery.fetchMore.bind(obsQuery),
6181
6314
  updateQuery: obsQuery.updateQuery.bind(obsQuery),
6182
6315
  startPolling: obsQuery.startPolling.bind(obsQuery),
@@ -6186,92 +6319,11 @@ var InternalState = (function () {
6186
6319
  if (this.renderPromises) {
6187
6320
  this.renderPromises.registerSSRObservable(obsQuery);
6188
6321
  if (!this.ssrDisabled && obsQuery.getCurrentResult().loading) {
6189
- this.renderPromises.addQueryPromise({
6190
- getOptions: function () { return obsQuery.options; },
6191
- fetchData: function () { return new Promise(function (resolve) {
6192
- var sub = obsQuery.subscribe({
6193
- next: function (result) {
6194
- if (!result.loading) {
6195
- resolve();
6196
- sub.unsubscribe();
6197
- }
6198
- },
6199
- error: function () {
6200
- resolve();
6201
- sub.unsubscribe();
6202
- },
6203
- complete: function () {
6204
- resolve();
6205
- },
6206
- });
6207
- }); },
6208
- }, function () { return null; });
6209
- obsQuery.setOptions(this.watchQueryOptions).catch(function () { });
6322
+ this.renderPromises.addObservableQueryPromise(obsQuery);
6210
6323
  }
6211
6324
  }
6212
- var prevOptionsRef = React.useRef({
6213
- watchQueryOptions: this.watchQueryOptions,
6214
- });
6215
- React.useEffect(function () {
6216
- if (_this.renderPromises) ;
6217
- else if (_this.watchQueryOptions !== prevOptionsRef.current.watchQueryOptions) {
6218
- obsQuery.setOptions(_this.watchQueryOptions).catch(function () { });
6219
- prevOptionsRef.current.watchQueryOptions = _this.watchQueryOptions;
6220
- _this.setResult(obsQuery.getCurrentResult());
6221
- }
6222
- }, [obsQuery, this.watchQueryOptions]);
6223
6325
  return obsQuery;
6224
6326
  };
6225
- InternalState.prototype.useSubscriptionEffect = function (obsQuery) {
6226
- var _this = this;
6227
- React.useEffect(function () {
6228
- if (_this.renderPromises) {
6229
- return;
6230
- }
6231
- var onNext = function () {
6232
- var previousResult = _this.result;
6233
- var result = obsQuery.getCurrentResult();
6234
- if (previousResult &&
6235
- previousResult.loading === result.loading &&
6236
- previousResult.networkStatus === result.networkStatus &&
6237
- equal.equal(previousResult.data, result.data)) {
6238
- return;
6239
- }
6240
- _this.setResult(result);
6241
- };
6242
- var onError = function (error) {
6243
- var last = obsQuery["last"];
6244
- subscription.unsubscribe();
6245
- try {
6246
- obsQuery.resetLastResults();
6247
- subscription = obsQuery.subscribe(onNext, onError);
6248
- }
6249
- finally {
6250
- obsQuery["last"] = last;
6251
- }
6252
- if (!hasOwnProperty.call(error, 'graphQLErrors')) {
6253
- throw error;
6254
- }
6255
- var previousResult = _this.result;
6256
- if (!previousResult ||
6257
- (previousResult && previousResult.loading) ||
6258
- !equal.equal(error, previousResult.error)) {
6259
- _this.setResult({
6260
- data: (previousResult && previousResult.data),
6261
- error: error,
6262
- loading: false,
6263
- networkStatus: exports.NetworkStatus.error,
6264
- });
6265
- }
6266
- };
6267
- var subscription = obsQuery.subscribe(onNext, onError);
6268
- return function () { return subscription.unsubscribe(); };
6269
- }, [
6270
- obsQuery,
6271
- this.renderPromises,
6272
- this.client.disableNetworkFetches,
6273
- ]);
6274
- };
6275
6327
  InternalState.prototype.setResult = function (nextResult) {
6276
6328
  var previousResult = this.result;
6277
6329
  if (previousResult && previousResult.data) {
@@ -6292,30 +6344,10 @@ var InternalState = (function () {
6292
6344
  }
6293
6345
  };
6294
6346
  InternalState.prototype.getCurrentResult = function () {
6295
- var result = this.result;
6296
- if (!result) {
6297
- result = this.result = this.observable.getCurrentResult();
6298
- this.handleErrorOrCompleted(result);
6299
- }
6300
- if ((this.renderPromises || this.client.disableNetworkFetches) &&
6301
- this.queryHookOptions.ssr === false) {
6302
- result = {
6303
- loading: true,
6304
- data: void 0,
6305
- error: void 0,
6306
- networkStatus: exports.NetworkStatus.loading,
6307
- };
6308
- }
6309
- else if (this.queryHookOptions.skip ||
6310
- this.queryHookOptions.fetchPolicy === 'standby') {
6311
- result = {
6312
- loading: false,
6313
- data: void 0,
6314
- error: void 0,
6315
- networkStatus: exports.NetworkStatus.ready,
6316
- };
6347
+ if (!this.result) {
6348
+ this.handleErrorOrCompleted(this.result = this.observable.getCurrentResult());
6317
6349
  }
6318
- return result;
6350
+ return this.result;
6319
6351
  };
6320
6352
  InternalState.prototype.toQueryResult = function (result) {
6321
6353
  var queryResult = this.toQueryResultCache.get(result);
@@ -6343,34 +6375,52 @@ var InternalState = (function () {
6343
6375
  };
6344
6376
  return InternalState;
6345
6377
  }());
6378
+ function useUnblockFetchEffect(renderPromises, resolveFetchBlockingPromise) {
6379
+ if (resolveFetchBlockingPromise) {
6380
+ if (renderPromises) {
6381
+ resolveFetchBlockingPromise(true);
6382
+ }
6383
+ else {
6384
+ setTimeout(function () { return resolveFetchBlockingPromise(false); }, 5000);
6385
+ }
6386
+ }
6387
+ React.useEffect(function () {
6388
+ if (resolveFetchBlockingPromise) {
6389
+ resolveFetchBlockingPromise(true);
6390
+ }
6391
+ }, [resolveFetchBlockingPromise]);
6392
+ }
6346
6393
 
6347
6394
  var EAGER_METHODS = [
6348
6395
  'refetch',
6396
+ 'reobserve',
6349
6397
  'fetchMore',
6350
6398
  'updateQuery',
6351
6399
  'startPolling',
6352
6400
  'subscribeToMore',
6353
6401
  ];
6354
- function useLazyQuery(query, optionsOrFunction) {
6355
- var options = useNormalizedOptions(optionsOrFunction);
6356
- var _a = React.useState({
6357
- called: false,
6358
- }), execution = _a[0], setExecution = _a[1];
6359
- var result = useQuery(query, tslib.__assign(tslib.__assign(tslib.__assign({}, options), execution.options), { fetchPolicy: execution.called ? options === null || options === void 0 ? void 0 : options.fetchPolicy : 'standby', skip: undefined }));
6360
- if (!execution.called) {
6361
- result = tslib.__assign(tslib.__assign({}, result), { loading: false, data: void 0, error: void 0, called: false });
6362
- }
6402
+ function useLazyQuery(query, options) {
6403
+ var internalState = useInternalState(useApolloClient(options && options.client), query);
6404
+ var execOptionsRef = React.useRef();
6405
+ var defaultOptions = internalState.client.defaultOptions.watchQuery;
6406
+ var initialFetchPolicy = (options && options.fetchPolicy) ||
6407
+ (execOptionsRef.current && execOptionsRef.current.fetchPolicy) ||
6408
+ (defaultOptions && defaultOptions.fetchPolicy) ||
6409
+ "cache-first";
6410
+ var useQueryResult = internalState.useQuery(tslib.__assign(tslib.__assign(tslib.__assign({}, options), execOptionsRef.current), { skip: !execOptionsRef.current }));
6411
+ var result = Object.assign(useQueryResult, {
6412
+ called: !!execOptionsRef.current,
6413
+ });
6363
6414
  var eagerMethods = React.useMemo(function () {
6364
6415
  var eagerMethods = {};
6365
6416
  var _loop_1 = function (key) {
6366
6417
  var method = result[key];
6367
6418
  eagerMethods[key] = function () {
6368
- var args = [];
6369
- for (var _i = 0; _i < arguments.length; _i++) {
6370
- args[_i] = arguments[_i];
6419
+ if (!execOptionsRef.current) {
6420
+ execOptionsRef.current = Object.create(null);
6421
+ internalState.forceUpdate();
6371
6422
  }
6372
- setExecution(function (execution) { return (tslib.__assign(tslib.__assign({}, execution), { called: true })); });
6373
- return method.apply(void 0, args);
6423
+ return method.apply(this, arguments);
6374
6424
  };
6375
6425
  };
6376
6426
  for (var _i = 0, EAGER_METHODS_1 = EAGER_METHODS; _i < EAGER_METHODS_1.length; _i++) {
@@ -6379,15 +6429,24 @@ function useLazyQuery(query, optionsOrFunction) {
6379
6429
  }
6380
6430
  return eagerMethods;
6381
6431
  }, []);
6382
- result.error = result.error || void 0;
6383
6432
  Object.assign(result, eagerMethods);
6384
6433
  var execute = React.useCallback(function (executeOptions) {
6385
- setExecution({ called: true, options: executeOptions });
6386
- var promise = result.refetch(executeOptions === null || executeOptions === void 0 ? void 0 : executeOptions.variables).then(function (result1) {
6387
- var result2 = tslib.__assign(tslib.__assign({}, result), { data: result1.data, error: result1.error, called: true, loading: false });
6388
- Object.assign(result2, eagerMethods);
6389
- return result2;
6390
- });
6434
+ var promise = result.reobserve(execOptionsRef.current = executeOptions ? tslib.__assign(tslib.__assign({}, executeOptions), { fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy }) : {
6435
+ fetchPolicy: initialFetchPolicy,
6436
+ }).then(function (apolloQueryResult) {
6437
+ apolloQueryResult = apolloQueryResult || internalState["getCurrentResult"]();
6438
+ if (apolloQueryResult.error ||
6439
+ isNonEmptyArray(apolloQueryResult.errors)) {
6440
+ var _a = result.observable.options.errorPolicy, errorPolicy = _a === void 0 ? "none" : _a;
6441
+ if (errorPolicy === "none") {
6442
+ throw apolloQueryResult.error || new ApolloError({
6443
+ graphQLErrors: apolloQueryResult.errors,
6444
+ });
6445
+ }
6446
+ }
6447
+ return internalState.toQueryResult(apolloQueryResult);
6448
+ }).then(function (queryResult) { return Object.assign(queryResult, eagerMethods); });
6449
+ internalState.forceUpdate();
6391
6450
  promise.catch(function () { });
6392
6451
  return promise;
6393
6452
  }, []);
@@ -6443,7 +6502,7 @@ function useMutation(mutation, options) {
6443
6502
  error: error,
6444
6503
  client: client,
6445
6504
  };
6446
- if (ref.current.isMounted && !equal.equal(ref.current.result, result_1)) {
6505
+ if (ref.current.isMounted && !equality.equal(ref.current.result, result_1)) {
6447
6506
  setResult(ref.current.result = result_1);
6448
6507
  }
6449
6508
  }
@@ -6461,7 +6520,7 @@ function useMutation(mutation, options) {
6461
6520
  called: true,
6462
6521
  client: client,
6463
6522
  };
6464
- if (!equal.equal(ref.current.result, result_2)) {
6523
+ if (!equality.equal(ref.current.result, result_2)) {
6465
6524
  setResult(ref.current.result = result_2);
6466
6525
  }
6467
6526
  }
@@ -6524,7 +6583,7 @@ function useSubscription(subscription, options) {
6524
6583
  subscription !== ref.current.subscription ||
6525
6584
  (options === null || options === void 0 ? void 0 : options.fetchPolicy) !== ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.fetchPolicy) ||
6526
6585
  !(options === null || options === void 0 ? void 0 : options.skip) !== !((_c = ref.current.options) === null || _c === void 0 ? void 0 : _c.skip) ||
6527
- !equal.equal(options === null || options === void 0 ? void 0 : options.variables, (_d = ref.current.options) === null || _d === void 0 ? void 0 : _d.variables))) {
6586
+ !equality.equal(options === null || options === void 0 ? void 0 : options.variables, (_d = ref.current.options) === null || _d === void 0 ? void 0 : _d.variables))) {
6528
6587
  setResult({
6529
6588
  loading: true,
6530
6589
  data: void 0,