@apollo/client 3.5.8 → 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 (41) hide show
  1. package/apollo-client.cjs +40 -32
  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 +5 -2
  25. package/core/ObservableQuery.js.map +1 -1
  26. package/core/core.cjs +6 -3
  27. package/core/core.cjs.map +1 -1
  28. package/invariantErrorCodes.js +1 -1
  29. package/package.json +7 -7
  30. package/react/hooks/hooks.cjs +13 -9
  31. package/react/hooks/hooks.cjs.map +1 -1
  32. package/react/hooks/useLazyQuery.d.ts.map +1 -1
  33. package/react/hooks/useLazyQuery.js +3 -1
  34. package/react/hooks/useLazyQuery.js.map +1 -1
  35. package/react/hooks/useSubscription.d.ts.map +1 -1
  36. package/react/hooks/useSubscription.js +10 -8
  37. package/react/hooks/useSubscription.js.map +1 -1
  38. package/utilities/globals/global.d.ts +2 -8
  39. package/utilities/globals/global.d.ts.map +1 -1
  40. package/utilities/globals/global.js.map +1 -1
  41. 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.8';
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" &&
@@ -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
  };
@@ -6310,11 +6314,13 @@ function useLazyQuery(query, options) {
6310
6314
  Object.assign(result, eagerMethods);
6311
6315
  var execute = React.useCallback(function (executeOptions) {
6312
6316
  setExecution({ called: true, options: executeOptions });
6313
- return result.refetch(executeOptions === null || executeOptions === void 0 ? void 0 : executeOptions.variables).then(function (result1) {
6317
+ var promise = result.refetch(executeOptions === null || executeOptions === void 0 ? void 0 : executeOptions.variables).then(function (result1) {
6314
6318
  var result2 = tslib.__assign(tslib.__assign({}, result), { data: result1.data, error: result1.error, called: true, loading: false });
6315
6319
  Object.assign(result2, eagerMethods);
6316
6320
  return result2;
6317
6321
  });
6322
+ promise.catch(function () { });
6323
+ return promise;
6318
6324
  }, []);
6319
6325
  return [execute, result];
6320
6326
  }
@@ -6434,14 +6440,16 @@ function useSubscription(subscription, options) {
6434
6440
  if (typeof shouldResubscribe === 'function') {
6435
6441
  shouldResubscribe = !!shouldResubscribe(options);
6436
6442
  }
6437
- 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)) {
6438
- setResult({
6439
- loading: false,
6440
- data: void 0,
6441
- error: void 0,
6442
- variables: options === null || options === void 0 ? void 0 : options.variables,
6443
- });
6444
- 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
+ }
6445
6453
  }
6446
6454
  else if (shouldResubscribe !== false && (client !== ref.current.client ||
6447
6455
  subscription !== ref.current.subscription ||