@apollo/client 3.7.0-alpha.3 → 3.7.0-alpha.4

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 (52) hide show
  1. package/apollo-client.cjs +26 -29
  2. package/apollo-client.cjs.map +1 -1
  3. package/apollo-client.min.cjs +1 -1
  4. package/cache/cache.cjs.native.js +2289 -0
  5. package/core/ObservableQuery.d.ts.map +1 -1
  6. package/core/ObservableQuery.js +1 -1
  7. package/core/ObservableQuery.js.map +1 -1
  8. package/core/QueryManager.d.ts.map +1 -1
  9. package/core/QueryManager.js +4 -3
  10. package/core/QueryManager.js.map +1 -1
  11. package/core/core.cjs +5 -4
  12. package/core/core.cjs.map +1 -1
  13. package/core/core.cjs.native.js +2142 -0
  14. package/errors/errors.cjs.native.js +48 -0
  15. package/invariantErrorCodes.js +1 -1
  16. package/link/batch/batch.cjs.native.js +161 -0
  17. package/link/batch-http/batch-http.cjs.native.js +127 -0
  18. package/link/context/context.cjs.native.js +38 -0
  19. package/link/core/core.cjs.native.js +121 -0
  20. package/link/error/error.cjs.native.js +90 -0
  21. package/link/http/http.cjs.native.js +320 -0
  22. package/link/persisted-queries/persisted-queries.cjs.native.js +174 -0
  23. package/link/retry/retry.cjs.native.js +170 -0
  24. package/link/schema/schema.cjs.native.js +56 -0
  25. package/link/subscriptions/subscriptions.cjs.native.js +45 -0
  26. package/link/utils/utils.cjs.native.js +115 -0
  27. package/link/ws/ws.cjs.native.js +28 -0
  28. package/main.cjs.native.js +16 -0
  29. package/package.json +4 -4
  30. package/react/components/components.cjs.native.js +79 -0
  31. package/react/context/context.cjs.native.js +67 -0
  32. package/react/hoc/hoc.cjs.native.js +325 -0
  33. package/react/hooks/hooks.cjs +4 -6
  34. package/react/hooks/hooks.cjs.map +1 -1
  35. package/react/hooks/hooks.cjs.native.js +594 -0
  36. package/react/hooks/useSyncExternalStore.d.ts.map +1 -1
  37. package/react/hooks/useSyncExternalStore.js +4 -6
  38. package/react/hooks/useSyncExternalStore.js.map +1 -1
  39. package/react/parser/parser.cjs.native.js +103 -0
  40. package/react/react.cjs.native.js +22 -0
  41. package/react/ssr/ssr.cjs.native.js +150 -0
  42. package/testing/core/core.cjs.native.js +288 -0
  43. package/testing/testing.cjs.native.js +58 -0
  44. package/utilities/globals/globals.cjs.native.js +56 -0
  45. package/utilities/observables/Concast.d.ts +5 -3
  46. package/utilities/observables/Concast.d.ts.map +1 -1
  47. package/utilities/observables/Concast.js +17 -19
  48. package/utilities/observables/Concast.js.map +1 -1
  49. package/utilities/utilities.cjs +17 -19
  50. package/utilities/utilities.cjs.map +1 -1
  51. package/utilities/utilities.cjs.native.js +1280 -0
  52. package/version.js +1 -1
package/apollo-client.cjs CHANGED
@@ -929,7 +929,6 @@ var Concast = (function (_super) {
929
929
  return function () { return _this.removeObserver(observer); };
930
930
  }) || this;
931
931
  _this.observers = new Set();
932
- _this.addCount = 0;
933
932
  _this.promise = new Promise(function (resolve, reject) {
934
933
  _this.resolve = resolve;
935
934
  _this.reject = reject;
@@ -938,6 +937,7 @@ var Concast = (function (_super) {
938
937
  next: function (result) {
939
938
  if (_this.sub !== null) {
940
939
  _this.latest = ["next", result];
940
+ _this.notify("next", result);
941
941
  iterateObserversSafely(_this.observers, "next", result);
942
942
  }
943
943
  },
@@ -949,6 +949,7 @@ var Concast = (function (_super) {
949
949
  _this.sub = null;
950
950
  _this.latest = ["error", error];
951
951
  _this.reject(error);
952
+ _this.notify("error", error);
952
953
  iterateObserversSafely(_this.observers, "error", error);
953
954
  }
954
955
  },
@@ -967,6 +968,7 @@ var Concast = (function (_super) {
967
968
  else {
968
969
  _this.resolve();
969
970
  }
971
+ _this.notify("complete");
970
972
  iterateObserversSafely(_this.observers, "complete");
971
973
  }
972
974
  else if (isPromiseLike(value)) {
@@ -978,6 +980,7 @@ var Concast = (function (_super) {
978
980
  }
979
981
  },
980
982
  };
983
+ _this.nextResultListeners = new Set();
981
984
  _this.cancel = function (reason) {
982
985
  _this.reject(reason);
983
986
  _this.sources = [];
@@ -1019,34 +1022,29 @@ var Concast = (function (_super) {
1019
1022
  if (!this.observers.has(observer)) {
1020
1023
  this.deliverLastMessage(observer);
1021
1024
  this.observers.add(observer);
1022
- ++this.addCount;
1023
1025
  }
1024
1026
  };
1025
- Concast.prototype.removeObserver = function (observer, quietly) {
1027
+ Concast.prototype.removeObserver = function (observer) {
1026
1028
  if (this.observers.delete(observer) &&
1027
- --this.addCount < 1 &&
1028
- !quietly) {
1029
+ this.observers.size < 1) {
1029
1030
  this.handlers.complete();
1030
1031
  }
1031
1032
  };
1032
- Concast.prototype.cleanup = function (callback) {
1033
- var _this = this;
1033
+ Concast.prototype.notify = function (method, arg) {
1034
+ var nextResultListeners = this.nextResultListeners;
1035
+ if (nextResultListeners.size) {
1036
+ this.nextResultListeners = new Set;
1037
+ nextResultListeners.forEach(function (listener) { return listener(method, arg); });
1038
+ }
1039
+ };
1040
+ Concast.prototype.beforeNext = function (callback) {
1034
1041
  var called = false;
1035
- var once = function () {
1042
+ this.nextResultListeners.add(function (method, arg) {
1036
1043
  if (!called) {
1037
1044
  called = true;
1038
- _this.observers.delete(observer);
1039
- callback();
1045
+ callback(method, arg);
1040
1046
  }
1041
- };
1042
- var observer = {
1043
- next: once,
1044
- error: once,
1045
- complete: once,
1046
- };
1047
- var count = this.addCount;
1048
- this.addObserver(observer);
1049
- this.addCount = count;
1047
+ });
1050
1048
  };
1051
1049
  return Concast;
1052
1050
  }(zenObservableTs.Observable));
@@ -1303,7 +1301,7 @@ var concat = ApolloLink.concat;
1303
1301
 
1304
1302
  var execute = ApolloLink.execute;
1305
1303
 
1306
- var version = '3.7.0-alpha.3';
1304
+ var version = '3.7.0-alpha.4';
1307
1305
 
1308
1306
  var hasOwnProperty$3 = Object.prototype.hasOwnProperty;
1309
1307
  function parseAndCheckHttpResponse(operations) {
@@ -4335,7 +4333,7 @@ var ObservableQuery = (function (_super) {
4335
4333
  };
4336
4334
  if (!useDisposableConcast) {
4337
4335
  if (this.concast && this.observer) {
4338
- this.concast.removeObserver(this.observer, true);
4336
+ this.concast.removeObserver(this.observer);
4339
4337
  }
4340
4338
  this.concast = concast;
4341
4339
  this.observer = observer;
@@ -5480,7 +5478,7 @@ var QueryManager = (function () {
5480
5478
  execute(link, operation)
5481
5479
  ]);
5482
5480
  byVariables_1.set(varJson_1, observable = concast);
5483
- concast.cleanup(function () {
5481
+ concast.beforeNext(function () {
5484
5482
  if (byVariables_1.delete(varJson_1) &&
5485
5483
  byVariables_1.size < 1) {
5486
5484
  inFlightLinkObservables_1.delete(serverQuery);
@@ -5515,6 +5513,7 @@ var QueryManager = (function () {
5515
5513
  };
5516
5514
  QueryManager.prototype.getResultsFromLink = function (queryInfo, cacheWriteBehavior, options) {
5517
5515
  var requestId = queryInfo.lastRequestId = this.generateRequestId();
5516
+ options = cloneDeep(options);
5518
5517
  return asyncMap(this.getObservableFromLink(queryInfo.document, options.context, options.variables), function (result) {
5519
5518
  var hasErrors = isNonEmptyArray(result.errors);
5520
5519
  if (requestId >= queryInfo.lastRequestId) {
@@ -5573,7 +5572,7 @@ var QueryManager = (function () {
5573
5572
  var concast = new Concast(this.transform(normalized.query).hasClientExports
5574
5573
  ? this.localState.addExportedVariables(normalized.query, normalized.variables, normalized.context).then(fromVariables)
5575
5574
  : fromVariables(normalized.variables));
5576
- concast.cleanup(function () {
5575
+ concast.beforeNext(function () {
5577
5576
  _this.fetchCancelFns.delete(queryId);
5578
5577
  if (queryInfo.observableQuery) {
5579
5578
  queryInfo.observableQuery["applyNextFetchPolicy"]("after-fetch", options);
@@ -6042,11 +6041,9 @@ function useApolloClient(override) {
6042
6041
  }
6043
6042
 
6044
6043
  var didWarnUncachedGetSnapshot = false;
6045
- var useSyncExternalStore = function (subscribe, getSnapshot, getServerSnapshot) {
6046
- var realHook = React__namespace.useSyncExternalStore;
6047
- if (realHook) {
6048
- return realHook(subscribe, getSnapshot, getServerSnapshot);
6049
- }
6044
+ var uSESKey = "useSyncExternalStore";
6045
+ var realHook = React__namespace[uSESKey];
6046
+ var useSyncExternalStore = realHook || (function (subscribe, getSnapshot, getServerSnapshot) {
6050
6047
  var value = getSnapshot();
6051
6048
  if (__DEV__ &&
6052
6049
  !didWarnUncachedGetSnapshot &&
@@ -6077,7 +6074,7 @@ var useSyncExternalStore = function (subscribe, getSnapshot, getServerSnapshot)
6077
6074
  });
6078
6075
  }, [subscribe]);
6079
6076
  return value;
6080
- };
6077
+ });
6081
6078
  function checkIfSnapshotChanged(_a) {
6082
6079
  var value = _a.value, getSnapshot = _a.getSnapshot;
6083
6080
  try {