@apollo/client 3.8.4 → 3.8.6

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 (141) hide show
  1. package/apollo-client.cjs +168 -149
  2. package/apollo-client.cjs.map +1 -1
  3. package/apollo-client.min.cjs +1 -1
  4. package/cache/cache.cjs +46 -11
  5. package/cache/cache.cjs.map +1 -1
  6. package/cache/cache.cjs.native.js +46 -11
  7. package/cache/core/types/common.d.ts +2 -2
  8. package/cache/core/types/common.d.ts.map +1 -1
  9. package/cache/core/types/common.js.map +1 -1
  10. package/cache/inmemory/entityStore.d.ts.map +1 -1
  11. package/cache/inmemory/entityStore.js +35 -0
  12. package/cache/inmemory/entityStore.js.map +1 -1
  13. package/cache/inmemory/key-extractor.js +1 -1
  14. package/cache/inmemory/policies.js +4 -4
  15. package/cache/inmemory/readFromStore.js +2 -2
  16. package/cache/inmemory/writeToStore.js +4 -4
  17. package/core/ApolloClient.js +3 -3
  18. package/core/LocalState.js +2 -2
  19. package/core/ObservableQuery.d.ts.map +1 -1
  20. package/core/ObservableQuery.js +10 -11
  21. package/core/ObservableQuery.js.map +1 -1
  22. package/core/QueryInfo.d.ts +0 -2
  23. package/core/QueryInfo.d.ts.map +1 -1
  24. package/core/QueryInfo.js +0 -2
  25. package/core/QueryInfo.js.map +1 -1
  26. package/core/QueryManager.js +11 -11
  27. package/core/QueryManager.js.map +1 -1
  28. package/core/core.cjs +27 -30
  29. package/core/core.cjs.map +1 -1
  30. package/core/core.cjs.native.js +27 -30
  31. package/dev/dev.cjs +124 -100
  32. package/dev/dev.cjs.map +1 -1
  33. package/dev/dev.cjs.native.js +124 -100
  34. package/dev/loadErrorMessageHandler.js +2 -2
  35. package/dev/loadErrorMessageHandler.js.map +1 -1
  36. package/invariantErrorCodes.js +95 -80
  37. package/link/core/ApolloLink.js +2 -2
  38. package/link/core/core.cjs +2 -2
  39. package/link/core/core.cjs.map +1 -1
  40. package/link/core/core.cjs.native.js +2 -2
  41. package/link/http/checkFetcher.js +1 -1
  42. package/link/http/createHttpLink.js +1 -1
  43. package/link/http/http.cjs +3 -3
  44. package/link/http/http.cjs.map +1 -1
  45. package/link/http/http.cjs.native.js +3 -3
  46. package/link/http/serializeFetchParameter.js +1 -1
  47. package/link/persisted-queries/index.js +2 -2
  48. package/link/persisted-queries/persisted-queries.cjs +2 -2
  49. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  50. package/link/persisted-queries/persisted-queries.cjs.native.js +2 -2
  51. package/link/utils/toPromise.js +1 -1
  52. package/link/utils/utils.cjs +2 -2
  53. package/link/utils/utils.cjs.map +1 -1
  54. package/link/utils/utils.cjs.native.js +2 -2
  55. package/link/utils/validateOperation.js +1 -1
  56. package/package.json +22 -22
  57. package/react/cache/QueryReference.d.ts.map +1 -1
  58. package/react/cache/QueryReference.js +7 -2
  59. package/react/cache/QueryReference.js.map +1 -1
  60. package/react/cache/index.d.ts +0 -4
  61. package/react/cache/index.d.ts.map +1 -1
  62. package/react/cache/index.js +0 -14
  63. package/react/cache/index.js.map +1 -1
  64. package/react/context/ApolloConsumer.js +1 -1
  65. package/react/context/ApolloContext.js +1 -1
  66. package/react/context/ApolloProvider.js +1 -1
  67. package/react/context/context.cjs +3 -3
  68. package/react/context/context.cjs.map +1 -1
  69. package/react/context/context.cjs.native.js +3 -3
  70. package/react/hoc/hoc-utils.js +1 -1
  71. package/react/hoc/hoc.cjs +2 -2
  72. package/react/hoc/hoc.cjs.map +1 -1
  73. package/react/hoc/hoc.cjs.native.js +2 -2
  74. package/react/hoc/withApollo.js +1 -1
  75. package/react/hooks/hooks.cjs +15 -10
  76. package/react/hooks/hooks.cjs.map +1 -1
  77. package/react/hooks/hooks.cjs.native.js +15 -10
  78. package/react/hooks/useApolloClient.js +1 -1
  79. package/react/hooks/useQuery.js +1 -1
  80. package/react/hooks/useReadQuery.js +1 -1
  81. package/react/hooks/useSubscription.js +2 -2
  82. package/react/hooks/useSuspenseQuery.js +2 -2
  83. package/react/hooks/useSyncExternalStore.js +1 -1
  84. package/react/index.d.ts +0 -1
  85. package/react/index.d.ts.map +1 -1
  86. package/react/index.js +0 -1
  87. package/react/index.js.map +1 -1
  88. package/react/parser/index.js +5 -5
  89. package/react/parser/parser.cjs +5 -5
  90. package/react/parser/parser.cjs.map +1 -1
  91. package/react/parser/parser.cjs.native.js +5 -5
  92. package/react/react.cjs +1 -218
  93. package/react/react.cjs.map +1 -1
  94. package/react/react.cjs.native.js +1 -218
  95. package/react/types/types.d.ts +0 -3
  96. package/react/types/types.d.ts.map +1 -1
  97. package/react/types/types.js.map +1 -1
  98. package/testing/core/core.cjs +1 -1
  99. package/testing/core/core.cjs.map +1 -1
  100. package/testing/core/core.cjs.native.js +1 -1
  101. package/testing/core/mocking/mockLink.js +1 -1
  102. package/testing/internal/ObservableStream.d.ts +26 -0
  103. package/testing/internal/ObservableStream.d.ts.map +1 -0
  104. package/testing/internal/ObservableStream.js +101 -0
  105. package/testing/internal/ObservableStream.js.map +1 -0
  106. package/testing/internal/index.d.ts +1 -0
  107. package/testing/internal/index.d.ts.map +1 -1
  108. package/testing/internal/index.js +1 -0
  109. package/testing/internal/index.js.map +1 -1
  110. package/testing/react/MockedProvider.d.ts +1 -0
  111. package/testing/react/MockedProvider.d.ts.map +1 -1
  112. package/testing/react/MockedProvider.js +2 -1
  113. package/testing/react/MockedProvider.js.map +1 -1
  114. package/testing/testing.cjs +2 -1
  115. package/testing/testing.cjs.map +1 -1
  116. package/testing/testing.cjs.native.js +2 -1
  117. package/utilities/globals/globals.cjs +29 -19
  118. package/utilities/globals/globals.cjs.map +1 -1
  119. package/utilities/globals/globals.cjs.native.js +29 -19
  120. package/utilities/globals/invariantWrappers.d.ts.map +1 -1
  121. package/utilities/globals/invariantWrappers.js +28 -18
  122. package/utilities/globals/invariantWrappers.js.map +1 -1
  123. package/utilities/graphql/DocumentTransform.js +1 -1
  124. package/utilities/graphql/directives.js +4 -4
  125. package/utilities/graphql/fragments.js +3 -3
  126. package/utilities/graphql/getFromAST.js +8 -8
  127. package/utilities/graphql/storeUtils.d.ts +5 -0
  128. package/utilities/graphql/storeUtils.d.ts.map +1 -1
  129. package/utilities/graphql/storeUtils.js +1 -1
  130. package/utilities/graphql/storeUtils.js.map +1 -1
  131. package/utilities/graphql/transform.js +2 -2
  132. package/utilities/index.d.ts +1 -1
  133. package/utilities/index.d.ts.map +1 -1
  134. package/utilities/index.js.map +1 -1
  135. package/utilities/observables/asyncMap.d.ts.map +1 -1
  136. package/utilities/observables/asyncMap.js +17 -34
  137. package/utilities/observables/asyncMap.js.map +1 -1
  138. package/utilities/utilities.cjs +36 -53
  139. package/utilities/utilities.cjs.map +1 -1
  140. package/utilities/utilities.cjs.native.js +36 -53
  141. package/version.js +1 -1
@@ -19,7 +19,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
19
19
 
20
20
  var equal__default = /*#__PURE__*/_interopDefaultLegacy(equal);
21
21
 
22
- var version = "3.8.4";
22
+ var version = "3.8.6";
23
23
 
24
24
  function isNonNullObject(obj) {
25
25
  return obj !== null && typeof obj === "object";
@@ -369,7 +369,7 @@ var ObservableQuery = (function (_super) {
369
369
  var vars = queryDef.variableDefinitions;
370
370
  if (!vars || !vars.some(function (v) { return v.variable.name.value === "variables"; })) {
371
371
  globalThis.__DEV__ !== false && globals.invariant.warn(
372
- 18,
372
+ 20,
373
373
  variables,
374
374
  ((_a = queryDef.name) === null || _a === void 0 ? void 0 : _a.value) || queryDef
375
375
  );
@@ -467,7 +467,7 @@ var ObservableQuery = (function (_super) {
467
467
  options.onError(err);
468
468
  return;
469
469
  }
470
- globalThis.__DEV__ !== false && globals.invariant.error(19, err);
470
+ globalThis.__DEV__ !== false && globals.invariant.error(21, err);
471
471
  },
472
472
  });
473
473
  this.subscriptions.add(subscription);
@@ -546,9 +546,9 @@ var ObservableQuery = (function (_super) {
546
546
  }
547
547
  return options.fetchPolicy;
548
548
  };
549
- ObservableQuery.prototype.fetch = function (options, newNetworkStatus) {
549
+ ObservableQuery.prototype.fetch = function (options, newNetworkStatus, query) {
550
550
  this.queryManager.setObservableQuery(this);
551
- return this.queryManager["fetchConcastWithInfo"](this.queryId, options, newNetworkStatus);
551
+ return this.queryManager["fetchConcastWithInfo"](this.queryId, options, newNetworkStatus, query);
552
552
  };
553
553
  ObservableQuery.prototype.updatePolling = function () {
554
554
  var _this = this;
@@ -566,7 +566,7 @@ var ObservableQuery = (function (_super) {
566
566
  if (pollingInfo && pollingInfo.interval === pollInterval) {
567
567
  return;
568
568
  }
569
- globals.invariant(pollInterval, 20);
569
+ globals.invariant(pollInterval, 22);
570
570
  var info = pollingInfo || (this.pollingInfo = {});
571
571
  info.interval = pollInterval;
572
572
  var maybeFetch = function () {
@@ -630,15 +630,14 @@ var ObservableQuery = (function (_super) {
630
630
  }
631
631
  }
632
632
  }
633
- var fetchOptions = query === options.query ? options : tslib.__assign(tslib.__assign({}, options), { query: query });
634
- this.waitForOwnResult && (this.waitForOwnResult = skipCacheDataFor(fetchOptions.fetchPolicy));
633
+ this.waitForOwnResult && (this.waitForOwnResult = skipCacheDataFor(options.fetchPolicy));
635
634
  var finishWaitingForOwnResult = function () {
636
635
  if (_this.concast === concast) {
637
636
  _this.waitForOwnResult = false;
638
637
  }
639
638
  };
640
- var variables = fetchOptions.variables && tslib.__assign({}, fetchOptions.variables);
641
- var _a = this.fetch(fetchOptions, newNetworkStatus), concast = _a.concast, fromLink = _a.fromLink;
639
+ var variables = options.variables && tslib.__assign({}, options.variables);
640
+ var _a = this.fetch(options, newNetworkStatus, query), concast = _a.concast, fromLink = _a.fromLink;
642
641
  var observer = {
643
642
  next: function (result) {
644
643
  finishWaitingForOwnResult();
@@ -732,11 +731,11 @@ function reobserveCacheFirst(obsQuery) {
732
731
  return obsQuery.reobserve();
733
732
  }
734
733
  function defaultSubscriptionObserverErrorCallback(error) {
735
- globalThis.__DEV__ !== false && globals.invariant.error(21, error.message, error.stack);
734
+ globalThis.__DEV__ !== false && globals.invariant.error(23, error.message, error.stack);
736
735
  }
737
736
  function logMissingFieldErrors(missing) {
738
737
  if (globalThis.__DEV__ !== false && missing) {
739
- globalThis.__DEV__ !== false && globals.invariant.debug(22, missing);
738
+ globalThis.__DEV__ !== false && globals.invariant.debug(24, missing);
740
739
  }
741
740
  }
742
741
  function skipCacheDataFor(fetchPolicy) {
@@ -921,7 +920,7 @@ var LocalState = (function () {
921
920
  }
922
921
  else {
923
922
  fragment = fragmentMap[selection.name.value];
924
- globals.invariant(fragment, 16, selection.name.value);
923
+ globals.invariant(fragment, 18, selection.name.value);
925
924
  }
926
925
  if (fragment && fragment.typeCondition) {
927
926
  typeCondition = fragment.typeCondition.name.value;
@@ -1034,7 +1033,7 @@ var LocalState = (function () {
1034
1033
  },
1035
1034
  FragmentSpread: function (spread, _, __, ___, ancestors) {
1036
1035
  var fragment = fragmentMap[spread.name.value];
1037
- globals.invariant(fragment, 17, spread.name.value);
1036
+ globals.invariant(fragment, 19, spread.name.value);
1038
1037
  var fragmentSelections = collectByDefinition(fragment);
1039
1038
  if (fragmentSelections.size > 0) {
1040
1039
  ancestors.forEach(function (node) {
@@ -1080,7 +1079,6 @@ var QueryInfo = (function () {
1080
1079
  this.listeners = new Set();
1081
1080
  this.document = null;
1082
1081
  this.lastRequestId = 1;
1083
- this.subscriptions = new Set();
1084
1082
  this.stopped = false;
1085
1083
  this.dirty = false;
1086
1084
  this.observableQuery = null;
@@ -1215,7 +1213,6 @@ var QueryInfo = (function () {
1215
1213
  this.reset();
1216
1214
  this.cancel();
1217
1215
  this.cancel = QueryInfo.prototype.cancel;
1218
- this.subscriptions.forEach(function (sub) { return sub.unsubscribe(); });
1219
1216
  var oq = this.observableQuery;
1220
1217
  if (oq)
1221
1218
  oq.stopPolling();
@@ -1366,7 +1363,7 @@ var QueryManager = (function () {
1366
1363
  this.queries.forEach(function (_info, queryId) {
1367
1364
  _this.stopQueryNoBroadcast(queryId);
1368
1365
  });
1369
- this.cancelPendingFetches(globals.newInvariantError(23));
1366
+ this.cancelPendingFetches(globals.newInvariantError(25));
1370
1367
  };
1371
1368
  QueryManager.prototype.cancelPendingFetches = function (error) {
1372
1369
  this.fetchCancelFns.forEach(function (cancel) { return cancel(error); });
@@ -1380,8 +1377,8 @@ var QueryManager = (function () {
1380
1377
  return tslib.__generator(this, function (_h) {
1381
1378
  switch (_h.label) {
1382
1379
  case 0:
1383
- globals.invariant(mutation, 24);
1384
- globals.invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 25);
1380
+ globals.invariant(mutation, 26);
1381
+ globals.invariant(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 27);
1385
1382
  mutationId = this.generateMutationId();
1386
1383
  mutation = this.cache.transformForLink(this.transform(mutation));
1387
1384
  hasClientExports = this.getDocumentInfo(mutation).hasClientExports;
@@ -1702,10 +1699,10 @@ var QueryManager = (function () {
1702
1699
  QueryManager.prototype.query = function (options, queryId) {
1703
1700
  var _this = this;
1704
1701
  if (queryId === void 0) { queryId = this.generateQueryId(); }
1705
- globals.invariant(options.query, 26);
1706
- globals.invariant(options.query.kind === "Document", 27);
1707
- globals.invariant(!options.returnPartialData, 28);
1708
- globals.invariant(!options.pollInterval, 29);
1702
+ globals.invariant(options.query, 28);
1703
+ globals.invariant(options.query.kind === "Document", 29);
1704
+ globals.invariant(!options.returnPartialData, 30);
1705
+ globals.invariant(!options.pollInterval, 31);
1709
1706
  return this.fetchQuery(queryId, tslib.__assign(tslib.__assign({}, options), { query: this.transform(options.query) })).finally(function () { return _this.stopQuery(queryId); });
1710
1707
  };
1711
1708
  QueryManager.prototype.generateQueryId = function () {
@@ -1730,7 +1727,7 @@ var QueryManager = (function () {
1730
1727
  if (options === void 0) { options = {
1731
1728
  discardWatches: true,
1732
1729
  }; }
1733
- this.cancelPendingFetches(globals.newInvariantError(30));
1730
+ this.cancelPendingFetches(globals.newInvariantError(32));
1734
1731
  this.queries.forEach(function (queryInfo) {
1735
1732
  if (queryInfo.observableQuery) {
1736
1733
  queryInfo.networkStatus = exports.NetworkStatus.loading;
@@ -1806,7 +1803,7 @@ var QueryManager = (function () {
1806
1803
  if (globalThis.__DEV__ !== false && queryNamesAndDocs.size) {
1807
1804
  queryNamesAndDocs.forEach(function (included, nameOrDoc) {
1808
1805
  if (!included) {
1809
- globalThis.__DEV__ !== false && globals.invariant.warn(typeof nameOrDoc === "string" ? 31 : 32, nameOrDoc);
1806
+ globalThis.__DEV__ !== false && globals.invariant.warn(typeof nameOrDoc === "string" ? 33 : 34, nameOrDoc);
1810
1807
  }
1811
1808
  });
1812
1809
  }
@@ -1994,10 +1991,10 @@ var QueryManager = (function () {
1994
1991
  throw error;
1995
1992
  });
1996
1993
  };
1997
- QueryManager.prototype.fetchConcastWithInfo = function (queryId, options, networkStatus) {
1994
+ QueryManager.prototype.fetchConcastWithInfo = function (queryId, options, networkStatus, query) {
1998
1995
  var _this = this;
1999
1996
  if (networkStatus === void 0) { networkStatus = exports.NetworkStatus.loading; }
2000
- var query = options.query;
1997
+ if (query === void 0) { query = options.query; }
2001
1998
  var variables = this.getVariables(query, options.variables);
2002
1999
  var queryInfo = this.getQuery(queryId);
2003
2000
  var defaults = this.defaultOptions.watchQuery;
@@ -2243,7 +2240,7 @@ var ApolloClient = (function () {
2243
2240
  this.resetStoreCallbacks = [];
2244
2241
  this.clearStoreCallbacks = [];
2245
2242
  if (!options.cache) {
2246
- throw globals.newInvariantError(13);
2243
+ throw globals.newInvariantError(15);
2247
2244
  }
2248
2245
  var uri = options.uri, credentials = options.credentials, headers = options.headers, cache = options.cache, documentTransform = options.documentTransform, _a = options.ssrMode, ssrMode = _a === void 0 ? false : _a, _b = options.ssrForceFetchDelay, ssrForceFetchDelay = _b === void 0 ? 0 : _b, _c = options.connectToDevTools, connectToDevTools = _c === void 0 ? typeof window === "object" &&
2249
2246
  !window.__APOLLO_CLIENT__ &&
@@ -2368,7 +2365,7 @@ var ApolloClient = (function () {
2368
2365
  if (this.defaultOptions.query) {
2369
2366
  options = utilities.mergeOptions(this.defaultOptions.query, options);
2370
2367
  }
2371
- globals.invariant(options.fetchPolicy !== "cache-and-network", 14);
2368
+ globals.invariant(options.fetchPolicy !== "cache-and-network", 16);
2372
2369
  if (this.disableNetworkFetches && options.fetchPolicy === "network-only") {
2373
2370
  options = tslib.__assign(tslib.__assign({}, options), { fetchPolicy: "cache-first" });
2374
2371
  }
@@ -2461,7 +2458,7 @@ var ApolloClient = (function () {
2461
2458
  result.queries = queries;
2462
2459
  result.results = results;
2463
2460
  result.catch(function (error) {
2464
- globalThis.__DEV__ !== false && globals.invariant.debug(15, error);
2461
+ globalThis.__DEV__ !== false && globals.invariant.debug(17, error);
2465
2462
  });
2466
2463
  return result;
2467
2464
  };