@apollo/client 3.6.0-beta.10 → 3.6.0-beta.11

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 (42) hide show
  1. package/apollo-client.cjs +113 -100
  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 +0 -1
  8. package/core/ObservableQuery.d.ts.map +1 -1
  9. package/core/ObservableQuery.js +14 -13
  10. package/core/ObservableQuery.js.map +1 -1
  11. package/core/QueryManager.d.ts.map +1 -1
  12. package/core/QueryManager.js +2 -1
  13. package/core/QueryManager.js.map +1 -1
  14. package/core/core.cjs +15 -14
  15. package/core/core.cjs.map +1 -1
  16. package/core/watchQueryOptions.d.ts +2 -1
  17. package/core/watchQueryOptions.d.ts.map +1 -1
  18. package/core/watchQueryOptions.js.map +1 -1
  19. package/invariantErrorCodes.js +1 -1
  20. package/package.json +1 -1
  21. package/react/hooks/hooks.cjs +81 -70
  22. package/react/hooks/hooks.cjs.map +1 -1
  23. package/react/hooks/index.d.ts +1 -1
  24. package/react/hooks/index.d.ts.map +1 -1
  25. package/react/hooks/index.js +1 -1
  26. package/react/hooks/index.js.map +1 -1
  27. package/react/hooks/useLazyQuery.d.ts +2 -2
  28. package/react/hooks/useLazyQuery.d.ts.map +1 -1
  29. package/react/hooks/useLazyQuery.js +38 -24
  30. package/react/hooks/useLazyQuery.js.map +1 -1
  31. package/react/hooks/useQuery.d.ts +33 -3
  32. package/react/hooks/useQuery.d.ts.map +1 -1
  33. package/react/hooks/useQuery.js +43 -23
  34. package/react/hooks/useQuery.js.map +1 -1
  35. package/react/types/types.d.ts +9 -13
  36. package/react/types/types.d.ts.map +1 -1
  37. package/react/types/types.js.map +1 -1
  38. package/version.js +1 -1
  39. package/react/hooks/options.d.ts +0 -3
  40. package/react/hooks/options.d.ts.map +0 -1
  41. package/react/hooks/options.js +0 -20
  42. 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');
@@ -14,8 +14,6 @@ var trie = require('@wry/trie');
14
14
  var graphqlTag = require('graphql-tag');
15
15
  var React = require('react');
16
16
 
17
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
18
-
19
17
  function _interopNamespace(e) {
20
18
  if (e && e.__esModule) return e;
21
19
  var n = Object.create(null);
@@ -28,7 +26,6 @@ function _interopNamespace(e) {
28
26
  return Object.freeze(n);
29
27
  }
30
28
 
31
- var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
32
29
  var React__namespace = /*#__PURE__*/_interopNamespace(React);
33
30
 
34
31
  function maybe(thunk) {
@@ -1294,7 +1291,7 @@ var concat = ApolloLink.concat;
1294
1291
 
1295
1292
  var execute = ApolloLink.execute;
1296
1293
 
1297
- var version = '3.6.0-beta.10';
1294
+ var version = '3.6.0-beta.11';
1298
1295
 
1299
1296
  var hasOwnProperty$3 = Object.prototype.hasOwnProperty;
1300
1297
  function parseAndCheckHttpResponse(operations) {
@@ -2162,7 +2159,7 @@ var Layer = (function (_super) {
2162
2159
  }
2163
2160
  else if (ownStoreObject !== parentStoreObject) {
2164
2161
  Object.keys(ownStoreObject).forEach(function (storeFieldName) {
2165
- if (!equal.equal(ownStoreObject[storeFieldName], parentStoreObject[storeFieldName])) {
2162
+ if (!equality.equal(ownStoreObject[storeFieldName], parentStoreObject[storeFieldName])) {
2166
2163
  _this.group.dirty(dataId, storeFieldName);
2167
2164
  }
2168
2165
  });
@@ -2206,7 +2203,7 @@ var Stump = (function (_super) {
2206
2203
  function storeObjectReconciler(existingObject, incomingObject, property) {
2207
2204
  var existingValue = existingObject[property];
2208
2205
  var incomingValue = incomingObject[property];
2209
- return equal.equal(existingValue, incomingValue) ? existingValue : incomingValue;
2206
+ return equality.equal(existingValue, incomingValue) ? existingValue : incomingValue;
2210
2207
  }
2211
2208
  function supportsResultCaching(store) {
2212
2209
  return !!(store instanceof EntityStore && store.group.caching);
@@ -3536,7 +3533,7 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
3536
3533
  return;
3537
3534
  if (isReference(existing))
3538
3535
  return;
3539
- if (equal.equal(existing, incoming))
3536
+ if (equality.equal(existing, incoming))
3540
3537
  return;
3541
3538
  if (Object.keys(existing).every(function (key) { return store.getFieldValue(incoming, key) !== void 0; })) {
3542
3539
  return;
@@ -3850,7 +3847,7 @@ var InMemoryCache = (function (_super) {
3850
3847
  return;
3851
3848
  }
3852
3849
  }
3853
- if (!lastDiff || !equal.equal(lastDiff.result, diff.result)) {
3850
+ if (!lastDiff || !equality.equal(lastDiff.result, diff.result)) {
3854
3851
  c.callback(c.lastDiff = diff, lastDiff);
3855
3852
  }
3856
3853
  };
@@ -3942,11 +3939,10 @@ var ObservableQuery = (function (_super) {
3942
3939
  _this.observers = new Set();
3943
3940
  _this.subscriptions = new Set();
3944
3941
  _this.isTornDown = false;
3945
- _this.options = options;
3942
+ _this.options = tslib.__assign({ initialFetchPolicy: options.fetchPolicy || "cache-first" }, options);
3946
3943
  _this.queryId = queryInfo.queryId || queryManager.generateQueryId();
3947
3944
  var opDef = getOperationDefinition(options.query);
3948
3945
  _this.queryName = opDef && opDef.name && opDef.name.value;
3949
- _this.initialFetchPolicy = options.fetchPolicy || "cache-first";
3950
3946
  _this.queryManager = queryManager;
3951
3947
  _this.queryInfo = queryInfo;
3952
3948
  return _this;
@@ -3994,7 +3990,7 @@ var ObservableQuery = (function (_super) {
3994
3990
  if (diff.complete || this.options.returnPartialData) {
3995
3991
  result.data = diff.result;
3996
3992
  }
3997
- if (equal.equal(result.data, {})) {
3993
+ if (equality.equal(result.data, {})) {
3998
3994
  result.data = void 0;
3999
3995
  }
4000
3996
  if (diff.complete) {
@@ -4025,13 +4021,13 @@ var ObservableQuery = (function (_super) {
4025
4021
  return result;
4026
4022
  };
4027
4023
  ObservableQuery.prototype.isDifferentFromLastResult = function (newResult) {
4028
- return !this.last || !equal.equal(this.last.result, newResult);
4024
+ return !this.last || !equality.equal(this.last.result, newResult);
4029
4025
  };
4030
4026
  ObservableQuery.prototype.getLast = function (key, variablesMustMatch) {
4031
4027
  var last = this.last;
4032
4028
  if (last &&
4033
4029
  last[key] &&
4034
- (!variablesMustMatch || equal.equal(last.variables, this.variables))) {
4030
+ (!variablesMustMatch || equality.equal(last.variables, this.variables))) {
4035
4031
  return last[key];
4036
4032
  }
4037
4033
  };
@@ -4070,7 +4066,7 @@ var ObservableQuery = (function (_super) {
4070
4066
  __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 })?"));
4071
4067
  }
4072
4068
  }
4073
- if (variables && !equal.equal(this.options.variables, variables)) {
4069
+ if (variables && !equality.equal(this.options.variables, variables)) {
4074
4070
  reobserveOptions.variables = this.options.variables = tslib.__assign(tslib.__assign({}, this.options.variables), variables);
4075
4071
  }
4076
4072
  this.queryInfo.resetLastWrite();
@@ -4165,7 +4161,7 @@ var ObservableQuery = (function (_super) {
4165
4161
  return this.reobserve(newOptions);
4166
4162
  };
4167
4163
  ObservableQuery.prototype.setVariables = function (variables) {
4168
- if (equal.equal(this.variables, variables)) {
4164
+ if (equality.equal(this.variables, variables)) {
4169
4165
  return this.observers.size
4170
4166
  ? this.result()
4171
4167
  : Promise.resolve();
@@ -4175,7 +4171,7 @@ var ObservableQuery = (function (_super) {
4175
4171
  return Promise.resolve();
4176
4172
  }
4177
4173
  return this.reobserve({
4178
- fetchPolicy: this.initialFetchPolicy,
4174
+ fetchPolicy: this.options.initialFetchPolicy,
4179
4175
  variables: variables,
4180
4176
  }, exports.NetworkStatus.setVariables);
4181
4177
  };
@@ -4208,19 +4204,18 @@ var ObservableQuery = (function (_super) {
4208
4204
  this.updatePolling();
4209
4205
  };
4210
4206
  ObservableQuery.prototype.applyNextFetchPolicy = function (reason, options) {
4211
- if (options === void 0) { options = this.options; }
4212
4207
  if (options.nextFetchPolicy) {
4213
- var _a = options.fetchPolicy, fetchPolicy = _a === void 0 ? "cache-first" : _a;
4208
+ var _a = options.fetchPolicy, fetchPolicy = _a === void 0 ? "cache-first" : _a, _b = options.initialFetchPolicy, initialFetchPolicy = _b === void 0 ? fetchPolicy : _b;
4214
4209
  if (typeof options.nextFetchPolicy === "function") {
4215
4210
  options.fetchPolicy = options.nextFetchPolicy(fetchPolicy, {
4216
4211
  reason: reason,
4217
4212
  options: options,
4218
4213
  observable: this,
4219
- initialPolicy: this.initialFetchPolicy,
4214
+ initialFetchPolicy: initialFetchPolicy,
4220
4215
  });
4221
4216
  }
4222
4217
  else if (reason === "variables-changed") {
4223
- options.fetchPolicy = this.initialFetchPolicy;
4218
+ options.fetchPolicy = initialFetchPolicy;
4224
4219
  }
4225
4220
  else {
4226
4221
  options.fetchPolicy = options.nextFetchPolicy;
@@ -4290,16 +4285,18 @@ var ObservableQuery = (function (_super) {
4290
4285
  newNetworkStatus === exports.NetworkStatus.fetchMore ||
4291
4286
  newNetworkStatus === exports.NetworkStatus.poll;
4292
4287
  var oldVariables = this.options.variables;
4288
+ var oldFetchPolicy = this.options.fetchPolicy;
4289
+ var mergedOptions = mergeOptions(this.options, newOptions || {});
4293
4290
  var options = useDisposableConcast
4294
- ? compact(this.options, newOptions)
4295
- : assign(this.options, compact(newOptions));
4291
+ ? mergedOptions
4292
+ : assign(this.options, mergedOptions);
4296
4293
  if (!useDisposableConcast) {
4297
4294
  this.updatePolling();
4298
4295
  if (newOptions &&
4299
4296
  newOptions.variables &&
4300
- !newOptions.fetchPolicy &&
4301
- !equal.equal(newOptions.variables, oldVariables)) {
4302
- this.applyNextFetchPolicy("variables-changed");
4297
+ !equality.equal(newOptions.variables, oldVariables) &&
4298
+ (!newOptions.fetchPolicy || newOptions.fetchPolicy === oldFetchPolicy)) {
4299
+ this.applyNextFetchPolicy("variables-changed", options);
4303
4300
  if (newNetworkStatus === void 0) {
4304
4301
  newNetworkStatus = exports.NetworkStatus.setVariables;
4305
4302
  }
@@ -4689,10 +4686,10 @@ var QueryInfo = (function () {
4689
4686
  var networkStatus = query.networkStatus || exports.NetworkStatus.loading;
4690
4687
  if (this.variables &&
4691
4688
  this.networkStatus !== exports.NetworkStatus.loading &&
4692
- !equal.equal(this.variables, query.variables)) {
4689
+ !equality.equal(this.variables, query.variables)) {
4693
4690
  networkStatus = exports.NetworkStatus.setVariables;
4694
4691
  }
4695
- if (!equal.equal(query.variables, this.variables)) {
4692
+ if (!equality.equal(query.variables, this.variables)) {
4696
4693
  this.lastDiff = void 0;
4697
4694
  }
4698
4695
  Object.assign(this, {
@@ -4718,7 +4715,7 @@ var QueryInfo = (function () {
4718
4715
  QueryInfo.prototype.getDiff = function (variables) {
4719
4716
  if (variables === void 0) { variables = this.variables; }
4720
4717
  var options = this.getDiffOptions(variables);
4721
- if (this.lastDiff && equal.equal(options, this.lastDiff.options)) {
4718
+ if (this.lastDiff && equality.equal(options, this.lastDiff.options)) {
4722
4719
  return this.lastDiff.diff;
4723
4720
  }
4724
4721
  this.updateWatch(this.variables = variables);
@@ -4752,7 +4749,7 @@ var QueryInfo = (function () {
4752
4749
  var oldDiff = this.lastDiff && this.lastDiff.diff;
4753
4750
  this.updateLastDiff(diff);
4754
4751
  if (!this.dirty &&
4755
- !equal.equal(oldDiff && oldDiff.result, diff && diff.result)) {
4752
+ !equality.equal(oldDiff && oldDiff.result, diff && diff.result)) {
4756
4753
  this.dirty = true;
4757
4754
  if (!this.notifyTimeout) {
4758
4755
  this.notifyTimeout = setTimeout(function () { return _this.notify(); }, 0);
@@ -4827,7 +4824,7 @@ var QueryInfo = (function () {
4827
4824
  }
4828
4825
  var watchOptions = tslib.__assign(tslib.__assign({}, this.getDiffOptions(variables)), { watcher: this, callback: function (diff) { return _this.setDiff(diff); } });
4829
4826
  if (!this.lastWatch ||
4830
- !equal.equal(watchOptions, this.lastWatch)) {
4827
+ !equality.equal(watchOptions, this.lastWatch)) {
4831
4828
  this.cancel();
4832
4829
  this.cancel = this.cache.watch(this.lastWatch = watchOptions);
4833
4830
  }
@@ -4839,8 +4836,8 @@ var QueryInfo = (function () {
4839
4836
  var lastWrite = this.lastWrite;
4840
4837
  return !(lastWrite &&
4841
4838
  lastWrite.dmCount === destructiveMethodCounts.get(this.cache) &&
4842
- equal.equal(variables, lastWrite.variables) &&
4843
- equal.equal(result.data, lastWrite.result.data));
4839
+ equality.equal(variables, lastWrite.variables) &&
4840
+ equality.equal(result.data, lastWrite.result.data));
4844
4841
  };
4845
4842
  QueryInfo.prototype.markResult = function (result, options, cacheWriteBehavior) {
4846
4843
  var _this = this;
@@ -5511,10 +5508,11 @@ var QueryManager = (function () {
5511
5508
  var aqr = {
5512
5509
  data: result.data,
5513
5510
  loading: false,
5514
- networkStatus: queryInfo.networkStatus || exports.NetworkStatus.ready,
5511
+ networkStatus: exports.NetworkStatus.ready,
5515
5512
  };
5516
5513
  if (hasErrors && options.errorPolicy !== "ignore") {
5517
5514
  aqr.errors = result.errors;
5515
+ aqr.networkStatus = exports.NetworkStatus.error;
5518
5516
  }
5519
5517
  return aqr;
5520
5518
  }, function (networkError) {
@@ -5645,7 +5643,7 @@ var QueryManager = (function () {
5645
5643
  var data = diff.result;
5646
5644
  if (__DEV__ &&
5647
5645
  !returnPartialData &&
5648
- !equal.equal(data, {})) {
5646
+ !equality.equal(data, {})) {
5649
5647
  logMissingFieldErrors(diff.missing);
5650
5648
  }
5651
5649
  var fromData = function (data) { return zenObservableTs.Observable.of(tslib.__assign({ data: data, loading: isNetworkRequestInFlight(networkStatus), networkStatus: networkStatus }, (diff.complete ? null : { partial: true }))); };
@@ -6108,26 +6106,9 @@ function verifyDocumentType(document, type) {
6108
6106
  "".concat(requiredOperationName, ", but a ").concat(usedOperationName, " was used instead.")) : tsInvariant.invariant(operation.type === type, 34);
6109
6107
  }
6110
6108
 
6111
- function useNormalizedOptions(optionsOrFunction) {
6112
- var optionsRef = React.useRef();
6113
- var options = optionsRef.current || Object.create(null);
6114
- if (typeof optionsOrFunction === "function") {
6115
- var newOptions = optionsOrFunction(options);
6116
- if (newOptions !== options) {
6117
- Object.assign(options, newOptions, newOptions.variables && {
6118
- variables: tslib.__assign(tslib.__assign({}, options.variables), newOptions.variables),
6119
- });
6120
- }
6121
- }
6122
- else if (optionsOrFunction && !equal__default(optionsOrFunction, options)) {
6123
- options = optionsOrFunction;
6124
- }
6125
- return optionsRef.current = options;
6126
- }
6127
-
6128
6109
  var hasOwnProperty = Object.prototype.hasOwnProperty;
6129
- function useQuery(query, optionsOrFunction) {
6130
- var options = useNormalizedOptions(optionsOrFunction);
6110
+ function useQuery(query, options) {
6111
+ if (options === void 0) { options = Object.create(null); }
6131
6112
  return useInternalState(useApolloClient(options.client), query).useQuery(options);
6132
6113
  }
6133
6114
  function useInternalState(client, query) {
@@ -6154,6 +6135,7 @@ var InternalState = (function () {
6154
6135
  InternalState.prototype.forceUpdate = function () {
6155
6136
  };
6156
6137
  InternalState.prototype.useQuery = function (options) {
6138
+ this.renderPromises = React.useContext(getApolloContext()).renderPromises;
6157
6139
  this.useOptions(options);
6158
6140
  var obsQuery = this.useObservableQuery();
6159
6141
  this.useSubscriptionEffect(obsQuery);
@@ -6162,37 +6144,55 @@ var InternalState = (function () {
6162
6144
  return this.toQueryResult(result);
6163
6145
  };
6164
6146
  InternalState.prototype.useOptions = function (options) {
6165
- this.renderPromises = React.useContext(getApolloContext()).renderPromises;
6166
6147
  var watchQueryOptions = this.createWatchQueryOptions(this.queryHookOptions = options);
6167
- if (!equal.equal(watchQueryOptions, this.watchQueryOptions)) {
6148
+ if (!equality.equal(watchQueryOptions, this.watchQueryOptions)) {
6168
6149
  this.watchQueryOptions = watchQueryOptions;
6169
6150
  }
6170
- this.ssrDisabled = !!(options && (options.ssr === false ||
6171
- options.skip));
6172
- this.onCompleted = options
6173
- && options.onCompleted
6174
- || InternalState.prototype.onCompleted;
6175
- this.onError = options
6176
- && options.onError
6177
- || InternalState.prototype.onError;
6151
+ this.ssrDisabled = !!(options.ssr === false ||
6152
+ options.skip);
6153
+ this.onCompleted = options.onCompleted || InternalState.prototype.onCompleted;
6154
+ this.onError = options.onError || InternalState.prototype.onError;
6178
6155
  };
6179
6156
  InternalState.prototype.createWatchQueryOptions = function (_a) {
6180
- var _b;
6181
6157
  if (_a === void 0) { _a = {}; }
6182
- var skip = _a.skip; _a.ssr; _a.onCompleted; _a.onError; _a.displayName; var otherOptions = tslib.__rest(_a, ["skip", "ssr", "onCompleted", "onError", "displayName"]);
6183
- var watchQueryOptions = Object.assign(otherOptions, { query: this.query });
6184
- if (skip) {
6185
- watchQueryOptions.fetchPolicy = 'standby';
6158
+ 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"]);
6159
+ var toMerge = [];
6160
+ var globalDefaults = this.client.defaultOptions.watchQuery;
6161
+ if (globalDefaults)
6162
+ toMerge.push(globalDefaults);
6163
+ if (defaultOptions)
6164
+ toMerge.push(defaultOptions);
6165
+ var latestOptions = this.observable && this.observable.options;
6166
+ if (latestOptions && toMerge.length) {
6167
+ var defaults_1 = toMerge.reduce(mergeOptions, Object.create(null));
6168
+ toMerge.length = 1;
6169
+ toMerge[0] = defaults_1;
6170
+ Object.keys(defaults_1).forEach(function (defaultOptionName) {
6171
+ var currentOptionValue = latestOptions[defaultOptionName];
6172
+ if (hasOwnProperty.call(latestOptions, defaultOptionName) &&
6173
+ !equality.equal(defaults_1[defaultOptionName], currentOptionValue)) {
6174
+ defaults_1[defaultOptionName] = defaultOptionName === "variables"
6175
+ ? tslib.__assign(tslib.__assign({}, defaults_1.variables), currentOptionValue) : currentOptionValue;
6176
+ }
6177
+ });
6186
6178
  }
6187
- else if (((_b = watchQueryOptions.context) === null || _b === void 0 ? void 0 : _b.renderPromises) &&
6179
+ toMerge.push(otherOptions);
6180
+ var merged = toMerge.reduce(mergeOptions, Object.create(null));
6181
+ var watchQueryOptions = Object.assign(merged, { query: this.query });
6182
+ if (this.renderPromises &&
6188
6183
  (watchQueryOptions.fetchPolicy === 'network-only' ||
6189
6184
  watchQueryOptions.fetchPolicy === 'cache-and-network')) {
6190
6185
  watchQueryOptions.fetchPolicy = 'cache-first';
6191
6186
  }
6192
6187
  else if (!watchQueryOptions.fetchPolicy) {
6193
- var defaultOptions = this.client.defaultOptions.watchQuery;
6194
- watchQueryOptions.fetchPolicy =
6195
- defaultOptions && defaultOptions.fetchPolicy || 'cache-first';
6188
+ watchQueryOptions.fetchPolicy = 'cache-first';
6189
+ }
6190
+ if (skip) {
6191
+ var _b = watchQueryOptions.initialFetchPolicy, initialFetchPolicy = _b === void 0 ? watchQueryOptions.fetchPolicy : _b;
6192
+ Object.assign(watchQueryOptions, {
6193
+ initialFetchPolicy: initialFetchPolicy,
6194
+ fetchPolicy: 'standby',
6195
+ });
6196
6196
  }
6197
6197
  if (!watchQueryOptions.variables) {
6198
6198
  watchQueryOptions.variables = {};
@@ -6210,6 +6210,7 @@ var InternalState = (function () {
6210
6210
  || this.client.watchQuery(this.watchQueryOptions);
6211
6211
  this.obsQueryFields = React.useMemo(function () { return ({
6212
6212
  refetch: obsQuery.refetch.bind(obsQuery),
6213
+ reobserve: obsQuery.reobserve.bind(obsQuery),
6213
6214
  fetchMore: obsQuery.fetchMore.bind(obsQuery),
6214
6215
  updateQuery: obsQuery.updateQuery.bind(obsQuery),
6215
6216
  startPolling: obsQuery.startPolling.bind(obsQuery),
@@ -6267,7 +6268,7 @@ var InternalState = (function () {
6267
6268
  if (previousResult &&
6268
6269
  previousResult.loading === result.loading &&
6269
6270
  previousResult.networkStatus === result.networkStatus &&
6270
- equal.equal(previousResult.data, result.data)) {
6271
+ equality.equal(previousResult.data, result.data)) {
6271
6272
  return;
6272
6273
  }
6273
6274
  _this.setResult(result);
@@ -6288,7 +6289,7 @@ var InternalState = (function () {
6288
6289
  var previousResult = _this.result;
6289
6290
  if (!previousResult ||
6290
6291
  (previousResult && previousResult.loading) ||
6291
- !equal.equal(error, previousResult.error)) {
6292
+ !equality.equal(error, previousResult.error)) {
6292
6293
  _this.setResult({
6293
6294
  data: (previousResult && previousResult.data),
6294
6295
  error: error,
@@ -6340,7 +6341,7 @@ var InternalState = (function () {
6340
6341
  };
6341
6342
  }
6342
6343
  else if (this.queryHookOptions.skip ||
6343
- this.queryHookOptions.fetchPolicy === 'standby') {
6344
+ this.watchQueryOptions.fetchPolicy === 'standby') {
6344
6345
  result = {
6345
6346
  loading: false,
6346
6347
  data: void 0,
@@ -6379,31 +6380,34 @@ var InternalState = (function () {
6379
6380
 
6380
6381
  var EAGER_METHODS = [
6381
6382
  'refetch',
6383
+ 'reobserve',
6382
6384
  'fetchMore',
6383
6385
  'updateQuery',
6384
6386
  'startPolling',
6385
6387
  'subscribeToMore',
6386
6388
  ];
6387
- function useLazyQuery(query, optionsOrFunction) {
6388
- var options = useNormalizedOptions(optionsOrFunction);
6389
- var _a = React.useState({
6390
- called: false,
6391
- }), execution = _a[0], setExecution = _a[1];
6392
- 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 }));
6393
- if (!execution.called) {
6394
- result = tslib.__assign(tslib.__assign({}, result), { loading: false, data: void 0, error: void 0, called: false });
6395
- }
6389
+ function useLazyQuery(query, options) {
6390
+ var internalState = useInternalState(useApolloClient(options && options.client), query);
6391
+ var execOptionsRef = React.useRef();
6392
+ var defaultOptions = internalState.client.defaultOptions.watchQuery;
6393
+ var initialFetchPolicy = (options && options.fetchPolicy) ||
6394
+ (execOptionsRef.current && execOptionsRef.current.fetchPolicy) ||
6395
+ (defaultOptions && defaultOptions.fetchPolicy) ||
6396
+ "cache-first";
6397
+ var useQueryResult = internalState.useQuery(tslib.__assign(tslib.__assign(tslib.__assign({}, options), execOptionsRef.current), { skip: !execOptionsRef.current }));
6398
+ var result = Object.assign(useQueryResult, {
6399
+ called: !!execOptionsRef.current,
6400
+ });
6396
6401
  var eagerMethods = React.useMemo(function () {
6397
6402
  var eagerMethods = {};
6398
6403
  var _loop_1 = function (key) {
6399
6404
  var method = result[key];
6400
6405
  eagerMethods[key] = function () {
6401
- var args = [];
6402
- for (var _i = 0; _i < arguments.length; _i++) {
6403
- args[_i] = arguments[_i];
6406
+ if (!execOptionsRef.current) {
6407
+ execOptionsRef.current = Object.create(null);
6408
+ internalState.forceUpdate();
6404
6409
  }
6405
- setExecution(function (execution) { return (tslib.__assign(tslib.__assign({}, execution), { called: true })); });
6406
- return method.apply(void 0, args);
6410
+ return method.apply(this, arguments);
6407
6411
  };
6408
6412
  };
6409
6413
  for (var _i = 0, EAGER_METHODS_1 = EAGER_METHODS; _i < EAGER_METHODS_1.length; _i++) {
@@ -6412,15 +6416,24 @@ function useLazyQuery(query, optionsOrFunction) {
6412
6416
  }
6413
6417
  return eagerMethods;
6414
6418
  }, []);
6415
- result.error = result.error || void 0;
6416
6419
  Object.assign(result, eagerMethods);
6417
6420
  var execute = React.useCallback(function (executeOptions) {
6418
- setExecution({ called: true, options: executeOptions });
6419
- var promise = result.refetch(executeOptions === null || executeOptions === void 0 ? void 0 : executeOptions.variables).then(function (result1) {
6420
- var result2 = tslib.__assign(tslib.__assign({}, result), { data: result1.data, error: result1.error, called: true, loading: false });
6421
- Object.assign(result2, eagerMethods);
6422
- return result2;
6423
- });
6421
+ var promise = result.reobserve(execOptionsRef.current = executeOptions ? tslib.__assign(tslib.__assign({}, executeOptions), { fetchPolicy: executeOptions.fetchPolicy || initialFetchPolicy }) : {
6422
+ fetchPolicy: initialFetchPolicy,
6423
+ }).then(function (apolloQueryResult) {
6424
+ apolloQueryResult = apolloQueryResult || internalState["getCurrentResult"]();
6425
+ if (apolloQueryResult.error ||
6426
+ isNonEmptyArray(apolloQueryResult.errors)) {
6427
+ var _a = result.observable.options.errorPolicy, errorPolicy = _a === void 0 ? "none" : _a;
6428
+ if (errorPolicy === "none") {
6429
+ throw apolloQueryResult.error || new ApolloError({
6430
+ graphQLErrors: apolloQueryResult.errors,
6431
+ });
6432
+ }
6433
+ }
6434
+ return internalState.toQueryResult(apolloQueryResult);
6435
+ }).then(function (queryResult) { return Object.assign(queryResult, eagerMethods); });
6436
+ internalState.forceUpdate();
6424
6437
  promise.catch(function () { });
6425
6438
  return promise;
6426
6439
  }, []);
@@ -6476,7 +6489,7 @@ function useMutation(mutation, options) {
6476
6489
  error: error,
6477
6490
  client: client,
6478
6491
  };
6479
- if (ref.current.isMounted && !equal.equal(ref.current.result, result_1)) {
6492
+ if (ref.current.isMounted && !equality.equal(ref.current.result, result_1)) {
6480
6493
  setResult(ref.current.result = result_1);
6481
6494
  }
6482
6495
  }
@@ -6494,7 +6507,7 @@ function useMutation(mutation, options) {
6494
6507
  called: true,
6495
6508
  client: client,
6496
6509
  };
6497
- if (!equal.equal(ref.current.result, result_2)) {
6510
+ if (!equality.equal(ref.current.result, result_2)) {
6498
6511
  setResult(ref.current.result = result_2);
6499
6512
  }
6500
6513
  }
@@ -6557,7 +6570,7 @@ function useSubscription(subscription, options) {
6557
6570
  subscription !== ref.current.subscription ||
6558
6571
  (options === null || options === void 0 ? void 0 : options.fetchPolicy) !== ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.fetchPolicy) ||
6559
6572
  !(options === null || options === void 0 ? void 0 : options.skip) !== !((_c = ref.current.options) === null || _c === void 0 ? void 0 : _c.skip) ||
6560
- !equal.equal(options === null || options === void 0 ? void 0 : options.variables, (_d = ref.current.options) === null || _d === void 0 ? void 0 : _d.variables))) {
6573
+ !equality.equal(options === null || options === void 0 ? void 0 : options.variables, (_d = ref.current.options) === null || _d === void 0 ? void 0 : _d.variables))) {
6561
6574
  setResult({
6562
6575
  loading: true,
6563
6576
  data: void 0,