@apollo/client 3.7.0-beta.8 → 3.7.0

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/README.md +1 -0
  2. package/apollo-client.cjs +44 -6
  3. package/apollo-client.cjs.map +1 -1
  4. package/apollo-client.min.cjs +1 -1
  5. package/core/core.cjs +1 -1
  6. package/core/core.cjs.map +1 -1
  7. package/core/core.cjs.native.js +1 -1
  8. package/invariantErrorCodes.js +1 -1
  9. package/link/http/http.cjs +11 -0
  10. package/link/http/http.cjs.map +1 -1
  11. package/link/http/http.cjs.native.js +11 -0
  12. package/link/http/parseAndCheckHttpResponse.d.ts.map +1 -1
  13. package/link/http/parseAndCheckHttpResponse.js +11 -0
  14. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  15. package/package.json +8 -7
  16. package/react/components/Subscription.js +2 -0
  17. package/react/components/Subscription.js.map +1 -1
  18. package/react/components/components.cjs +2 -0
  19. package/react/components/components.cjs.map +1 -1
  20. package/react/components/components.cjs.native.js +2 -0
  21. package/react/hooks/hooks.cjs +32 -5
  22. package/react/hooks/hooks.cjs.map +1 -1
  23. package/react/hooks/hooks.cjs.native.js +32 -5
  24. package/react/hooks/useSubscription.d.ts.map +1 -1
  25. package/react/hooks/useSubscription.js +33 -5
  26. package/react/hooks/useSubscription.js.map +1 -1
  27. package/react/ssr/getDataFromTree.d.ts.map +1 -1
  28. package/react/ssr/getDataFromTree.js +3 -2
  29. package/react/ssr/getDataFromTree.js.map +1 -1
  30. package/react/ssr/renderToStringWithData.d.ts.map +1 -1
  31. package/react/ssr/renderToStringWithData.js +2 -1
  32. package/react/ssr/renderToStringWithData.js.map +1 -1
  33. package/react/ssr/ssr.cjs +4 -3
  34. package/react/ssr/ssr.cjs.map +1 -1
  35. package/react/ssr/ssr.cjs.native.js +4 -3
  36. package/react/types/types.d.ts +6 -0
  37. package/react/types/types.d.ts.map +1 -1
  38. package/react/types/types.js.map +1 -1
  39. package/version.js +1 -1
package/README.md CHANGED
@@ -27,6 +27,7 @@ Learn how to use Apollo Client with self-paced hands-on training on Odyssey, Apo
27
27
  - [@hwillson](https://github.com/hwillson)
28
28
  - [@jpvajda](https://github.com/jpvajda)
29
29
  - [@mrdoombringer](https://github.com/mrdoombringer)
30
+ - [@jerelmiller](https://github.com/jerelmiller)
30
31
 
31
32
  ## Who is Apollo?
32
33
 
package/apollo-client.cjs CHANGED
@@ -1300,7 +1300,7 @@ var concat = ApolloLink.concat;
1300
1300
 
1301
1301
  var execute = ApolloLink.execute;
1302
1302
 
1303
- var version = '3.7.0-beta.8';
1303
+ var version = '3.7.0';
1304
1304
 
1305
1305
  function isNodeResponse(value) {
1306
1306
  return !!value.body;
@@ -1548,6 +1548,17 @@ function parseHeaders(headerText) {
1548
1548
  return headersInit;
1549
1549
  }
1550
1550
  function parseJsonBody(response, bodyText) {
1551
+ if (response.status >= 300) {
1552
+ var getResult = function () {
1553
+ try {
1554
+ return JSON.parse(bodyText);
1555
+ }
1556
+ catch (err) {
1557
+ return bodyText;
1558
+ }
1559
+ };
1560
+ throwServerError(response, getResult(), "Response not successful: Received status code ".concat(response.status));
1561
+ }
1551
1562
  try {
1552
1563
  return JSON.parse(bodyText);
1553
1564
  }
@@ -6936,6 +6947,7 @@ function useMutation(mutation, options) {
6936
6947
  }
6937
6948
 
6938
6949
  function useSubscription(subscription, options) {
6950
+ var hasIssuedDeprecationWarningRef = React.useRef(false);
6939
6951
  var client = useApolloClient(options === null || options === void 0 ? void 0 : options.client);
6940
6952
  verifyDocumentType(subscription, exports.DocumentType.Subscription);
6941
6953
  var _a = React.useState({
@@ -6944,6 +6956,19 @@ function useSubscription(subscription, options) {
6944
6956
  data: void 0,
6945
6957
  variables: options === null || options === void 0 ? void 0 : options.variables,
6946
6958
  }), result = _a[0], setResult = _a[1];
6959
+ if (!hasIssuedDeprecationWarningRef.current) {
6960
+ hasIssuedDeprecationWarningRef.current = true;
6961
+ if (options === null || options === void 0 ? void 0 : options.onSubscriptionData) {
6962
+ __DEV__ && tsInvariant.invariant.warn(options.onData
6963
+ ? "'useSubscription' supports only the 'onSubscriptionData' or 'onData' option, but not both. Only the 'onData' option will be used."
6964
+ : "'onSubscriptionData' is deprecated and will be removed in a future major version. Please use the 'onData' option instead.");
6965
+ }
6966
+ if (options === null || options === void 0 ? void 0 : options.onSubscriptionComplete) {
6967
+ __DEV__ && tsInvariant.invariant.warn(options.onComplete
6968
+ ? "'useSubscription' supports only the 'onSubscriptionComplete' or 'onComplete' option, but not both. Only the 'onComplete' option will be used."
6969
+ : "'onSubscriptionComplete' is deprecated and will be removed in a future major version. Please use the 'onComplete' option instead.");
6970
+ }
6971
+ }
6947
6972
  var _b = React.useState(function () {
6948
6973
  if (options === null || options === void 0 ? void 0 : options.skip) {
6949
6974
  return null;
@@ -7017,10 +7042,18 @@ function useSubscription(subscription, options) {
7017
7042
  variables: options === null || options === void 0 ? void 0 : options.variables,
7018
7043
  };
7019
7044
  setResult(result);
7020
- (_b = (_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onSubscriptionData) === null || _b === void 0 ? void 0 : _b.call(_a, {
7021
- client: client,
7022
- subscriptionData: result
7023
- });
7045
+ if ((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onData) {
7046
+ ref.current.options.onData({
7047
+ client: client,
7048
+ data: result
7049
+ });
7050
+ }
7051
+ else if ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.onSubscriptionData) {
7052
+ ref.current.options.onSubscriptionData({
7053
+ client: client,
7054
+ subscriptionData: result
7055
+ });
7056
+ }
7024
7057
  },
7025
7058
  error: function (error) {
7026
7059
  var _a, _b;
@@ -7034,7 +7067,12 @@ function useSubscription(subscription, options) {
7034
7067
  },
7035
7068
  complete: function () {
7036
7069
  var _a, _b;
7037
- (_b = (_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onSubscriptionComplete) === null || _b === void 0 ? void 0 : _b.call(_a);
7070
+ if ((_a = ref.current.options) === null || _a === void 0 ? void 0 : _a.onComplete) {
7071
+ ref.current.options.onComplete();
7072
+ }
7073
+ else if ((_b = ref.current.options) === null || _b === void 0 ? void 0 : _b.onSubscriptionComplete) {
7074
+ ref.current.options.onSubscriptionComplete();
7075
+ }
7038
7076
  },
7039
7077
  });
7040
7078
  return function () {