@apollo/client 3.8.0-beta.0 → 3.8.0-beta.1

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 (101) hide show
  1. package/apollo-client.cjs +120 -120
  2. package/apollo-client.cjs.map +1 -1
  3. package/apollo-client.min.cjs +1 -1
  4. package/cache/cache.cjs +1 -2
  5. package/cache/cache.cjs.map +1 -1
  6. package/cache/cache.cjs.native.js +1 -2
  7. package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
  8. package/cache/inmemory/inMemoryCache.js +1 -2
  9. package/cache/inmemory/inMemoryCache.js.map +1 -1
  10. package/core/ApolloClient.d.ts +1 -2
  11. package/core/ApolloClient.d.ts.map +1 -1
  12. package/core/ApolloClient.js.map +1 -1
  13. package/core/LocalState.js +2 -2
  14. package/core/ObservableQuery.js +5 -5
  15. package/core/QueryManager.d.ts +1 -2
  16. package/core/QueryManager.d.ts.map +1 -1
  17. package/core/QueryManager.js +10 -11
  18. package/core/QueryManager.js.map +1 -1
  19. package/core/core.cjs +19 -84
  20. package/core/core.cjs.map +1 -1
  21. package/core/core.cjs.native.js +19 -84
  22. package/core/index.d.ts +1 -2
  23. package/core/index.d.ts.map +1 -1
  24. package/core/index.js +1 -2
  25. package/core/index.js.map +1 -1
  26. package/dev/dev.cjs +54 -54
  27. package/dev/dev.cjs.map +1 -1
  28. package/dev/dev.cjs.native.js +54 -54
  29. package/invariantErrorCodes.js +53 -53
  30. package/link/core/ApolloLink.js +2 -2
  31. package/link/core/core.cjs +2 -2
  32. package/link/core/core.cjs.map +1 -1
  33. package/link/core/core.cjs.native.js +2 -2
  34. package/link/http/checkFetcher.js +1 -1
  35. package/link/http/createHttpLink.js +1 -1
  36. package/link/http/http.cjs +3 -3
  37. package/link/http/http.cjs.map +1 -1
  38. package/link/http/http.cjs.native.js +3 -3
  39. package/link/http/serializeFetchParameter.js +1 -1
  40. package/link/persisted-queries/index.js +2 -2
  41. package/link/persisted-queries/persisted-queries.cjs +2 -2
  42. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  43. package/link/persisted-queries/persisted-queries.cjs.native.js +2 -2
  44. package/link/remove-typename/remove-typename.cjs +5 -6
  45. package/link/remove-typename/remove-typename.cjs.map +1 -1
  46. package/link/remove-typename/remove-typename.cjs.native.js +5 -6
  47. package/link/remove-typename/removeTypenameFromVariables.d.ts.map +1 -1
  48. package/link/remove-typename/removeTypenameFromVariables.js +5 -6
  49. package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
  50. package/link/utils/toPromise.js +1 -1
  51. package/link/utils/utils.cjs +2 -2
  52. package/link/utils/utils.cjs.map +1 -1
  53. package/link/utils/utils.cjs.native.js +2 -2
  54. package/link/utils/validateOperation.js +1 -1
  55. package/package.json +1 -1
  56. package/react/context/ApolloConsumer.js +1 -1
  57. package/react/context/ApolloContext.js +1 -1
  58. package/react/context/ApolloProvider.js +1 -1
  59. package/react/context/context.cjs +3 -3
  60. package/react/context/context.cjs.map +1 -1
  61. package/react/context/context.cjs.native.js +3 -3
  62. package/react/hoc/hoc-utils.js +1 -1
  63. package/react/hoc/hoc.cjs +2 -2
  64. package/react/hoc/hoc.cjs.map +1 -1
  65. package/react/hoc/hoc.cjs.native.js +2 -2
  66. package/react/hoc/withApollo.js +1 -1
  67. package/react/hooks/hooks.cjs +9 -9
  68. package/react/hooks/hooks.cjs.map +1 -1
  69. package/react/hooks/hooks.cjs.native.js +9 -9
  70. package/react/hooks/useApolloClient.js +1 -1
  71. package/react/hooks/useBackgroundQuery.js +1 -1
  72. package/react/hooks/useQuery.js +1 -1
  73. package/react/hooks/useSubscription.js +2 -2
  74. package/react/hooks/useSuspenseCache.js +1 -1
  75. package/react/hooks/useSuspenseQuery.js +2 -2
  76. package/react/hooks/useSyncExternalStore.js +1 -1
  77. package/react/parser/index.js +5 -5
  78. package/react/parser/parser.cjs +5 -5
  79. package/react/parser/parser.cjs.map +1 -1
  80. package/react/parser/parser.cjs.native.js +5 -5
  81. package/testing/core/core.cjs +1 -1
  82. package/testing/core/core.cjs.map +1 -1
  83. package/testing/core/core.cjs.native.js +1 -1
  84. package/testing/core/mocking/mockLink.js +1 -1
  85. package/utilities/globals/globals.cjs +1 -1
  86. package/utilities/globals/globals.cjs.map +1 -1
  87. package/utilities/globals/globals.cjs.native.js +1 -1
  88. package/utilities/graphql/DocumentTransform.d.ts.map +1 -0
  89. package/{core → utilities/graphql}/DocumentTransform.js +4 -3
  90. package/utilities/graphql/DocumentTransform.js.map +1 -0
  91. package/utilities/index.d.ts +1 -0
  92. package/utilities/index.d.ts.map +1 -1
  93. package/utilities/index.js +1 -0
  94. package/utilities/index.js.map +1 -1
  95. package/utilities/utilities.cjs +86 -20
  96. package/utilities/utilities.cjs.map +1 -1
  97. package/utilities/utilities.cjs.native.js +86 -20
  98. package/version.js +1 -1
  99. package/core/DocumentTransform.d.ts.map +0 -1
  100. package/core/DocumentTransform.js.map +0 -1
  101. /package/{core → utilities/graphql}/DocumentTransform.d.ts +0 -0
package/core/core.cjs CHANGED
@@ -10,7 +10,6 @@ var equal = require('@wry/equality');
10
10
  var utilities = require('../utilities');
11
11
  var cache = require('../cache');
12
12
  var errors = require('../errors');
13
- var trie = require('@wry/trie');
14
13
  var graphql = require('graphql');
15
14
  var utils = require('../link/utils');
16
15
  var tsInvariant = require('ts-invariant');
@@ -20,7 +19,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
20
19
 
21
20
  var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
22
21
 
23
- var version = '3.8.0-beta.0';
22
+ var version = '3.8.0-beta.1';
24
23
 
25
24
  function isNonNullObject(obj) {
26
25
  return obj !== null && typeof obj === 'object';
@@ -364,7 +363,7 @@ var ObservableQuery = (function (_super) {
364
363
  var vars = queryDef.variableDefinitions;
365
364
  if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
366
365
  globals.__DEV__ && globals.invariant.warn(
367
- 20,
366
+ 19,
368
367
  variables,
369
368
  ((_a = queryDef.name) === null || _a === void 0 ? void 0 : _a.value) || queryDef
370
369
  );
@@ -455,7 +454,7 @@ var ObservableQuery = (function (_super) {
455
454
  options.onError(err);
456
455
  return;
457
456
  }
458
- globals.__DEV__ && globals.invariant.error(21, err);
457
+ globals.__DEV__ && globals.invariant.error(20, err);
459
458
  },
460
459
  });
461
460
  this.subscriptions.add(subscription);
@@ -553,7 +552,7 @@ var ObservableQuery = (function (_super) {
553
552
  pollingInfo.interval === pollInterval) {
554
553
  return;
555
554
  }
556
- globals.invariant(pollInterval, 22);
555
+ globals.invariant(pollInterval, 21);
557
556
  var info = pollingInfo || (this.pollingInfo = {});
558
557
  info.interval = pollInterval;
559
558
  var maybeFetch = function () {
@@ -698,78 +697,14 @@ function reobserveCacheFirst(obsQuery) {
698
697
  return obsQuery.reobserve();
699
698
  }
700
699
  function defaultSubscriptionObserverErrorCallback(error) {
701
- globals.__DEV__ && globals.invariant.error(23, error.message, error.stack);
700
+ globals.__DEV__ && globals.invariant.error(22, error.message, error.stack);
702
701
  }
703
702
  function logMissingFieldErrors(missing) {
704
703
  if (globals.__DEV__ && missing) {
705
- globals.__DEV__ && globals.invariant.debug(24, missing);
704
+ globals.__DEV__ && globals.invariant.debug(23, missing);
706
705
  }
707
706
  }
708
707
 
709
- function identity(document) {
710
- return document;
711
- }
712
- var DocumentTransform = (function () {
713
- function DocumentTransform(transform, options) {
714
- if (options === void 0) { options = Object.create(null); }
715
- this.resultCache = utilities.canUseWeakSet
716
- ? new WeakSet()
717
- : new Set();
718
- this.transform = transform;
719
- if (options.getCacheKey) {
720
- this.getCacheKey = options.getCacheKey;
721
- }
722
- if (options.cache !== false) {
723
- this.stableCacheKeys = new trie.Trie(utilities.canUseWeakMap, function (key) { return ({ key: key }); });
724
- }
725
- }
726
- DocumentTransform.prototype.getCacheKey = function (document) {
727
- return [document];
728
- };
729
- DocumentTransform.identity = function () {
730
- return new DocumentTransform(identity, { cache: false });
731
- };
732
- DocumentTransform.split = function (predicate, left, right) {
733
- if (right === void 0) { right = DocumentTransform.identity(); }
734
- return new DocumentTransform(function (document) {
735
- var documentTransform = predicate(document) ? left : right;
736
- return documentTransform.transformDocument(document);
737
- }, { cache: false });
738
- };
739
- DocumentTransform.prototype.transformDocument = function (document) {
740
- if (this.resultCache.has(document)) {
741
- return document;
742
- }
743
- var cacheEntry = this.getStableCacheEntry(document);
744
- if (cacheEntry && cacheEntry.value) {
745
- return cacheEntry.value;
746
- }
747
- utilities.checkDocument(document);
748
- var transformedDocument = this.transform(document);
749
- this.resultCache.add(transformedDocument);
750
- if (cacheEntry) {
751
- cacheEntry.value = transformedDocument;
752
- }
753
- return transformedDocument;
754
- };
755
- DocumentTransform.prototype.concat = function (otherTransform) {
756
- var _this = this;
757
- return new DocumentTransform(function (document) {
758
- return otherTransform.transformDocument(_this.transformDocument(document));
759
- }, { cache: false });
760
- };
761
- DocumentTransform.prototype.getStableCacheEntry = function (document) {
762
- if (!this.stableCacheKeys)
763
- return;
764
- var cacheKeys = this.getCacheKey(document);
765
- if (cacheKeys) {
766
- globals.invariant(Array.isArray(cacheKeys), 17);
767
- return this.stableCacheKeys.lookupArray(cacheKeys);
768
- }
769
- };
770
- return DocumentTransform;
771
- }());
772
-
773
708
  var LocalState = (function () {
774
709
  function LocalState(_a) {
775
710
  var cache = _a.cache, client = _a.client, resolvers = _a.resolvers, fragmentMatcher = _a.fragmentMatcher;
@@ -945,7 +880,7 @@ var LocalState = (function () {
945
880
  }
946
881
  else {
947
882
  fragment = fragmentMap[selection.name.value];
948
- globals.invariant(fragment, 18, selection.name.value);
883
+ globals.invariant(fragment, 17, selection.name.value);
949
884
  }
950
885
  if (fragment && fragment.typeCondition) {
951
886
  typeCondition = fragment.typeCondition.name.value;
@@ -1058,7 +993,7 @@ var LocalState = (function () {
1058
993
  },
1059
994
  FragmentSpread: function (spread, _, __, ___, ancestors) {
1060
995
  var fragment = fragmentMap[spread.name.value];
1061
- globals.invariant(fragment, 19, spread.name.value);
996
+ globals.invariant(fragment, 18, spread.name.value);
1062
997
  var fragmentSelections = collectByDefinition(fragment);
1063
998
  if (fragmentSelections.size > 0) {
1064
999
  ancestors.forEach(function (node) {
@@ -1372,7 +1307,7 @@ var QueryManager = (function () {
1372
1307
  this.requestIdCounter = 1;
1373
1308
  this.mutationIdCounter = 1;
1374
1309
  this.inFlightLinkObservables = new Map();
1375
- var defaultDocumentTransform = new DocumentTransform(function (document) { return _this.cache.transformDocument(document); }, { cache: false });
1310
+ var defaultDocumentTransform = new utilities.DocumentTransform(function (document) { return _this.cache.transformDocument(document); }, { cache: false });
1376
1311
  this.cache = cache;
1377
1312
  this.link = link;
1378
1313
  this.defaultOptions = defaultOptions || Object.create(null);
@@ -1395,7 +1330,7 @@ var QueryManager = (function () {
1395
1330
  this.queries.forEach(function (_info, queryId) {
1396
1331
  _this.stopQueryNoBroadcast(queryId);
1397
1332
  });
1398
- this.cancelPendingFetches(globals.newInvariantError(25));
1333
+ this.cancelPendingFetches(globals.newInvariantError(24));
1399
1334
  };
1400
1335
  QueryManager.prototype.cancelPendingFetches = function (error) {
1401
1336
  this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
@@ -1409,9 +1344,9 @@ var QueryManager = (function () {
1409
1344
  return tslib.__generator(this, function (_h) {
1410
1345
  switch (_h.label) {
1411
1346
  case 0:
1412
- globals.invariant(mutation, 26);
1347
+ globals.invariant(mutation, 25);
1413
1348
  globals.invariant(fetchPolicy === 'network-only' ||
1414
- fetchPolicy === 'no-cache', 27);
1349
+ fetchPolicy === 'no-cache', 26);
1415
1350
  mutationId = this.generateMutationId();
1416
1351
  mutation = this.cache.transformForLink(this.transform(mutation));
1417
1352
  hasClientExports = this.getDocumentInfo(mutation).hasClientExports;
@@ -1729,10 +1664,10 @@ var QueryManager = (function () {
1729
1664
  QueryManager.prototype.query = function (options, queryId) {
1730
1665
  var _this = this;
1731
1666
  if (queryId === void 0) { queryId = this.generateQueryId(); }
1732
- globals.invariant(options.query, 28);
1733
- globals.invariant(options.query.kind === 'Document', 29);
1734
- globals.invariant(!options.returnPartialData, 30);
1735
- globals.invariant(!options.pollInterval, 31);
1667
+ globals.invariant(options.query, 27);
1668
+ globals.invariant(options.query.kind === 'Document', 28);
1669
+ globals.invariant(!options.returnPartialData, 29);
1670
+ globals.invariant(!options.pollInterval, 30);
1736
1671
  return this.fetchQuery(queryId, tslib.__assign(tslib.__assign({}, options), { query: this.transform(options.query) })).finally(function () { return _this.stopQuery(queryId); });
1737
1672
  };
1738
1673
  QueryManager.prototype.generateQueryId = function () {
@@ -1757,7 +1692,7 @@ var QueryManager = (function () {
1757
1692
  if (options === void 0) { options = {
1758
1693
  discardWatches: true,
1759
1694
  }; }
1760
- this.cancelPendingFetches(globals.newInvariantError(32));
1695
+ this.cancelPendingFetches(globals.newInvariantError(31));
1761
1696
  this.queries.forEach(function (queryInfo) {
1762
1697
  if (queryInfo.observableQuery) {
1763
1698
  queryInfo.networkStatus = exports.NetworkStatus.loading;
@@ -1833,7 +1768,7 @@ var QueryManager = (function () {
1833
1768
  if (globals.__DEV__ && queryNamesAndDocs.size) {
1834
1769
  queryNamesAndDocs.forEach(function (included, nameOrDoc) {
1835
1770
  if (!included) {
1836
- globals.__DEV__ && globals.invariant.warn(typeof nameOrDoc === "string" ? 33 : 34, nameOrDoc);
1771
+ globals.__DEV__ && globals.invariant.warn(typeof nameOrDoc === "string" ? 32 : 33, nameOrDoc);
1837
1772
  }
1838
1773
  });
1839
1774
  }
@@ -2480,6 +2415,7 @@ var ApolloClient = (function () {
2480
2415
 
2481
2416
  tsInvariant.setVerbosity(globals.__DEV__ ? "log" : "silent");
2482
2417
 
2418
+ exports.DocumentTransform = utilities.DocumentTransform;
2483
2419
  exports.Observable = utilities.Observable;
2484
2420
  exports.isReference = utilities.isReference;
2485
2421
  exports.makeReference = utilities.makeReference;
@@ -2503,7 +2439,6 @@ exports.enableExperimentalFragmentVariables = graphqlTag.enableExperimentalFragm
2503
2439
  exports.gql = graphqlTag.gql;
2504
2440
  exports.resetCaches = graphqlTag.resetCaches;
2505
2441
  exports.ApolloClient = ApolloClient;
2506
- exports.DocumentTransform = DocumentTransform;
2507
2442
  exports.ObservableQuery = ObservableQuery;
2508
2443
  exports.isNetworkRequestSettled = isNetworkRequestSettled;
2509
2444
  for (var k in core) {