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

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
@@ -1301,7 +1301,7 @@ var concat = ApolloLink.concat;
1301
1301
 
1302
1302
  var execute = ApolloLink.execute;
1303
1303
 
1304
- var version = '3.7.0-alpha.4';
1304
+ var version = '3.7.0-alpha.5';
1305
1305
 
1306
1306
  var hasOwnProperty$3 = Object.prototype.hasOwnProperty;
1307
1307
  function parseAndCheckHttpResponse(operations) {
@@ -6591,6 +6591,12 @@ function useSubscription(subscription, options) {
6591
6591
  context: options === null || options === void 0 ? void 0 : options.context,
6592
6592
  });
6593
6593
  }), observable = _b[0], setObservable = _b[1];
6594
+ var canResetObservableRef = React.useRef(false);
6595
+ React.useEffect(function () {
6596
+ return function () {
6597
+ canResetObservableRef.current = true;
6598
+ };
6599
+ }, []);
6594
6600
  var ref = React.useRef({ client: client, subscription: subscription, options: options });
6595
6601
  React.useEffect(function () {
6596
6602
  var _a, _b, _c, _d;
@@ -6599,7 +6605,7 @@ function useSubscription(subscription, options) {
6599
6605
  shouldResubscribe = !!shouldResubscribe(options);
6600
6606
  }
6601
6607
  if (options === null || options === void 0 ? void 0 : options.skip) {
6602
- if (!(options === null || options === void 0 ? void 0 : options.skip) !== !((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.skip)) {
6608
+ if (!(options === null || options === void 0 ? void 0 : options.skip) !== !((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.skip) || canResetObservableRef.current) {
6603
6609
  setResult({
6604
6610
  loading: false,
6605
6611
  data: void 0,
@@ -6607,13 +6613,16 @@ function useSubscription(subscription, options) {
6607
6613
  variables: options === null || options === void 0 ? void 0 : options.variables,
6608
6614
  });
6609
6615
  setObservable(null);
6616
+ canResetObservableRef.current = false;
6610
6617
  }
6611
6618
  }
6612
- else if (shouldResubscribe !== false && (client !== ref.current.client ||
6613
- subscription !== ref.current.subscription ||
6614
- (options === null || options === void 0 ? void 0 : options.fetchPolicy) !== ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.fetchPolicy) ||
6615
- !(options === null || options === void 0 ? void 0 : options.skip) !== !((_c = ref.current.options) === null || _c === void 0 ? void 0 : _c.skip) ||
6616
- !equality.equal(options === null || options === void 0 ? void 0 : options.variables, (_d = ref.current.options) === null || _d === void 0 ? void 0 : _d.variables))) {
6619
+ else if ((shouldResubscribe !== false &&
6620
+ (client !== ref.current.client ||
6621
+ subscription !== ref.current.subscription ||
6622
+ (options === null || options === void 0 ? void 0 : options.fetchPolicy) !== ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.fetchPolicy) ||
6623
+ !(options === null || options === void 0 ? void 0 : options.skip) !== !((_c = ref.current.options) === null || _c === void 0 ? void 0 : _c.skip) ||
6624
+ !equality.equal(options === null || options === void 0 ? void 0 : options.variables, (_d = ref.current.options) === null || _d === void 0 ? void 0 : _d.variables))) ||
6625
+ canResetObservableRef.current) {
6617
6626
  setResult({
6618
6627
  loading: true,
6619
6628
  data: void 0,
@@ -6626,9 +6635,10 @@ function useSubscription(subscription, options) {
6626
6635
  fetchPolicy: options === null || options === void 0 ? void 0 : options.fetchPolicy,
6627
6636
  context: options === null || options === void 0 ? void 0 : options.context,
6628
6637
  }));
6638
+ canResetObservableRef.current = false;
6629
6639
  }
6630
6640
  Object.assign(ref.current, { client: client, subscription: subscription, options: options });
6631
- }, [client, subscription, options]);
6641
+ }, [client, subscription, options, canResetObservableRef.current]);
6632
6642
  React.useEffect(function () {
6633
6643
  if (!observable) {
6634
6644
  return;