@apollo/client 3.5.5 → 3.5.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (55) hide show
  1. package/apollo-client.cjs +141 -144
  2. package/apollo-client.cjs.map +1 -1
  3. package/apollo-client.min.cjs +1 -1
  4. package/cache/cache.cjs +21 -20
  5. package/cache/cache.cjs.map +1 -1
  6. package/cache/inmemory/helpers.d.ts +1 -0
  7. package/cache/inmemory/helpers.d.ts.map +1 -1
  8. package/cache/inmemory/helpers.js +3 -2
  9. package/cache/inmemory/helpers.js.map +1 -1
  10. package/cache/inmemory/key-extractor.js +5 -5
  11. package/cache/inmemory/key-extractor.js.map +1 -1
  12. package/cache/inmemory/object-canon.d.ts.map +1 -1
  13. package/cache/inmemory/object-canon.js +2 -1
  14. package/cache/inmemory/object-canon.js.map +1 -1
  15. package/cache/inmemory/policies.d.ts +1 -1
  16. package/cache/inmemory/policies.d.ts.map +1 -1
  17. package/cache/inmemory/policies.js +6 -6
  18. package/cache/inmemory/policies.js.map +1 -1
  19. package/cache/inmemory/readFromStore.js +3 -3
  20. package/cache/inmemory/readFromStore.js.map +1 -1
  21. package/cache/inmemory/writeToStore.js +7 -7
  22. package/cache/inmemory/writeToStore.js.map +1 -1
  23. package/core/ObservableQuery.d.ts.map +1 -1
  24. package/core/ObservableQuery.js +6 -3
  25. package/core/ObservableQuery.js.map +1 -1
  26. package/core/core.cjs +7 -4
  27. package/core/core.cjs.map +1 -1
  28. package/invariantErrorCodes.js +3 -3
  29. package/package.json +14 -14
  30. package/react/hooks/hooks.cjs +113 -120
  31. package/react/hooks/hooks.cjs.map +1 -1
  32. package/react/hooks/useApolloClient.js +2 -2
  33. package/react/hooks/useApolloClient.js.map +1 -1
  34. package/react/hooks/useLazyQuery.d.ts.map +1 -1
  35. package/react/hooks/useLazyQuery.js +20 -27
  36. package/react/hooks/useLazyQuery.js.map +1 -1
  37. package/react/hooks/useMutation.d.ts.map +1 -1
  38. package/react/hooks/useMutation.js +59 -68
  39. package/react/hooks/useMutation.js.map +1 -1
  40. package/react/hooks/useQuery.d.ts.map +1 -1
  41. package/react/hooks/useQuery.js +25 -17
  42. package/react/hooks/useQuery.js.map +1 -1
  43. package/react/hooks/useSubscription.d.ts.map +1 -1
  44. package/react/hooks/useSubscription.js +10 -8
  45. package/react/hooks/useSubscription.js.map +1 -1
  46. package/react/types/types.d.ts +1 -1
  47. package/react/types/types.d.ts.map +1 -1
  48. package/react/types/types.js.map +1 -1
  49. package/utilities/globals/global.d.ts +2 -8
  50. package/utilities/globals/global.d.ts.map +1 -1
  51. package/utilities/globals/global.js +1 -1
  52. package/utilities/globals/global.js.map +1 -1
  53. package/utilities/globals/globals.cjs +1 -1
  54. package/utilities/globals/globals.cjs.map +1 -1
  55. package/version.js +1 -1
package/apollo-client.cjs CHANGED
@@ -1291,7 +1291,7 @@ var concat = ApolloLink.concat;
1291
1291
 
1292
1292
  var execute = ApolloLink.execute;
1293
1293
 
1294
- var version = '3.5.5';
1294
+ var version = '3.5.9';
1295
1295
 
1296
1296
  var hasOwnProperty$2 = Object.prototype.hasOwnProperty;
1297
1297
  function parseAndCheckHttpResponse(operations) {
@@ -1726,7 +1726,7 @@ function fieldNameFromStoreName(storeFieldName) {
1726
1726
  }
1727
1727
  function selectionSetMatchesResult(selectionSet, result, variables) {
1728
1728
  if (isNonNullObject(result)) {
1729
- return Array.isArray(result)
1729
+ return isArray(result)
1730
1730
  ? result.every(function (item) { return selectionSetMatchesResult(selectionSet, item, variables); })
1731
1731
  : selectionSet.selections.every(function (field) {
1732
1732
  if (isField(field) && shouldInclude(field, variables)) {
@@ -1743,11 +1743,12 @@ function selectionSetMatchesResult(selectionSet, result, variables) {
1743
1743
  function storeValueIsStoreObject(value) {
1744
1744
  return isNonNullObject(value) &&
1745
1745
  !isReference(value) &&
1746
- !Array.isArray(value);
1746
+ !isArray(value);
1747
1747
  }
1748
1748
  function makeProcessedFieldsMerger() {
1749
1749
  return new DeepMerger;
1750
1750
  }
1751
+ var isArray = function (a) { return Array.isArray(a); };
1751
1752
 
1752
1753
  var DELETE = Object.create(null);
1753
1754
  var delModifier = function () { return DELETE; };
@@ -2210,7 +2211,7 @@ function supportsResultCaching(store) {
2210
2211
 
2211
2212
  function shallowCopy(value) {
2212
2213
  if (isNonNullObject(value)) {
2213
- return Array.isArray(value)
2214
+ return isArray(value)
2214
2215
  ? value.slice(0)
2215
2216
  : tslib.__assign({ __proto__: Object.getPrototypeOf(value) }, value);
2216
2217
  }
@@ -2473,7 +2474,7 @@ var StoreReader = (function () {
2473
2474
  _a));
2474
2475
  }
2475
2476
  }
2476
- else if (Array.isArray(fieldValue)) {
2477
+ else if (isArray(fieldValue)) {
2477
2478
  fieldValue = handleMissing(_this.executeSubSelectedArray({
2478
2479
  field: selection,
2479
2480
  array: fieldValue,
@@ -2532,7 +2533,7 @@ var StoreReader = (function () {
2532
2533
  if (item === null) {
2533
2534
  return null;
2534
2535
  }
2535
- if (Array.isArray(item)) {
2536
+ if (isArray(item)) {
2536
2537
  return handleMissing(_this.executeSubSelectedArray({
2537
2538
  field: field,
2538
2539
  array: item,
@@ -2726,13 +2727,13 @@ function getSpecifierPaths(spec) {
2726
2727
  var paths_1 = info.paths = [];
2727
2728
  var currentPath_1 = [];
2728
2729
  spec.forEach(function (s, i) {
2729
- if (Array.isArray(s)) {
2730
+ if (isArray(s)) {
2730
2731
  getSpecifierPaths(s).forEach(function (p) { return paths_1.push(currentPath_1.concat(p)); });
2731
2732
  currentPath_1.length = 0;
2732
2733
  }
2733
2734
  else {
2734
2735
  currentPath_1.push(s);
2735
- if (!Array.isArray(spec[i + 1])) {
2736
+ if (!isArray(spec[i + 1])) {
2736
2737
  paths_1.push(currentPath_1.slice(0));
2737
2738
  currentPath_1.length = 0;
2738
2739
  }
@@ -2747,14 +2748,14 @@ function extractKey(object, key) {
2747
2748
  function extractKeyPath(object, path, extract) {
2748
2749
  extract = extract || extractKey;
2749
2750
  return normalize(path.reduce(function reducer(obj, key) {
2750
- return Array.isArray(obj)
2751
+ return isArray(obj)
2751
2752
  ? obj.map(function (child) { return reducer(child, key); })
2752
2753
  : obj && extract(obj, key);
2753
2754
  }, object));
2754
2755
  }
2755
2756
  function normalize(value) {
2756
2757
  if (isNonNullObject(value)) {
2757
- if (Array.isArray(value)) {
2758
+ if (isArray(value)) {
2758
2759
  return value.map(normalize);
2759
2760
  }
2760
2761
  return collectSpecifierPaths(Object.keys(value).sort(), function (path) { return extractKeyPath(value, path); });
@@ -2817,7 +2818,7 @@ var Policies = (function () {
2817
2818
  var keyFn = policy && policy.keyFn || this.config.dataIdFromObject;
2818
2819
  while (keyFn) {
2819
2820
  var specifierOrId = keyFn(object, context);
2820
- if (Array.isArray(specifierOrId)) {
2821
+ if (isArray(specifierOrId)) {
2821
2822
  keyFn = keyFieldsFnFromSpecifier(specifierOrId);
2822
2823
  }
2823
2824
  else {
@@ -2860,7 +2861,7 @@ var Policies = (function () {
2860
2861
  setMerge(existing, incoming.merge);
2861
2862
  existing.keyFn =
2862
2863
  keyFields === false ? nullKeyFieldsFn :
2863
- Array.isArray(keyFields) ? keyFieldsFnFromSpecifier(keyFields) :
2864
+ isArray(keyFields) ? keyFieldsFnFromSpecifier(keyFields) :
2864
2865
  typeof keyFields === "function" ? keyFields :
2865
2866
  existing.keyFn;
2866
2867
  if (fields) {
@@ -2874,7 +2875,7 @@ var Policies = (function () {
2874
2875
  var keyArgs = incoming.keyArgs, read = incoming.read, merge = incoming.merge;
2875
2876
  existing.keyFn =
2876
2877
  keyArgs === false ? simpleKeyArgsFn :
2877
- Array.isArray(keyArgs) ? keyArgsFnFromSpecifier(keyArgs) :
2878
+ isArray(keyArgs) ? keyArgsFnFromSpecifier(keyArgs) :
2878
2879
  typeof keyArgs === "function" ? keyArgs :
2879
2880
  existing.keyFn;
2880
2881
  if (typeof read === "function") {
@@ -3019,7 +3020,7 @@ var Policies = (function () {
3019
3020
  var args = argsFromFieldSpecifier(fieldSpec);
3020
3021
  while (keyFn) {
3021
3022
  var specifierOrString = keyFn(args, context);
3022
- if (Array.isArray(specifierOrString)) {
3023
+ if (isArray(specifierOrString)) {
3023
3024
  keyFn = keyArgsFnFromSpecifier(specifierOrString);
3024
3025
  }
3025
3026
  else {
@@ -3140,7 +3141,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
3140
3141
  }
3141
3142
  function makeMergeObjectsFunction(store) {
3142
3143
  return function mergeObjects(existing, incoming) {
3143
- if (Array.isArray(existing) || Array.isArray(incoming)) {
3144
+ if (isArray(existing) || isArray(incoming)) {
3144
3145
  throw __DEV__ ? new tsInvariant.InvariantError("Cannot automatically merge arrays") : new tsInvariant.InvariantError(4);
3145
3146
  }
3146
3147
  if (isNonNullObject(existing) &&
@@ -3369,7 +3370,7 @@ var StoreWriter = (function () {
3369
3370
  if (!field.selectionSet || value === null) {
3370
3371
  return __DEV__ ? cloneDeep(value) : value;
3371
3372
  }
3372
- if (Array.isArray(value)) {
3373
+ if (isArray(value)) {
3373
3374
  return value.map(function (item, i) {
3374
3375
  var value = _this.processFieldValue(item, field, context, getChildMergeTree(mergeTree, i));
3375
3376
  maybeRecycleChildMergeTree(mergeTree, i);
@@ -3434,7 +3435,7 @@ var StoreWriter = (function () {
3434
3435
  var _a;
3435
3436
  var _this = this;
3436
3437
  if (mergeTree.map.size && !isReference(incoming)) {
3437
- var e_1 = (!Array.isArray(incoming) &&
3438
+ var e_1 = (!isArray(incoming) &&
3438
3439
  (isReference(existing) || storeValueIsStoreObject(existing))) ? existing : void 0;
3439
3440
  var i_1 = incoming;
3440
3441
  if (e_1 && !getStorageArgs) {
@@ -3442,7 +3443,7 @@ var StoreWriter = (function () {
3442
3443
  }
3443
3444
  var changedFields_1;
3444
3445
  var getValue_1 = function (from, name) {
3445
- return Array.isArray(from)
3446
+ return isArray(from)
3446
3447
  ? (typeof name === "number" ? from[name] : void 0)
3447
3448
  : context.store.getFieldValue(from, String(name));
3448
3449
  };
@@ -3464,7 +3465,7 @@ var StoreWriter = (function () {
3464
3465
  }
3465
3466
  });
3466
3467
  if (changedFields_1) {
3467
- incoming = (Array.isArray(i_1) ? i_1.slice(0) : tslib.__assign({}, i_1));
3468
+ incoming = (isArray(i_1) ? i_1.slice(0) : tslib.__assign({}, i_1));
3468
3469
  changedFields_1.forEach(function (value, name) {
3469
3470
  incoming[name] = value;
3470
3471
  });
@@ -3545,8 +3546,8 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
3545
3546
  return;
3546
3547
  warnings.add(typeDotName);
3547
3548
  var childTypenames = [];
3548
- if (!Array.isArray(existing) &&
3549
- !Array.isArray(incoming)) {
3549
+ if (!isArray(existing) &&
3550
+ !isArray(incoming)) {
3550
3551
  [existing, incoming].forEach(function (child) {
3551
3552
  var typename = store.getFieldValue(child, "__typename");
3552
3553
  if (typeof typename === "string" &&
@@ -4051,7 +4052,7 @@ var ObservableQuery = (function (_super) {
4051
4052
  pollInterval: 0,
4052
4053
  };
4053
4054
  var fetchPolicy = this.options.fetchPolicy;
4054
- if (fetchPolicy === 'standby' || fetchPolicy === 'cache-and-network') {
4055
+ if (fetchPolicy === 'cache-and-network') {
4055
4056
  reobserveOptions.fetchPolicy = fetchPolicy;
4056
4057
  }
4057
4058
  else if (fetchPolicy === 'no-cache') {
@@ -4291,8 +4292,11 @@ var ObservableQuery = (function (_super) {
4291
4292
  this.reportResult(this.getCurrentResult(false), this.variables);
4292
4293
  };
4293
4294
  ObservableQuery.prototype.reportResult = function (result, variables) {
4294
- if (this.getLastError() || this.isDifferentFromLastResult(result)) {
4295
- this.updateLastResult(result, variables);
4295
+ var lastError = this.getLastError();
4296
+ if (lastError || this.isDifferentFromLastResult(result)) {
4297
+ if (lastError || !result.partial || this.options.returnPartialData) {
4298
+ this.updateLastResult(result, variables);
4299
+ }
4296
4300
  iterateObserversSafely(this.observers, 'next', result);
4297
4301
  }
4298
4302
  };
@@ -5966,8 +5970,8 @@ function useApolloClient(override) {
5966
5970
  var context = React.useContext(getApolloContext());
5967
5971
  var client = override || context.client;
5968
5972
  __DEV__ ? tsInvariant.invariant(!!client, 'Could not find "client" in the context or passed in as an option. ' +
5969
- 'Wrap the root component in an <ApolloProvider>, or pass an ApolloClient' +
5970
- 'ApolloClient instance in via options.') : tsInvariant.invariant(!!client, 29);
5973
+ 'Wrap the root component in an <ApolloProvider>, or pass an ApolloClient ' +
5974
+ 'instance in via options.') : tsInvariant.invariant(!!client, 29);
5971
5975
  return client;
5972
5976
  }
5973
5977
 
@@ -6054,9 +6058,10 @@ function useQuery(query, options) {
6054
6058
  var _a;
6055
6059
  var context = React.useContext(getApolloContext());
6056
6060
  var client = useApolloClient(options === null || options === void 0 ? void 0 : options.client);
6061
+ var defaultWatchQueryOptions = client.defaultOptions.watchQuery;
6057
6062
  verifyDocumentType(query, exports.DocumentType.Query);
6058
6063
  var _b = React.useState(function () {
6059
- var watchQueryOptions = createWatchQueryOptions(query, options);
6064
+ var watchQueryOptions = createWatchQueryOptions(query, options, defaultWatchQueryOptions);
6060
6065
  var obsQuery = null;
6061
6066
  if (context.renderPromises) {
6062
6067
  obsQuery = context.renderPromises.getSSRObservable(watchQueryOptions);
@@ -6072,7 +6077,7 @@ function useQuery(query, options) {
6072
6077
  !(options === null || options === void 0 ? void 0 : options.skip) &&
6073
6078
  obsQuery.getCurrentResult().loading) {
6074
6079
  context.renderPromises.addQueryPromise({
6075
- getOptions: function () { return createWatchQueryOptions(query, options); },
6080
+ getOptions: function () { return createWatchQueryOptions(query, options, defaultWatchQueryOptions); },
6076
6081
  fetchData: function () { return new Promise(function (resolve) {
6077
6082
  var sub = obsQuery.subscribe({
6078
6083
  next: function (result) {
@@ -6113,11 +6118,11 @@ function useQuery(query, options) {
6113
6118
  options: options,
6114
6119
  result: result,
6115
6120
  previousData: void 0,
6116
- watchQueryOptions: createWatchQueryOptions(query, options),
6121
+ watchQueryOptions: createWatchQueryOptions(query, options, defaultWatchQueryOptions),
6117
6122
  });
6118
6123
  React.useEffect(function () {
6119
6124
  var _a, _b;
6120
- var watchQueryOptions = createWatchQueryOptions(query, options);
6125
+ var watchQueryOptions = createWatchQueryOptions(query, options, defaultWatchQueryOptions);
6121
6126
  var nextResult;
6122
6127
  if (ref.current.client !== client || !equality.equal(ref.current.query, query)) {
6123
6128
  var obsQuery_1 = client.watchQuery(watchQueryOptions);
@@ -6136,17 +6141,15 @@ function useQuery(query, options) {
6136
6141
  }
6137
6142
  setResult(ref.current.result = nextResult);
6138
6143
  if (!nextResult.loading && options) {
6139
- if (!result.loading) {
6140
- if (result.error) {
6141
- (_a = options.onError) === null || _a === void 0 ? void 0 : _a.call(options, result.error);
6142
- }
6143
- else if (result.data) {
6144
- (_b = options.onCompleted) === null || _b === void 0 ? void 0 : _b.call(options, result.data);
6145
- }
6144
+ if (nextResult.error) {
6145
+ (_a = options.onError) === null || _a === void 0 ? void 0 : _a.call(options, nextResult.error);
6146
+ }
6147
+ else if (nextResult.data) {
6148
+ (_b = options.onCompleted) === null || _b === void 0 ? void 0 : _b.call(options, nextResult.data);
6146
6149
  }
6147
6150
  }
6148
6151
  }
6149
- Object.assign(ref.current, { client: client, query: query, options: options });
6152
+ Object.assign(ref.current, { client: client, query: query });
6150
6153
  }, [obsQuery, client, query, options]);
6151
6154
  React.useEffect(function () {
6152
6155
  if (context.renderPromises) {
@@ -6214,8 +6217,9 @@ function useQuery(query, options) {
6214
6217
  (options === null || options === void 0 ? void 0 : options.ssr) !== false &&
6215
6218
  !(options === null || options === void 0 ? void 0 : options.skip) &&
6216
6219
  result.loading) {
6217
- obsQuery.setOptions(createWatchQueryOptions(query, options)).catch(function () { });
6220
+ obsQuery.setOptions(createWatchQueryOptions(query, options, defaultWatchQueryOptions)).catch(function () { });
6218
6221
  }
6222
+ Object.assign(ref.current, { options: options });
6219
6223
  }
6220
6224
  if ((context.renderPromises || client.disableNetworkFetches) &&
6221
6225
  (options === null || options === void 0 ? void 0 : options.ssr) === false) {
@@ -6245,12 +6249,16 @@ function useQuery(query, options) {
6245
6249
  stopPolling: obsQuery.stopPolling.bind(obsQuery),
6246
6250
  subscribeToMore: obsQuery.subscribeToMore.bind(obsQuery),
6247
6251
  }); }, [obsQuery]);
6248
- return tslib.__assign(tslib.__assign(tslib.__assign({}, obsQueryFields), { variables: obsQuery.variables, client: client, called: true, previousData: ref.current.previousData }), result);
6252
+ return tslib.__assign(tslib.__assign(tslib.__assign({}, obsQueryFields), { variables: createWatchQueryOptions(query, options, defaultWatchQueryOptions).variables, client: client, called: true, previousData: ref.current.previousData }), result);
6249
6253
  }
6250
- function createWatchQueryOptions(query, options) {
6254
+ function createWatchQueryOptions(query, options, defaultOptions) {
6251
6255
  var _a;
6252
6256
  if (options === void 0) { options = {}; }
6253
- var skip = options.skip; options.ssr; options.onCompleted; options.onError; options.displayName; var watchQueryOptions = tslib.__rest(options, ["skip", "ssr", "onCompleted", "onError", "displayName"]);
6257
+ var skip = options.skip; options.ssr; options.onCompleted; options.onError; options.displayName; var otherOptions = tslib.__rest(options, ["skip", "ssr", "onCompleted", "onError", "displayName"]);
6258
+ var watchQueryOptions = tslib.__assign({ query: query }, otherOptions);
6259
+ if (defaultOptions) {
6260
+ watchQueryOptions = mergeOptions(defaultOptions, watchQueryOptions);
6261
+ }
6254
6262
  if (skip) {
6255
6263
  watchQueryOptions.fetchPolicy = 'standby';
6256
6264
  }
@@ -6262,7 +6270,10 @@ function createWatchQueryOptions(query, options) {
6262
6270
  else if (!watchQueryOptions.fetchPolicy) {
6263
6271
  watchQueryOptions.fetchPolicy = 'cache-first';
6264
6272
  }
6265
- return tslib.__assign({ query: query }, watchQueryOptions);
6273
+ if (!watchQueryOptions.variables) {
6274
+ watchQueryOptions.variables = {};
6275
+ }
6276
+ return watchQueryOptions;
6266
6277
  }
6267
6278
 
6268
6279
  var EAGER_METHODS = [
@@ -6275,36 +6286,16 @@ var EAGER_METHODS = [
6275
6286
  function useLazyQuery(query, options) {
6276
6287
  var _a = React.useState({
6277
6288
  called: false,
6278
- resolves: [],
6279
6289
  }), execution = _a[0], setExecution = _a[1];
6280
- var execute = React.useCallback(function (executeOptions) {
6281
- var resolve;
6282
- var promise = new Promise(function (resolve1) { return (resolve = resolve1); });
6283
- setExecution(function (execution) {
6284
- if (execution.called) {
6285
- result && result.refetch(executeOptions === null || executeOptions === void 0 ? void 0 : executeOptions.variables);
6286
- }
6287
- return {
6288
- called: true,
6289
- resolves: tslib.__spreadArray(tslib.__spreadArray([], execution.resolves, true), [resolve], false),
6290
- options: executeOptions,
6291
- };
6292
- });
6293
- return promise;
6294
- }, []);
6295
6290
  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 }));
6296
- React.useEffect(function () {
6297
- var resolves = execution.resolves;
6298
- if (!result.loading && resolves.length) {
6299
- setExecution(function (execution) { return (tslib.__assign(tslib.__assign({}, execution), { resolves: [] })); });
6300
- resolves.forEach(function (resolve) { return resolve(result); });
6301
- }
6302
- }, [result, execution]);
6303
6291
  if (!execution.called) {
6304
6292
  result = tslib.__assign(tslib.__assign({}, result), { loading: false, data: void 0, error: void 0, called: false });
6293
+ }
6294
+ var eagerMethods = React.useMemo(function () {
6295
+ var eagerMethods = {};
6305
6296
  var _loop_1 = function (key) {
6306
6297
  var method = result[key];
6307
- result[key] = function () {
6298
+ eagerMethods[key] = function () {
6308
6299
  var args = [];
6309
6300
  for (var _i = 0; _i < arguments.length; _i++) {
6310
6301
  args[_i] = arguments[_i];
@@ -6317,7 +6308,20 @@ function useLazyQuery(query, options) {
6317
6308
  var key = EAGER_METHODS_1[_i];
6318
6309
  _loop_1(key);
6319
6310
  }
6320
- }
6311
+ return eagerMethods;
6312
+ }, []);
6313
+ result.error = result.error || void 0;
6314
+ Object.assign(result, eagerMethods);
6315
+ var execute = React.useCallback(function (executeOptions) {
6316
+ setExecution({ called: true, options: executeOptions });
6317
+ var promise = result.refetch(executeOptions === null || executeOptions === void 0 ? void 0 : executeOptions.variables).then(function (result1) {
6318
+ var result2 = tslib.__assign(tslib.__assign({}, result), { data: result1.data, error: result1.error, called: true, loading: false });
6319
+ Object.assign(result2, eagerMethods);
6320
+ return result2;
6321
+ });
6322
+ promise.catch(function () { });
6323
+ return promise;
6324
+ }, []);
6321
6325
  return [execute, result];
6322
6326
  }
6323
6327
 
@@ -6333,82 +6337,73 @@ function useMutation(mutation, options) {
6333
6337
  result: result,
6334
6338
  mutationId: 0,
6335
6339
  isMounted: true,
6336
- execute: null,
6337
6340
  client: client,
6338
6341
  mutation: mutation,
6339
6342
  options: options,
6340
6343
  });
6341
- var execute = React.useMemo(function () {
6342
- if (ref.current.execute != null &&
6343
- ref.current.client === client &&
6344
- equality.equal(options, ref.current.options) &&
6345
- equality.equal(mutation, ref.current.mutation)) {
6346
- return ref.current.execute;
6347
- }
6348
- ref.current.client = client;
6349
- ref.current.options = options;
6350
- ref.current.mutation = mutation;
6351
- ref.current.execute = function (executeOptions) {
6352
- if (executeOptions === void 0) { executeOptions = {}; }
6353
- var baseOptions = tslib.__assign(tslib.__assign({}, options), { mutation: mutation });
6354
- if (!ref.current.result.loading && !baseOptions.ignoreResults) {
6355
- setResult(ref.current.result = {
6356
- loading: true,
6357
- error: void 0,
6358
- data: void 0,
6344
+ {
6345
+ Object.assign(ref.current, { client: client, options: options, mutation: mutation });
6346
+ }
6347
+ var execute = React.useCallback(function (executeOptions) {
6348
+ if (executeOptions === void 0) { executeOptions = {}; }
6349
+ var _a = ref.current, client = _a.client, options = _a.options, mutation = _a.mutation;
6350
+ var baseOptions = tslib.__assign(tslib.__assign({}, options), { mutation: mutation });
6351
+ if (!ref.current.result.loading && !baseOptions.ignoreResults) {
6352
+ setResult(ref.current.result = {
6353
+ loading: true,
6354
+ error: void 0,
6355
+ data: void 0,
6356
+ called: true,
6357
+ client: client,
6358
+ });
6359
+ }
6360
+ var mutationId = ++ref.current.mutationId;
6361
+ var clientOptions = mergeOptions(baseOptions, executeOptions);
6362
+ return client.mutate(clientOptions).then(function (response) {
6363
+ var _a, _b;
6364
+ var data = response.data, errors = response.errors;
6365
+ var error = errors && errors.length > 0
6366
+ ? new ApolloError({ graphQLErrors: errors })
6367
+ : void 0;
6368
+ if (mutationId === ref.current.mutationId &&
6369
+ !clientOptions.ignoreResults) {
6370
+ var result_1 = {
6359
6371
  called: true,
6372
+ loading: false,
6373
+ data: data,
6374
+ error: error,
6360
6375
  client: client,
6361
- });
6362
- }
6363
- var mutationId = ++ref.current.mutationId;
6364
- var clientOptions = mergeOptions(baseOptions, executeOptions);
6365
- return client.mutate(clientOptions).then(function (response) {
6366
- var _a, _b;
6367
- var data = response.data, errors = response.errors;
6368
- var error = errors && errors.length > 0
6369
- ? new ApolloError({ graphQLErrors: errors })
6370
- : void 0;
6371
- if (mutationId === ref.current.mutationId &&
6372
- !clientOptions.ignoreResults) {
6373
- var result_1 = {
6374
- called: true,
6375
- loading: false,
6376
- data: data,
6377
- error: error,
6378
- client: client,
6379
- };
6380
- if (ref.current.isMounted && !equality.equal(ref.current.result, result_1)) {
6381
- setResult(ref.current.result = result_1);
6382
- }
6383
- }
6384
- (_a = baseOptions.onCompleted) === null || _a === void 0 ? void 0 : _a.call(baseOptions, response.data);
6385
- (_b = executeOptions.onCompleted) === null || _b === void 0 ? void 0 : _b.call(executeOptions, response.data);
6386
- return response;
6387
- }).catch(function (error) {
6388
- var _a, _b;
6389
- if (mutationId === ref.current.mutationId &&
6390
- ref.current.isMounted) {
6391
- var result_2 = {
6392
- loading: false,
6393
- error: error,
6394
- data: void 0,
6395
- called: true,
6396
- client: client,
6397
- };
6398
- if (!equality.equal(ref.current.result, result_2)) {
6399
- setResult(ref.current.result = result_2);
6400
- }
6376
+ };
6377
+ if (ref.current.isMounted && !equality.equal(ref.current.result, result_1)) {
6378
+ setResult(ref.current.result = result_1);
6401
6379
  }
6402
- if (baseOptions.onError || clientOptions.onError) {
6403
- (_a = baseOptions.onError) === null || _a === void 0 ? void 0 : _a.call(baseOptions, error);
6404
- (_b = executeOptions.onError) === null || _b === void 0 ? void 0 : _b.call(executeOptions, error);
6405
- return { data: void 0, errors: error };
6380
+ }
6381
+ (_a = baseOptions.onCompleted) === null || _a === void 0 ? void 0 : _a.call(baseOptions, response.data);
6382
+ (_b = executeOptions.onCompleted) === null || _b === void 0 ? void 0 : _b.call(executeOptions, response.data);
6383
+ return response;
6384
+ }).catch(function (error) {
6385
+ var _a, _b;
6386
+ if (mutationId === ref.current.mutationId &&
6387
+ ref.current.isMounted) {
6388
+ var result_2 = {
6389
+ loading: false,
6390
+ error: error,
6391
+ data: void 0,
6392
+ called: true,
6393
+ client: client,
6394
+ };
6395
+ if (!equality.equal(ref.current.result, result_2)) {
6396
+ setResult(ref.current.result = result_2);
6406
6397
  }
6407
- throw error;
6408
- });
6409
- };
6410
- return ref.current.execute;
6411
- }, [client, mutation, options]);
6398
+ }
6399
+ if (baseOptions.onError || clientOptions.onError) {
6400
+ (_a = baseOptions.onError) === null || _a === void 0 ? void 0 : _a.call(baseOptions, error);
6401
+ (_b = executeOptions.onError) === null || _b === void 0 ? void 0 : _b.call(executeOptions, error);
6402
+ return { data: void 0, errors: error };
6403
+ }
6404
+ throw error;
6405
+ });
6406
+ }, []);
6412
6407
  var reset = React.useCallback(function () {
6413
6408
  setResult({ called: false, loading: false, client: client });
6414
6409
  }, []);
@@ -6445,14 +6440,16 @@ function useSubscription(subscription, options) {
6445
6440
  if (typeof shouldResubscribe === 'function') {
6446
6441
  shouldResubscribe = !!shouldResubscribe(options);
6447
6442
  }
6448
- if ((options === null || options === void 0 ? void 0 : options.skip) && !(options === null || options === void 0 ? void 0 : options.skip) !== !((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.skip)) {
6449
- setResult({
6450
- loading: false,
6451
- data: void 0,
6452
- error: void 0,
6453
- variables: options === null || options === void 0 ? void 0 : options.variables,
6454
- });
6455
- setObservable(null);
6443
+ if (options === null || options === void 0 ? void 0 : options.skip) {
6444
+ if (!(options === null || options === void 0 ? void 0 : options.skip) !== !((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.skip)) {
6445
+ setResult({
6446
+ loading: false,
6447
+ data: void 0,
6448
+ error: void 0,
6449
+ variables: options === null || options === void 0 ? void 0 : options.variables,
6450
+ });
6451
+ setObservable(null);
6452
+ }
6456
6453
  }
6457
6454
  else if (shouldResubscribe !== false && (client !== ref.current.client ||
6458
6455
  subscription !== ref.current.subscription ||