@apollo/client 3.7.11 → 3.7.13

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
@@ -1360,7 +1360,7 @@ var concat = ApolloLink.concat;
1360
1360
 
1361
1361
  var execute = ApolloLink.execute;
1362
1362
 
1363
- var version = '3.7.11';
1363
+ var version = '3.7.13';
1364
1364
 
1365
1365
  function isNodeResponse(value) {
1366
1366
  return !!value.body;
@@ -1563,12 +1563,12 @@ var ApolloError = (function (_super) {
1563
1563
 
1564
1564
  var hasOwnProperty$3 = Object.prototype.hasOwnProperty;
1565
1565
  function readMultipartBody(response, observer) {
1566
- var _a, _b, _c, _d;
1566
+ var _a, _b, _c, _d, _e;
1567
1567
  return tslib.__awaiter(this, void 0, void 0, function () {
1568
- var decoder, contentType, delimiter, boundaryVal, boundary, buffer, iterator, running, _e, value, done, chunk, bi, message, i, headers, contentType_1, body, result, next;
1569
- var _f, _g;
1570
- return tslib.__generator(this, function (_h) {
1571
- switch (_h.label) {
1568
+ var decoder, contentType, delimiter, boundaryVal, boundary, buffer, iterator, running, _f, value, done, chunk, bi, message, i, headers, contentType_1, body, result, next;
1569
+ var _g, _h;
1570
+ return tslib.__generator(this, function (_j) {
1571
+ switch (_j.label) {
1572
1572
  case 0:
1573
1573
  if (TextDecoder === undefined) {
1574
1574
  throw new Error("TextDecoder must be defined in the environment: please import a polyfill.");
@@ -1583,22 +1583,22 @@ function readMultipartBody(response, observer) {
1583
1583
  buffer = "";
1584
1584
  iterator = responseIterator(response);
1585
1585
  running = true;
1586
- _h.label = 1;
1586
+ _j.label = 1;
1587
1587
  case 1:
1588
1588
  if (!running) return [3, 3];
1589
1589
  return [4, iterator.next()];
1590
1590
  case 2:
1591
- _e = _h.sent(), value = _e.value, done = _e.done;
1591
+ _f = _j.sent(), value = _f.value, done = _f.done;
1592
1592
  chunk = typeof value === "string" ? value : decoder.decode(value);
1593
1593
  running = !done;
1594
1594
  buffer += chunk;
1595
1595
  bi = buffer.indexOf(boundary);
1596
1596
  while (bi > -1) {
1597
1597
  message = void 0;
1598
- _f = [
1598
+ _g = [
1599
1599
  buffer.slice(0, bi),
1600
1600
  buffer.slice(bi + boundary.length),
1601
- ], message = _f[0], buffer = _f[1];
1601
+ ], message = _g[0], buffer = _g[1];
1602
1602
  if (message.trim()) {
1603
1603
  i = message.indexOf("\r\n\r\n");
1604
1604
  headers = parseHeaders(message.slice(0, i));
@@ -1621,7 +1621,7 @@ function readMultipartBody(response, observer) {
1621
1621
  next = tslib.__assign({}, result.payload);
1622
1622
  }
1623
1623
  if ("errors" in result) {
1624
- next = tslib.__assign(tslib.__assign({}, next), { extensions: tslib.__assign(tslib.__assign({}, ("extensions" in next ? next.extensions : null)), (_g = {}, _g[PROTOCOL_ERRORS_SYMBOL] = result.errors, _g)) });
1624
+ next = tslib.__assign(tslib.__assign({}, next), { extensions: tslib.__assign(tslib.__assign({}, ("extensions" in next ? next.extensions : null)), (_h = {}, _h[PROTOCOL_ERRORS_SYMBOL] = result.errors, _h)) });
1625
1625
  }
1626
1626
  (_b = observer.next) === null || _b === void 0 ? void 0 : _b.call(observer, next);
1627
1627
  }
@@ -1629,6 +1629,11 @@ function readMultipartBody(response, observer) {
1629
1629
  (_c = observer.next) === null || _c === void 0 ? void 0 : _c.call(observer, result);
1630
1630
  }
1631
1631
  }
1632
+ else if (Object.keys(result).length === 1 &&
1633
+ "hasNext" in result &&
1634
+ !result.hasNext) {
1635
+ (_d = observer.complete) === null || _d === void 0 ? void 0 : _d.call(observer);
1636
+ }
1632
1637
  }
1633
1638
  catch (err) {
1634
1639
  handleError(err, observer);
@@ -1638,7 +1643,7 @@ function readMultipartBody(response, observer) {
1638
1643
  }
1639
1644
  return [3, 1];
1640
1645
  case 3:
1641
- (_d = observer.complete) === null || _d === void 0 ? void 0 : _d.call(observer);
1646
+ (_e = observer.complete) === null || _e === void 0 ? void 0 : _e.call(observer);
1642
1647
  return [2];
1643
1648
  }
1644
1649
  });
@@ -7228,9 +7233,13 @@ function useSubscription(subscription, options) {
7228
7233
  if (!observable) {
7229
7234
  return;
7230
7235
  }
7236
+ var subscriptionStopped = false;
7231
7237
  var subscription = observable.subscribe({
7232
7238
  next: function (fetchResult) {
7233
7239
  var _a, _b;
7240
+ if (subscriptionStopped) {
7241
+ return;
7242
+ }
7234
7243
  var result = {
7235
7244
  loading: false,
7236
7245
  data: fetchResult.data,
@@ -7253,26 +7262,33 @@ function useSubscription(subscription, options) {
7253
7262
  },
7254
7263
  error: function (error) {
7255
7264
  var _a, _b;
7256
- setResult({
7257
- loading: false,
7258
- data: void 0,
7259
- error: error,
7260
- variables: options === null || options === void 0 ? void 0 : options.variables,
7261
- });
7262
- (_b = (_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onError) === null || _b === void 0 ? void 0 : _b.call(_a, error);
7265
+ if (!subscriptionStopped) {
7266
+ setResult({
7267
+ loading: false,
7268
+ data: void 0,
7269
+ error: error,
7270
+ variables: options === null || options === void 0 ? void 0 : options.variables,
7271
+ });
7272
+ (_b = (_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onError) === null || _b === void 0 ? void 0 : _b.call(_a, error);
7273
+ }
7263
7274
  },
7264
7275
  complete: function () {
7265
7276
  var _a, _b;
7266
- if ((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onComplete) {
7267
- ref.current.options.onComplete();
7268
- }
7269
- else if ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.onSubscriptionComplete) {
7270
- ref.current.options.onSubscriptionComplete();
7277
+ if (!subscriptionStopped) {
7278
+ if ((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onComplete) {
7279
+ ref.current.options.onComplete();
7280
+ }
7281
+ else if ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.onSubscriptionComplete) {
7282
+ ref.current.options.onSubscriptionComplete();
7283
+ }
7271
7284
  }
7272
7285
  },
7273
7286
  });
7274
7287
  return function () {
7275
- subscription.unsubscribe();
7288
+ subscriptionStopped = true;
7289
+ setTimeout(function () {
7290
+ subscription.unsubscribe();
7291
+ });
7276
7292
  };
7277
7293
  }, [observable]);
7278
7294
  return result;