@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/cache/cache.cjs CHANGED
@@ -147,7 +147,7 @@ function fieldNameFromStoreName(storeFieldName) {
147
147
  }
148
148
  function selectionSetMatchesResult(selectionSet, result, variables) {
149
149
  if (utilities.isNonNullObject(result)) {
150
- return Array.isArray(result)
150
+ return isArray(result)
151
151
  ? result.every(function (item) { return selectionSetMatchesResult(selectionSet, item, variables); })
152
152
  : selectionSet.selections.every(function (field) {
153
153
  if (utilities.isField(field) && utilities.shouldInclude(field, variables)) {
@@ -164,11 +164,12 @@ function selectionSetMatchesResult(selectionSet, result, variables) {
164
164
  function storeValueIsStoreObject(value) {
165
165
  return utilities.isNonNullObject(value) &&
166
166
  !utilities.isReference(value) &&
167
- !Array.isArray(value);
167
+ !isArray(value);
168
168
  }
169
169
  function makeProcessedFieldsMerger() {
170
170
  return new utilities.DeepMerger;
171
171
  }
172
+ var isArray = function (a) { return Array.isArray(a); };
172
173
 
173
174
  var DELETE = Object.create(null);
174
175
  var delModifier = function () { return DELETE; };
@@ -631,7 +632,7 @@ function supportsResultCaching(store) {
631
632
 
632
633
  function shallowCopy(value) {
633
634
  if (utilities.isNonNullObject(value)) {
634
- return Array.isArray(value)
635
+ return isArray(value)
635
636
  ? value.slice(0)
636
637
  : tslib.__assign({ __proto__: Object.getPrototypeOf(value) }, value);
637
638
  }
@@ -894,7 +895,7 @@ var StoreReader = (function () {
894
895
  _a));
895
896
  }
896
897
  }
897
- else if (Array.isArray(fieldValue)) {
898
+ else if (isArray(fieldValue)) {
898
899
  fieldValue = handleMissing(_this.executeSubSelectedArray({
899
900
  field: selection,
900
901
  array: fieldValue,
@@ -953,7 +954,7 @@ var StoreReader = (function () {
953
954
  if (item === null) {
954
955
  return null;
955
956
  }
956
- if (Array.isArray(item)) {
957
+ if (isArray(item)) {
957
958
  return handleMissing(_this.executeSubSelectedArray({
958
959
  field: field,
959
960
  array: item,
@@ -1147,13 +1148,13 @@ function getSpecifierPaths(spec) {
1147
1148
  var paths_1 = info.paths = [];
1148
1149
  var currentPath_1 = [];
1149
1150
  spec.forEach(function (s, i) {
1150
- if (Array.isArray(s)) {
1151
+ if (isArray(s)) {
1151
1152
  getSpecifierPaths(s).forEach(function (p) { return paths_1.push(currentPath_1.concat(p)); });
1152
1153
  currentPath_1.length = 0;
1153
1154
  }
1154
1155
  else {
1155
1156
  currentPath_1.push(s);
1156
- if (!Array.isArray(spec[i + 1])) {
1157
+ if (!isArray(spec[i + 1])) {
1157
1158
  paths_1.push(currentPath_1.slice(0));
1158
1159
  currentPath_1.length = 0;
1159
1160
  }
@@ -1168,14 +1169,14 @@ function extractKey(object, key) {
1168
1169
  function extractKeyPath(object, path, extract) {
1169
1170
  extract = extract || extractKey;
1170
1171
  return normalize(path.reduce(function reducer(obj, key) {
1171
- return Array.isArray(obj)
1172
+ return isArray(obj)
1172
1173
  ? obj.map(function (child) { return reducer(child, key); })
1173
1174
  : obj && extract(obj, key);
1174
1175
  }, object));
1175
1176
  }
1176
1177
  function normalize(value) {
1177
1178
  if (utilities.isNonNullObject(value)) {
1178
- if (Array.isArray(value)) {
1179
+ if (isArray(value)) {
1179
1180
  return value.map(normalize);
1180
1181
  }
1181
1182
  return collectSpecifierPaths(Object.keys(value).sort(), function (path) { return extractKeyPath(value, path); });
@@ -1238,7 +1239,7 @@ var Policies = (function () {
1238
1239
  var keyFn = policy && policy.keyFn || this.config.dataIdFromObject;
1239
1240
  while (keyFn) {
1240
1241
  var specifierOrId = keyFn(object, context);
1241
- if (Array.isArray(specifierOrId)) {
1242
+ if (isArray(specifierOrId)) {
1242
1243
  keyFn = keyFieldsFnFromSpecifier(specifierOrId);
1243
1244
  }
1244
1245
  else {
@@ -1281,7 +1282,7 @@ var Policies = (function () {
1281
1282
  setMerge(existing, incoming.merge);
1282
1283
  existing.keyFn =
1283
1284
  keyFields === false ? nullKeyFieldsFn :
1284
- Array.isArray(keyFields) ? keyFieldsFnFromSpecifier(keyFields) :
1285
+ isArray(keyFields) ? keyFieldsFnFromSpecifier(keyFields) :
1285
1286
  typeof keyFields === "function" ? keyFields :
1286
1287
  existing.keyFn;
1287
1288
  if (fields) {
@@ -1295,7 +1296,7 @@ var Policies = (function () {
1295
1296
  var keyArgs = incoming.keyArgs, read = incoming.read, merge = incoming.merge;
1296
1297
  existing.keyFn =
1297
1298
  keyArgs === false ? simpleKeyArgsFn :
1298
- Array.isArray(keyArgs) ? keyArgsFnFromSpecifier(keyArgs) :
1299
+ isArray(keyArgs) ? keyArgsFnFromSpecifier(keyArgs) :
1299
1300
  typeof keyArgs === "function" ? keyArgs :
1300
1301
  existing.keyFn;
1301
1302
  if (typeof read === "function") {
@@ -1440,7 +1441,7 @@ var Policies = (function () {
1440
1441
  var args = argsFromFieldSpecifier(fieldSpec);
1441
1442
  while (keyFn) {
1442
1443
  var specifierOrString = keyFn(args, context);
1443
- if (Array.isArray(specifierOrString)) {
1444
+ if (isArray(specifierOrString)) {
1444
1445
  keyFn = keyArgsFnFromSpecifier(specifierOrString);
1445
1446
  }
1446
1447
  else {
@@ -1561,7 +1562,7 @@ function normalizeReadFieldOptions(readFieldArgs, objectOrReference, variables)
1561
1562
  }
1562
1563
  function makeMergeObjectsFunction(store) {
1563
1564
  return function mergeObjects(existing, incoming) {
1564
- if (Array.isArray(existing) || Array.isArray(incoming)) {
1565
+ if (isArray(existing) || isArray(incoming)) {
1565
1566
  throw __DEV__ ? new globals.InvariantError("Cannot automatically merge arrays") : new globals.InvariantError(4);
1566
1567
  }
1567
1568
  if (utilities.isNonNullObject(existing) &&
@@ -1790,7 +1791,7 @@ var StoreWriter = (function () {
1790
1791
  if (!field.selectionSet || value === null) {
1791
1792
  return __DEV__ ? utilities.cloneDeep(value) : value;
1792
1793
  }
1793
- if (Array.isArray(value)) {
1794
+ if (isArray(value)) {
1794
1795
  return value.map(function (item, i) {
1795
1796
  var value = _this.processFieldValue(item, field, context, getChildMergeTree(mergeTree, i));
1796
1797
  maybeRecycleChildMergeTree(mergeTree, i);
@@ -1855,7 +1856,7 @@ var StoreWriter = (function () {
1855
1856
  var _a;
1856
1857
  var _this = this;
1857
1858
  if (mergeTree.map.size && !utilities.isReference(incoming)) {
1858
- var e_1 = (!Array.isArray(incoming) &&
1859
+ var e_1 = (!isArray(incoming) &&
1859
1860
  (utilities.isReference(existing) || storeValueIsStoreObject(existing))) ? existing : void 0;
1860
1861
  var i_1 = incoming;
1861
1862
  if (e_1 && !getStorageArgs) {
@@ -1863,7 +1864,7 @@ var StoreWriter = (function () {
1863
1864
  }
1864
1865
  var changedFields_1;
1865
1866
  var getValue_1 = function (from, name) {
1866
- return Array.isArray(from)
1867
+ return isArray(from)
1867
1868
  ? (typeof name === "number" ? from[name] : void 0)
1868
1869
  : context.store.getFieldValue(from, String(name));
1869
1870
  };
@@ -1885,7 +1886,7 @@ var StoreWriter = (function () {
1885
1886
  }
1886
1887
  });
1887
1888
  if (changedFields_1) {
1888
- incoming = (Array.isArray(i_1) ? i_1.slice(0) : tslib.__assign({}, i_1));
1889
+ incoming = (isArray(i_1) ? i_1.slice(0) : tslib.__assign({}, i_1));
1889
1890
  changedFields_1.forEach(function (value, name) {
1890
1891
  incoming[name] = value;
1891
1892
  });
@@ -1966,8 +1967,8 @@ function warnAboutDataLoss(existingRef, incomingObj, storeFieldName, store) {
1966
1967
  return;
1967
1968
  warnings.add(typeDotName);
1968
1969
  var childTypenames = [];
1969
- if (!Array.isArray(existing) &&
1970
- !Array.isArray(incoming)) {
1970
+ if (!isArray(existing) &&
1971
+ !isArray(incoming)) {
1971
1972
  [existing, incoming].forEach(function (child) {
1972
1973
  var typename = store.getFieldValue(child, "__typename");
1973
1974
  if (typeof typename === "string" &&