@apollo/client 3.8.0-alpha.3 → 3.8.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.
package/apollo-client.cjs CHANGED
@@ -1345,7 +1345,7 @@ var concat = ApolloLink.concat;
1345
1345
 
1346
1346
  var execute = ApolloLink.execute;
1347
1347
 
1348
- var version = '3.8.0-alpha.3';
1348
+ var version = '3.8.0-alpha.4';
1349
1349
 
1350
1350
  function isNodeResponse(value) {
1351
1351
  return !!value.body;
@@ -6833,9 +6833,10 @@ var InternalState = (function () {
6833
6833
  InternalState.prototype.handleErrorOrCompleted = function (result, previousResult) {
6834
6834
  var _this = this;
6835
6835
  if (!result.loading) {
6836
+ var error_1 = this.toApolloError(result);
6836
6837
  Promise.resolve().then(function () {
6837
- if (result.error) {
6838
- _this.onError(result.error);
6838
+ if (error_1) {
6839
+ _this.onError(error_1);
6839
6840
  }
6840
6841
  else if (result.data &&
6841
6842
  (previousResult === null || previousResult === void 0 ? void 0 : previousResult.networkStatus) !== result.networkStatus &&
@@ -6847,6 +6848,11 @@ var InternalState = (function () {
6847
6848
  });
6848
6849
  }
6849
6850
  };
6851
+ InternalState.prototype.toApolloError = function (result) {
6852
+ return isNonEmptyArray(result.errors)
6853
+ ? new ApolloError({ graphQLErrors: result.errors })
6854
+ : result.error;
6855
+ };
6850
6856
  InternalState.prototype.getCurrentResult = function () {
6851
6857
  if (!this.result) {
6852
6858
  this.handleErrorOrCompleted(this.result = this.observable.getCurrentResult());
@@ -7252,9 +7258,9 @@ function useSuspenseQuery_experimental(query, options) {
7252
7258
  var hasFullResult = result.data && !result.partial;
7253
7259
  var hasPartialResult = result.data && result.partial;
7254
7260
  var usePartialResult = returnPartialData && hasPartialResult;
7261
+ var allowsThrownErrors = errorPolicy === 'none' && (!deferred || !hasPartialResult);
7255
7262
  if (result.error &&
7256
- errorPolicy === 'none' &&
7257
- (!deferred || !hasPartialResult)) {
7263
+ (result.error.networkError || allowsThrownErrors)) {
7258
7264
  throw result.error;
7259
7265
  }
7260
7266
  if (result.loading) {