@apollo/client 3.7.0-alpha.0 → 3.7.0-alpha.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.
Files changed (39) hide show
  1. package/LICENSE +1 -1
  2. package/apollo-client.cjs +39 -64
  3. package/apollo-client.cjs.map +1 -1
  4. package/apollo-client.min.cjs +1 -1
  5. package/core/QueryManager.d.ts.map +1 -1
  6. package/core/QueryManager.js +7 -23
  7. package/core/QueryManager.js.map +1 -1
  8. package/core/core.cjs +8 -24
  9. package/core/core.cjs.map +1 -1
  10. package/core/watchQueryOptions.d.ts +0 -1
  11. package/core/watchQueryOptions.d.ts.map +1 -1
  12. package/core/watchQueryOptions.js.map +1 -1
  13. package/invariantErrorCodes.js +1 -1
  14. package/link/persisted-queries/index.d.ts +2 -1
  15. package/link/persisted-queries/index.d.ts.map +1 -1
  16. package/link/persisted-queries/index.js +26 -13
  17. package/link/persisted-queries/index.js.map +1 -1
  18. package/link/persisted-queries/persisted-queries.cjs +25 -12
  19. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  20. package/package.json +11 -11
  21. package/react/context/ApolloConsumer.js +2 -2
  22. package/react/context/ApolloProvider.js +2 -2
  23. package/react/context/context.cjs +4 -4
  24. package/react/context/context.cjs.map +1 -1
  25. package/react/hooks/hooks.cjs +3 -26
  26. package/react/hooks/hooks.cjs.map +1 -1
  27. package/react/hooks/useQuery.d.ts.map +1 -1
  28. package/react/hooks/useQuery.js +4 -27
  29. package/react/hooks/useQuery.js.map +1 -1
  30. package/react/parser/index.d.ts.map +1 -1
  31. package/react/parser/index.js +24 -10
  32. package/react/parser/index.js.map +1 -1
  33. package/react/parser/parser.cjs +24 -10
  34. package/react/parser/parser.cjs.map +1 -1
  35. package/testing/core/mocking/mockQueryManager.js +1 -1
  36. package/testing/core/mocking/mockWatchQuery.js +1 -1
  37. package/testing/core/wrap.js +1 -1
  38. package/utilities/globals/global.js +1 -2
  39. package/version.js +1 -1
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2021 Apollo Graph, Inc. (Formerly Meteor Development Group, Inc.)
3
+ Copyright (c) 2022 Apollo Graph, Inc. (Formerly Meteor Development Group, Inc.)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
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.7.0-alpha.0';
1301
+ var version = '3.7.0-alpha.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 &&
@@ -6020,17 +6004,17 @@ function getApolloContext() {
6020
6004
 
6021
6005
  var ApolloConsumer = function (props) {
6022
6006
  var ApolloContext = getApolloContext();
6023
- return React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
6007
+ return (React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
6024
6008
  __DEV__ ? tsInvariant.invariant(context && context.client, 'Could not find "client" in the context of ApolloConsumer. ' +
6025
6009
  'Wrap the root component in an <ApolloProvider>.') : tsInvariant.invariant(context && context.client, 25);
6026
6010
  return props.children(context.client);
6027
- });
6011
+ }));
6028
6012
  };
6029
6013
 
6030
6014
  var ApolloProvider = function (_a) {
6031
6015
  var client = _a.client, children = _a.children;
6032
6016
  var ApolloContext = getApolloContext();
6033
- return React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
6017
+ return (React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
6034
6018
  if (context === void 0) { context = {}; }
6035
6019
  if (client && context.client !== client) {
6036
6020
  context = Object.assign({}, context, { client: client });
@@ -6038,7 +6022,7 @@ var ApolloProvider = function (_a) {
6038
6022
  __DEV__ ? tsInvariant.invariant(context.client, 'ApolloProvider was not passed a client instance. Make ' +
6039
6023
  'sure you pass in your client via the "client" prop.') : tsInvariant.invariant(context.client, 26);
6040
6024
  return (React__namespace.createElement(ApolloContext.Provider, { value: context }, children));
6041
- });
6025
+ }));
6042
6026
  };
6043
6027
 
6044
6028
  function useApolloClient(override) {
@@ -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 ||
@@ -6220,7 +6218,7 @@ var InternalState = (function () {
6220
6218
  obsQuery,
6221
6219
  this.renderPromises,
6222
6220
  this.client.disableNetworkFetches,
6223
- ]), function () { return _this.getCurrentResult(); });
6221
+ ]), function () { return _this.getCurrentResult(); }, function () { return _this.getCurrentResult(); });
6224
6222
  this.unsafeHandlePartialRefetch(result);
6225
6223
  return this.toQueryResult(result);
6226
6224
  };
@@ -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',