@apollo/client 3.6.0 → 3.6.1

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
@@ -1298,7 +1298,7 @@ var concat = ApolloLink.concat;
1298
1298
 
1299
1299
  var execute = ApolloLink.execute;
1300
1300
 
1301
- var version = '3.6.0';
1301
+ var version = '3.6.1';
1302
1302
 
1303
1303
  var hasOwnProperty$3 = Object.prototype.hasOwnProperty;
1304
1304
  function parseAndCheckHttpResponse(operations) {
@@ -5644,7 +5644,7 @@ var QueryManager = (function () {
5644
5644
  };
5645
5645
  QueryManager.prototype.fetchQueryByPolicy = function (queryInfo, _a, networkStatus) {
5646
5646
  var _this = this;
5647
- var query = _a.query, variables = _a.variables, fetchPolicy = _a.fetchPolicy, refetchWritePolicy = _a.refetchWritePolicy, errorPolicy = _a.errorPolicy, returnPartialData = _a.returnPartialData, context = _a.context, notifyOnNetworkStatusChange = _a.notifyOnNetworkStatusChange, fetchBlockingPromise = _a.fetchBlockingPromise;
5647
+ var query = _a.query, variables = _a.variables, fetchPolicy = _a.fetchPolicy, refetchWritePolicy = _a.refetchWritePolicy, errorPolicy = _a.errorPolicy, returnPartialData = _a.returnPartialData, context = _a.context, notifyOnNetworkStatusChange = _a.notifyOnNetworkStatusChange;
5648
5648
  var oldNetworkStatus = queryInfo.networkStatus;
5649
5649
  queryInfo.init({
5650
5650
  document: this.transform(query).document,
@@ -5676,28 +5676,12 @@ var QueryManager = (function () {
5676
5676
  (networkStatus === exports.NetworkStatus.refetch &&
5677
5677
  refetchWritePolicy !== "merge") ? 1
5678
5678
  : 2;
5679
- var resultsFromLink = function () {
5680
- var get = function () { return _this.getResultsFromLink(queryInfo, cacheWriteBehavior, {
5681
- variables: variables,
5682
- context: context,
5683
- fetchPolicy: fetchPolicy,
5684
- errorPolicy: errorPolicy,
5685
- }); };
5686
- return fetchBlockingPromise ? fetchBlockingPromise.then(function (ok) { return ok ? get() : zenObservableTs.Observable.of(); }, function (error) {
5687
- var apolloError = isApolloError(error)
5688
- ? error
5689
- : new ApolloError({ clientErrors: [error] });
5690
- if (errorPolicy !== "ignore") {
5691
- queryInfo.markError(apolloError);
5692
- }
5693
- return zenObservableTs.Observable.of({
5694
- loading: false,
5695
- networkStatus: exports.NetworkStatus.error,
5696
- error: apolloError,
5697
- data: readCache().result,
5698
- });
5699
- }) : get();
5700
- };
5679
+ var resultsFromLink = function () { return _this.getResultsFromLink(queryInfo, cacheWriteBehavior, {
5680
+ variables: variables,
5681
+ context: context,
5682
+ fetchPolicy: fetchPolicy,
5683
+ errorPolicy: errorPolicy,
5684
+ }); };
5701
5685
  var shouldNotify = notifyOnNetworkStatusChange &&
5702
5686
  typeof oldNetworkStatus === "number" &&
5703
5687
  oldNetworkStatus !== networkStatus &&
@@ -6080,16 +6064,30 @@ function parser(document) {
6080
6064
  __DEV__ ? tsInvariant.invariant(!!document && !!document.kind, "Argument of ".concat(document, " passed to parser was not a valid GraphQL ") +
6081
6065
  "DocumentNode. You may need to use 'graphql-tag' or another method " +
6082
6066
  "to convert your operation into a document") : tsInvariant.invariant(!!document && !!document.kind, 30);
6083
- var fragments = document.definitions.filter(function (x) { return x.kind === 'FragmentDefinition'; });
6084
- var queries = document.definitions.filter(function (x) {
6085
- return x.kind === 'OperationDefinition' && x.operation === 'query';
6086
- });
6087
- var mutations = document.definitions.filter(function (x) {
6088
- return x.kind === 'OperationDefinition' && x.operation === 'mutation';
6089
- });
6090
- var subscriptions = document.definitions.filter(function (x) {
6091
- return x.kind === 'OperationDefinition' && x.operation === 'subscription';
6092
- });
6067
+ var fragments = [];
6068
+ var queries = [];
6069
+ var mutations = [];
6070
+ var subscriptions = [];
6071
+ for (var _i = 0, _a = document.definitions; _i < _a.length; _i++) {
6072
+ var x = _a[_i];
6073
+ if (x.kind === 'FragmentDefinition') {
6074
+ fragments.push(x);
6075
+ continue;
6076
+ }
6077
+ if (x.kind === 'OperationDefinition') {
6078
+ switch (x.operation) {
6079
+ case 'query':
6080
+ queries.push(x);
6081
+ break;
6082
+ case 'mutation':
6083
+ mutations.push(x);
6084
+ break;
6085
+ case 'subscription':
6086
+ subscriptions.push(x);
6087
+ break;
6088
+ }
6089
+ }
6090
+ }
6093
6091
  __DEV__ ? tsInvariant.invariant(!fragments.length ||
6094
6092
  (queries.length || mutations.length || subscriptions.length), "Passing only a fragment to 'graphql' is not yet supported. " +
6095
6093
  "You must include a query, subscription or mutation as well") : tsInvariant.invariant(!fragments.length ||
@@ -6228,18 +6226,14 @@ var InternalState = (function () {
6228
6226
  var _a;
6229
6227
  var watchQueryOptions = this.createWatchQueryOptions(this.queryHookOptions = options);
6230
6228
  var currentWatchQueryOptions = this.watchQueryOptions;
6231
- var resolveFetchBlockingPromise;
6232
6229
  if (!equality.equal(watchQueryOptions, currentWatchQueryOptions)) {
6233
6230
  this.watchQueryOptions = watchQueryOptions;
6234
6231
  if (currentWatchQueryOptions && this.observable) {
6235
- this.observable.reobserve(tslib.__assign({ fetchBlockingPromise: new Promise(function (resolve) {
6236
- resolveFetchBlockingPromise = resolve;
6237
- }) }, watchQueryOptions));
6232
+ this.observable.reobserve(watchQueryOptions);
6238
6233
  this.previousData = ((_a = this.result) === null || _a === void 0 ? void 0 : _a.data) || this.previousData;
6239
6234
  this.result = void 0;
6240
6235
  }
6241
6236
  }
6242
- useUnblockFetchEffect(this.renderPromises, resolveFetchBlockingPromise);
6243
6237
  this.onCompleted = options.onCompleted || InternalState.prototype.onCompleted;
6244
6238
  this.onError = options.onError || InternalState.prototype.onError;
6245
6239
  if ((this.renderPromises || this.client.disableNetworkFetches) &&
@@ -6304,15 +6298,11 @@ var InternalState = (function () {
6304
6298
  InternalState.prototype.onCompleted = function (data) { };
6305
6299
  InternalState.prototype.onError = function (error) { };
6306
6300
  InternalState.prototype.useObservableQuery = function () {
6307
- var resolveFetchBlockingPromise;
6308
6301
  var obsQuery = this.observable =
6309
6302
  this.renderPromises
6310
6303
  && this.renderPromises.getSSRObservable(this.watchQueryOptions)
6311
6304
  || this.observable
6312
- || this.client.watchQuery(tslib.__assign({ fetchBlockingPromise: new Promise(function (resolve) {
6313
- resolveFetchBlockingPromise = resolve;
6314
- }) }, this.watchQueryOptions));
6315
- useUnblockFetchEffect(this.renderPromises, resolveFetchBlockingPromise);
6305
+ || this.client.watchQuery(tslib.__assign({}, this.watchQueryOptions));
6316
6306
  this.obsQueryFields = React.useMemo(function () { return ({
6317
6307
  refetch: obsQuery.refetch.bind(obsQuery),
6318
6308
  reobserve: obsQuery.reobserve.bind(obsQuery),
@@ -6383,21 +6373,6 @@ var InternalState = (function () {
6383
6373
  };
6384
6374
  return InternalState;
6385
6375
  }());
6386
- function useUnblockFetchEffect(renderPromises, resolveFetchBlockingPromise) {
6387
- if (resolveFetchBlockingPromise) {
6388
- if (renderPromises) {
6389
- resolveFetchBlockingPromise(true);
6390
- }
6391
- else {
6392
- setTimeout(function () { return resolveFetchBlockingPromise(false); }, 5000);
6393
- }
6394
- }
6395
- React.useEffect(function () {
6396
- if (resolveFetchBlockingPromise) {
6397
- resolveFetchBlockingPromise(true);
6398
- }
6399
- }, [resolveFetchBlockingPromise]);
6400
- }
6401
6376
 
6402
6377
  var EAGER_METHODS = [
6403
6378
  'refetch',