@apollo/client 3.6.1 → 3.6.4

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 (89) hide show
  1. package/LICENSE +1 -1
  2. package/apollo-client.cjs +133 -78
  3. package/apollo-client.cjs.map +1 -1
  4. package/apollo-client.min.cjs +1 -1
  5. package/cache/cache.cjs.native.js +2289 -0
  6. package/core/ApolloClient.d.ts.map +1 -1
  7. package/core/ApolloClient.js.map +1 -1
  8. package/core/ObservableQuery.d.ts.map +1 -1
  9. package/core/ObservableQuery.js +3 -1
  10. package/core/ObservableQuery.js.map +1 -1
  11. package/core/core.cjs +4 -2
  12. package/core/core.cjs.map +1 -1
  13. package/core/core.cjs.native.js +2141 -0
  14. package/errors/errors.cjs.native.js +48 -0
  15. package/invariantErrorCodes.js +1 -1
  16. package/link/batch/batch.cjs.native.js +161 -0
  17. package/link/batch-http/batch-http.cjs.native.js +127 -0
  18. package/link/context/context.cjs.native.js +38 -0
  19. package/link/core/core.cjs.native.js +121 -0
  20. package/link/error/error.cjs.native.js +90 -0
  21. package/link/http/http.cjs.native.js +320 -0
  22. package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
  23. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  24. package/link/persisted-queries/index.d.ts +2 -1
  25. package/link/persisted-queries/index.d.ts.map +1 -1
  26. package/link/persisted-queries/index.js +26 -13
  27. package/link/persisted-queries/index.js.map +1 -1
  28. package/link/persisted-queries/persisted-queries.cjs +25 -12
  29. package/link/persisted-queries/persisted-queries.cjs.map +1 -1
  30. package/link/persisted-queries/persisted-queries.cjs.native.js +174 -0
  31. package/link/retry/retry.cjs.native.js +170 -0
  32. package/link/schema/schema.cjs.native.js +56 -0
  33. package/link/subscriptions/subscriptions.cjs.native.js +45 -0
  34. package/link/utils/utils.cjs.native.js +115 -0
  35. package/link/ws/ws.cjs.native.js +28 -0
  36. package/main.cjs.native.js +16 -0
  37. package/package.json +17 -18
  38. package/react/components/components.cjs.native.js +79 -0
  39. package/react/context/ApolloConsumer.js +2 -2
  40. package/react/context/ApolloProvider.js +2 -2
  41. package/react/context/context.cjs +4 -4
  42. package/react/context/context.cjs.map +1 -1
  43. package/react/context/context.cjs.native.js +67 -0
  44. package/react/hoc/hoc.cjs.native.js +325 -0
  45. package/react/hooks/hooks.cjs +151 -90
  46. package/react/hooks/hooks.cjs.map +1 -1
  47. package/react/hooks/hooks.cjs.native.js +604 -0
  48. package/react/hooks/useLazyQuery.d.ts.map +1 -1
  49. package/react/hooks/useLazyQuery.js +7 -22
  50. package/react/hooks/useLazyQuery.js.map +1 -1
  51. package/react/hooks/useQuery.d.ts +5 -1
  52. package/react/hooks/useQuery.d.ts.map +1 -1
  53. package/react/hooks/useQuery.js +46 -39
  54. package/react/hooks/useQuery.js.map +1 -1
  55. package/react/hooks/useSubscription.d.ts.map +1 -1
  56. package/react/hooks/useSubscription.js +17 -7
  57. package/react/hooks/useSubscription.js.map +1 -1
  58. package/react/hooks/useSyncExternalStore.d.ts +4 -0
  59. package/react/hooks/useSyncExternalStore.d.ts.map +1 -0
  60. package/react/hooks/useSyncExternalStore.js +48 -0
  61. package/react/hooks/useSyncExternalStore.js.map +1 -0
  62. package/react/parser/parser.cjs.native.js +103 -0
  63. package/react/react.cjs.native.js +22 -0
  64. package/react/ssr/ssr.cjs.native.js +150 -0
  65. package/testing/core/core.cjs.native.js +288 -0
  66. package/testing/core/mocking/mockQueryManager.js +1 -1
  67. package/testing/core/mocking/mockWatchQuery.js +1 -1
  68. package/testing/core/wrap.js +1 -1
  69. package/testing/testing.cjs.native.js +58 -0
  70. package/utilities/common/canUse.d.ts +2 -0
  71. package/utilities/common/canUse.d.ts.map +1 -1
  72. package/utilities/common/canUse.js +6 -2
  73. package/utilities/common/canUse.js.map +1 -1
  74. package/utilities/common/mergeOptions.d.ts +1 -1
  75. package/utilities/common/mergeOptions.d.ts.map +1 -1
  76. package/utilities/common/mergeOptions.js +1 -1
  77. package/utilities/common/mergeOptions.js.map +1 -1
  78. package/utilities/globals/global.js +1 -2
  79. package/utilities/globals/globals.cjs.native.js +56 -0
  80. package/utilities/observables/Concast.d.ts.map +1 -1
  81. package/utilities/observables/Concast.js +5 -2
  82. package/utilities/observables/Concast.js.map +1 -1
  83. package/utilities/policies/pagination.d.ts.map +1 -1
  84. package/utilities/policies/pagination.js +9 -7
  85. package/utilities/policies/pagination.js.map +1 -1
  86. package/utilities/utilities.cjs +22 -12
  87. package/utilities/utilities.cjs.map +1 -1
  88. package/utilities/utilities.cjs.native.js +1284 -0
  89. package/version.js +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apollo/client",
3
- "version": "3.6.1",
3
+ "version": "3.6.4",
4
4
  "description": "A fully-featured caching GraphQL client.",
5
5
  "private": false,
6
6
  "keywords": [
@@ -55,14 +55,13 @@
55
55
  "optimism": "^0.16.1",
56
56
  "prop-types": "^15.7.2",
57
57
  "symbol-observable": "^4.0.0",
58
- "ts-invariant": "^0.10.0",
58
+ "ts-invariant": "^0.10.3",
59
59
  "tslib": "^2.3.0",
60
- "use-sync-external-store": "^1.0.0",
61
- "zen-observable-ts": "^1.2.0"
60
+ "zen-observable-ts": "^1.2.5"
62
61
  },
63
62
  "devDependencies": {
64
- "@babel/parser": "7.17.9",
65
- "@graphql-tools/schema": "8.3.10",
63
+ "@babel/parser": "7.17.10",
64
+ "@graphql-tools/schema": "8.3.11",
66
65
  "@rollup/plugin-node-resolve": "11.2.1",
67
66
  "@testing-library/react": "12.1.5",
68
67
  "@testing-library/react-hooks": "8.0.0",
@@ -70,37 +69,37 @@
70
69
  "@types/fetch-mock": "7.3.5",
71
70
  "@types/glob": "7.2.0",
72
71
  "@types/hoist-non-react-statics": "3.3.1",
73
- "@types/jest": "27.4.1",
72
+ "@types/jest": "27.5.1",
74
73
  "@types/lodash": "4.14.182",
75
- "@types/node": "16.11.27",
76
- "@types/react": "17.0.44",
77
- "@types/react-dom": "17.0.15",
74
+ "@types/node": "16.11.35",
75
+ "@types/react": "17.0.45",
76
+ "@types/react-dom": "17.0.17",
78
77
  "@types/use-sync-external-store": "^0.0.3",
79
- "acorn": "8.6.0",
78
+ "acorn": "8.7.1",
80
79
  "bundlesize": "0.18.1",
81
80
  "cross-fetch": "3.1.5",
82
81
  "crypto-hash": "1.3.0",
83
82
  "fetch-mock": "9.11.0",
84
- "glob": "8.0.1",
85
- "graphql": "16.3.0",
86
- "graphql-ws": "5.8.1",
83
+ "glob": "8.0.3",
84
+ "graphql": "16.5.0",
85
+ "graphql-ws": "5.8.2",
87
86
  "jest": "27.5.1",
88
87
  "jest-fetch-mock": "3.0.3",
89
88
  "jest-junit": "13.2.0",
90
89
  "lodash": "4.17.21",
91
90
  "react": "17.0.2",
92
91
  "react-dom": "17.0.2",
93
- "recast": "0.21.0",
92
+ "recast": "0.21.1",
94
93
  "resolve": "1.22.0",
95
94
  "rimraf": "3.0.2",
96
- "rollup": "2.70.2",
95
+ "rollup": "2.73.0",
97
96
  "rollup-plugin-terser": "7.0.2",
98
97
  "rxjs": "7.5.5",
99
98
  "subscriptions-transport-ws": "0.11.0",
100
- "terser": "5.12.1",
99
+ "terser": "5.13.1",
101
100
  "ts-jest": "27.1.4",
102
101
  "ts-node": "10.7.0",
103
- "typescript": "4.6.3",
102
+ "typescript": "4.6.4",
104
103
  "wait-for-observables": "1.0.3",
105
104
  "whatwg-fetch": "3.6.2"
106
105
  },
@@ -0,0 +1,79 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib = require('tslib');
6
+ var PropTypes = require('prop-types');
7
+ var hooks = require('../hooks');
8
+
9
+ function _interopNamespace(e) {
10
+ if (e && e.__esModule) return e;
11
+ var n = Object.create(null);
12
+ if (e) {
13
+ for (var k in e) {
14
+ n[k] = e[k];
15
+ }
16
+ }
17
+ n["default"] = e;
18
+ return Object.freeze(n);
19
+ }
20
+
21
+ var PropTypes__namespace = /*#__PURE__*/_interopNamespace(PropTypes);
22
+
23
+ function Query(props) {
24
+ var children = props.children, query = props.query, options = tslib.__rest(props, ["children", "query"]);
25
+ var result = hooks.useQuery(query, options);
26
+ return result ? children(result) : null;
27
+ }
28
+ Query.propTypes = {
29
+ client: PropTypes__namespace.object,
30
+ children: PropTypes__namespace.func.isRequired,
31
+ fetchPolicy: PropTypes__namespace.string,
32
+ notifyOnNetworkStatusChange: PropTypes__namespace.bool,
33
+ onCompleted: PropTypes__namespace.func,
34
+ onError: PropTypes__namespace.func,
35
+ pollInterval: PropTypes__namespace.number,
36
+ query: PropTypes__namespace.object.isRequired,
37
+ variables: PropTypes__namespace.object,
38
+ ssr: PropTypes__namespace.bool,
39
+ partialRefetch: PropTypes__namespace.bool,
40
+ returnPartialData: PropTypes__namespace.bool
41
+ };
42
+
43
+ function Mutation(props) {
44
+ var _a = hooks.useMutation(props.mutation, props), runMutation = _a[0], result = _a[1];
45
+ return props.children ? props.children(runMutation, result) : null;
46
+ }
47
+ Mutation.propTypes = {
48
+ mutation: PropTypes__namespace.object.isRequired,
49
+ variables: PropTypes__namespace.object,
50
+ optimisticResponse: PropTypes__namespace.oneOfType([PropTypes__namespace.object, PropTypes__namespace.func]),
51
+ refetchQueries: PropTypes__namespace.oneOfType([
52
+ PropTypes__namespace.arrayOf(PropTypes__namespace.oneOfType([PropTypes__namespace.string, PropTypes__namespace.object])),
53
+ PropTypes__namespace.func
54
+ ]),
55
+ awaitRefetchQueries: PropTypes__namespace.bool,
56
+ update: PropTypes__namespace.func,
57
+ children: PropTypes__namespace.func.isRequired,
58
+ onCompleted: PropTypes__namespace.func,
59
+ onError: PropTypes__namespace.func,
60
+ fetchPolicy: PropTypes__namespace.string,
61
+ };
62
+
63
+ function Subscription(props) {
64
+ var result = hooks.useSubscription(props.subscription, props);
65
+ return props.children && result ? props.children(result) : null;
66
+ }
67
+ Subscription.propTypes = {
68
+ subscription: PropTypes__namespace.object.isRequired,
69
+ variables: PropTypes__namespace.object,
70
+ children: PropTypes__namespace.func,
71
+ onSubscriptionData: PropTypes__namespace.func,
72
+ onSubscriptionComplete: PropTypes__namespace.func,
73
+ shouldResubscribe: PropTypes__namespace.oneOfType([PropTypes__namespace.func, PropTypes__namespace.bool])
74
+ };
75
+
76
+ exports.Mutation = Mutation;
77
+ exports.Query = Query;
78
+ exports.Subscription = Subscription;
79
+ //# sourceMappingURL=components.cjs.map
@@ -3,10 +3,10 @@ import * as React from 'react';
3
3
  import { getApolloContext } from "./ApolloContext.js";
4
4
  export var ApolloConsumer = function (props) {
5
5
  var ApolloContext = getApolloContext();
6
- return React.createElement(ApolloContext.Consumer, null, function (context) {
6
+ return (React.createElement(ApolloContext.Consumer, null, function (context) {
7
7
  __DEV__ ? invariant(context && context.client, 'Could not find "client" in the context of ApolloConsumer. ' +
8
8
  'Wrap the root component in an <ApolloProvider>.') : invariant(context && context.client, 25);
9
9
  return props.children(context.client);
10
- });
10
+ }));
11
11
  };
12
12
  //# sourceMappingURL=ApolloConsumer.js.map
@@ -4,7 +4,7 @@ import { getApolloContext } from "./ApolloContext.js";
4
4
  export var ApolloProvider = function (_a) {
5
5
  var client = _a.client, children = _a.children;
6
6
  var ApolloContext = getApolloContext();
7
- return React.createElement(ApolloContext.Consumer, null, function (context) {
7
+ return (React.createElement(ApolloContext.Consumer, null, function (context) {
8
8
  if (context === void 0) { context = {}; }
9
9
  if (client && context.client !== client) {
10
10
  context = Object.assign({}, context, { client: client });
@@ -12,6 +12,6 @@ export var ApolloProvider = function (_a) {
12
12
  __DEV__ ? invariant(context.client, 'ApolloProvider was not passed a client instance. Make ' +
13
13
  'sure you pass in your client via the "client" prop.') : invariant(context.client, 26);
14
14
  return (React.createElement(ApolloContext.Provider, { value: context }, children));
15
- });
15
+ }));
16
16
  };
17
17
  //# sourceMappingURL=ApolloProvider.js.map
@@ -39,17 +39,17 @@ function getApolloContext() {
39
39
 
40
40
  var ApolloConsumer = function (props) {
41
41
  var ApolloContext = getApolloContext();
42
- return React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
42
+ return (React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
43
43
  __DEV__ ? globals.invariant(context && context.client, 'Could not find "client" in the context of ApolloConsumer. ' +
44
44
  'Wrap the root component in an <ApolloProvider>.') : globals.invariant(context && context.client, 25);
45
45
  return props.children(context.client);
46
- });
46
+ }));
47
47
  };
48
48
 
49
49
  var ApolloProvider = function (_a) {
50
50
  var client = _a.client, children = _a.children;
51
51
  var ApolloContext = getApolloContext();
52
- return React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
52
+ return (React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
53
53
  if (context === void 0) { context = {}; }
54
54
  if (client && context.client !== client) {
55
55
  context = Object.assign({}, context, { client: client });
@@ -57,7 +57,7 @@ var ApolloProvider = function (_a) {
57
57
  __DEV__ ? globals.invariant(context.client, 'ApolloProvider was not passed a client instance. Make ' +
58
58
  'sure you pass in your client via the "client" prop.') : globals.invariant(context.client, 26);
59
59
  return (React__namespace.createElement(ApolloContext.Provider, { value: context }, children));
60
- });
60
+ }));
61
61
  };
62
62
 
63
63
  exports.ApolloConsumer = ApolloConsumer;
@@ -1 +1 @@
1
- {"version":3,"file":"context.cjs","sources":["ApolloContext.js","ApolloConsumer.js","ApolloProvider.js"],"sourcesContent":["import * as React from 'react';\nimport { canUseSymbol } from '../../utilities';\nvar contextKey = canUseSymbol\n ? Symbol.for('__APOLLO_CONTEXT__')\n : '__APOLLO_CONTEXT__';\nexport function getApolloContext() {\n var context = React.createContext[contextKey];\n if (!context) {\n Object.defineProperty(React.createContext, contextKey, {\n value: context = React.createContext({}),\n enumerable: false,\n writable: false,\n configurable: true,\n });\n context.displayName = 'ApolloContext';\n }\n return context;\n}\nexport { getApolloContext as resetApolloContext };\n//# sourceMappingURL=ApolloContext.js.map","import { invariant } from '../../utilities/globals';\nimport * as React from 'react';\nimport { getApolloContext } from './ApolloContext';\nexport var ApolloConsumer = function (props) {\n var ApolloContext = getApolloContext();\n return React.createElement(ApolloContext.Consumer, null, function (context) {\n __DEV__ ? invariant(context && context.client, 'Could not find \"client\" in the context of ApolloConsumer. ' +\n 'Wrap the root component in an <ApolloProvider>.') : invariant(context && context.client, 25);\n return props.children(context.client);\n });\n};\n//# sourceMappingURL=ApolloConsumer.js.map","import { invariant } from '../../utilities/globals';\nimport * as React from 'react';\nimport { getApolloContext } from './ApolloContext';\nexport var ApolloProvider = function (_a) {\n var client = _a.client, children = _a.children;\n var ApolloContext = getApolloContext();\n return React.createElement(ApolloContext.Consumer, null, function (context) {\n if (context === void 0) { context = {}; }\n if (client && context.client !== client) {\n context = Object.assign({}, context, { client: client });\n }\n __DEV__ ? invariant(context.client, 'ApolloProvider was not passed a client instance. Make ' +\n 'sure you pass in your client via the \"client\" prop.') : invariant(context.client, 26);\n return (React.createElement(ApolloContext.Provider, { value: context }, children));\n });\n};\n//# sourceMappingURL=ApolloProvider.js.map"],"names":["canUseSymbol","React","invariant"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAEA,IAAI,UAAU,GAAGA,sBAAY;AAC7B,MAAM,MAAM,CAAC,GAAG,CAAC,oBAAoB,CAAC;AACtC,MAAM,oBAAoB,CAAC;AACpB,SAAS,gBAAgB,GAAG;AACnC,IAAI,IAAI,OAAO,GAAGC,gBAAK,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC;AAClD,IAAI,IAAI,CAAC,OAAO,EAAE;AAClB,QAAQ,MAAM,CAAC,cAAc,CAACA,gBAAK,CAAC,aAAa,EAAE,UAAU,EAAE;AAC/D,YAAY,KAAK,EAAE,OAAO,GAAGA,gBAAK,CAAC,aAAa,CAAC,EAAE,CAAC;AACpD,YAAY,UAAU,EAAE,KAAK;AAC7B,YAAY,QAAQ,EAAE,KAAK;AAC3B,YAAY,YAAY,EAAE,IAAI;AAC9B,SAAS,CAAC,CAAC;AACX,QAAQ,OAAO,CAAC,WAAW,GAAG,eAAe,CAAC;AAC9C,KAAK;AACL,IAAI,OAAO,OAAO,CAAC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Q,QAAQD,gBAAK,CAAC,aAAa,CAAC,aAAa,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,CAAC,EAAE;AAC3F,KAAK,CAAC,CAAC;AACP;;;;;;;"}
1
+ {"version":3,"file":"context.cjs","sources":["ApolloContext.js","ApolloConsumer.js","ApolloProvider.js"],"sourcesContent":["import * as React from 'react';\nimport { canUseSymbol } from '../../utilities';\nvar contextKey = canUseSymbol\n ? Symbol.for('__APOLLO_CONTEXT__')\n : '__APOLLO_CONTEXT__';\nexport function getApolloContext() {\n var context = React.createContext[contextKey];\n if (!context) {\n Object.defineProperty(React.createContext, contextKey, {\n value: context = React.createContext({}),\n enumerable: false,\n writable: false,\n configurable: true,\n });\n context.displayName = 'ApolloContext';\n }\n return context;\n}\nexport { getApolloContext as resetApolloContext };\n//# sourceMappingURL=ApolloContext.js.map","import { invariant } from '../../utilities/globals';\nimport * as React from 'react';\nimport { getApolloContext } from './ApolloContext';\nexport var ApolloConsumer = function (props) {\n var ApolloContext = getApolloContext();\n return (React.createElement(ApolloContext.Consumer, null, function (context) {\n __DEV__ ? invariant(context && context.client, 'Could not find \"client\" in the context of ApolloConsumer. ' +\n 'Wrap the root component in an <ApolloProvider>.') : invariant(context && context.client, 25);\n return props.children(context.client);\n }));\n};\n//# sourceMappingURL=ApolloConsumer.js.map","import { invariant } from '../../utilities/globals';\nimport * as React from 'react';\nimport { getApolloContext } from './ApolloContext';\nexport var ApolloProvider = function (_a) {\n var client = _a.client, children = _a.children;\n var ApolloContext = getApolloContext();\n return (React.createElement(ApolloContext.Consumer, null, function (context) {\n if (context === void 0) { context = {}; }\n if (client && context.client !== client) {\n context = Object.assign({}, context, { client: client });\n }\n __DEV__ ? invariant(context.client, 'ApolloProvider was not passed a client instance. Make ' +\n 'sure you pass in your client via the \"client\" prop.') : invariant(context.client, 26);\n return (React.createElement(ApolloContext.Provider, { value: context }, children));\n }));\n};\n//# sourceMappingURL=ApolloProvider.js.map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,EAAE,CAAC,MAAM,EAAE,QAAQ,GAAG,EAAE,CAAC,QAAQ,CAAC;AACnD,IAAI,IAAI,aAAa,GAAG,gBAAgB,EAAE,CAAC;AAC3C,IAAI,QAAQD,gBAAK,CAAC,aAAa,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,EAAE,UAAU,OAAO,EAAE;AACjF,QAAQ,IAAI,OAAO,KAAK,KAAK,CAAC,EAAE,EAAE,OAAO,GAAG,EAAE,CAAC,EAAE;AACjD,QAAQ,IAAI,MAAM,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,EAAE;AACjD,YAAY,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;AACrE,SAAS;AACT,QAAQ,OAAO,GAAGC,iBAAS,CAAC,OAAO,CAAC,MAAM,EAAE,wDAAwD;AACpG,YAAY,qDAAqD,CAAC,GAAGA,iBAAS,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACnG,QAAQ,QAAQD,gBAAK,CAAC,aAAa,CAAC,aAAa,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,QAAQ,CAAC,EAAE;AAC3F,KAAK,CAAC,EAAE;AACR;;;;;;;"}
@@ -0,0 +1,67 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var globals = require('../../utilities/globals');
6
+ var React = require('react');
7
+ var utilities = require('../../utilities');
8
+
9
+ function _interopNamespace(e) {
10
+ if (e && e.__esModule) return e;
11
+ var n = Object.create(null);
12
+ if (e) {
13
+ for (var k in e) {
14
+ n[k] = e[k];
15
+ }
16
+ }
17
+ n["default"] = e;
18
+ return Object.freeze(n);
19
+ }
20
+
21
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
22
+
23
+ var contextKey = utilities.canUseSymbol
24
+ ? Symbol.for('__APOLLO_CONTEXT__')
25
+ : '__APOLLO_CONTEXT__';
26
+ function getApolloContext() {
27
+ var context = React__namespace.createContext[contextKey];
28
+ if (!context) {
29
+ Object.defineProperty(React__namespace.createContext, contextKey, {
30
+ value: context = React__namespace.createContext({}),
31
+ enumerable: false,
32
+ writable: false,
33
+ configurable: true,
34
+ });
35
+ context.displayName = 'ApolloContext';
36
+ }
37
+ return context;
38
+ }
39
+
40
+ var ApolloConsumer = function (props) {
41
+ var ApolloContext = getApolloContext();
42
+ return (React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
43
+ __DEV__ ? globals.invariant(context && context.client, 'Could not find "client" in the context of ApolloConsumer. ' +
44
+ 'Wrap the root component in an <ApolloProvider>.') : globals.invariant(context && context.client, 25);
45
+ return props.children(context.client);
46
+ }));
47
+ };
48
+
49
+ var ApolloProvider = function (_a) {
50
+ var client = _a.client, children = _a.children;
51
+ var ApolloContext = getApolloContext();
52
+ return (React__namespace.createElement(ApolloContext.Consumer, null, function (context) {
53
+ if (context === void 0) { context = {}; }
54
+ if (client && context.client !== client) {
55
+ context = Object.assign({}, context, { client: client });
56
+ }
57
+ __DEV__ ? globals.invariant(context.client, 'ApolloProvider was not passed a client instance. Make ' +
58
+ 'sure you pass in your client via the "client" prop.') : globals.invariant(context.client, 26);
59
+ return (React__namespace.createElement(ApolloContext.Provider, { value: context }, children));
60
+ }));
61
+ };
62
+
63
+ exports.ApolloConsumer = ApolloConsumer;
64
+ exports.ApolloProvider = ApolloProvider;
65
+ exports.getApolloContext = getApolloContext;
66
+ exports.resetApolloContext = getApolloContext;
67
+ //# sourceMappingURL=context.cjs.map
@@ -0,0 +1,325 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var globals = require('../../utilities/globals');
6
+ var parser = require('../parser');
7
+ var tslib = require('tslib');
8
+ var React = require('react');
9
+ var hoistNonReactStatics = require('hoist-non-react-statics');
10
+ var components = require('../components');
11
+ var context = require('../context');
12
+
13
+ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
14
+
15
+ function _interopNamespace(e) {
16
+ if (e && e.__esModule) return e;
17
+ var n = Object.create(null);
18
+ if (e) {
19
+ for (var k in e) {
20
+ n[k] = e[k];
21
+ }
22
+ }
23
+ n["default"] = e;
24
+ return Object.freeze(n);
25
+ }
26
+
27
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
28
+ var hoistNonReactStatics__default = /*#__PURE__*/_interopDefaultLegacy(hoistNonReactStatics);
29
+
30
+ var defaultMapPropsToOptions = function () { return ({}); };
31
+ var defaultMapPropsToSkip = function () { return false; };
32
+ function getDisplayName$1(WrappedComponent) {
33
+ return WrappedComponent.displayName || WrappedComponent.name || 'Component';
34
+ }
35
+ function calculateVariablesFromProps(operation, props) {
36
+ var variables = {};
37
+ for (var _i = 0, _a = operation.variables; _i < _a.length; _i++) {
38
+ var _b = _a[_i], variable = _b.variable, type = _b.type;
39
+ if (!variable.name || !variable.name.value)
40
+ continue;
41
+ var variableName = variable.name.value;
42
+ var variableProp = props[variableName];
43
+ if (typeof variableProp !== 'undefined') {
44
+ variables[variableName] = variableProp;
45
+ continue;
46
+ }
47
+ if (type.kind !== 'NonNullType') {
48
+ variables[variableName] = undefined;
49
+ }
50
+ }
51
+ return variables;
52
+ }
53
+ var GraphQLBase = (function (_super) {
54
+ tslib.__extends(GraphQLBase, _super);
55
+ function GraphQLBase(props) {
56
+ var _this = _super.call(this, props) || this;
57
+ _this.withRef = false;
58
+ _this.setWrappedInstance = _this.setWrappedInstance.bind(_this);
59
+ return _this;
60
+ }
61
+ GraphQLBase.prototype.getWrappedInstance = function () {
62
+ __DEV__ ? globals.invariant(this.withRef, "To access the wrapped instance, you need to specify " +
63
+ "{ withRef: true } in the options") : globals.invariant(this.withRef, 27);
64
+ return this.wrappedInstance;
65
+ };
66
+ GraphQLBase.prototype.setWrappedInstance = function (ref) {
67
+ this.wrappedInstance = ref;
68
+ };
69
+ return GraphQLBase;
70
+ }(React__namespace.Component));
71
+
72
+ function withQuery(document, operationOptions) {
73
+ if (operationOptions === void 0) { operationOptions = {}; }
74
+ var operation = parser.parser(document);
75
+ var _a = operationOptions.options, options = _a === void 0 ? defaultMapPropsToOptions : _a, _b = operationOptions.skip, skip = _b === void 0 ? defaultMapPropsToSkip : _b, _c = operationOptions.alias, alias = _c === void 0 ? 'Apollo' : _c;
76
+ var mapPropsToOptions = options;
77
+ if (typeof mapPropsToOptions !== 'function') {
78
+ mapPropsToOptions = function () { return options; };
79
+ }
80
+ var mapPropsToSkip = skip;
81
+ if (typeof mapPropsToSkip !== 'function') {
82
+ mapPropsToSkip = function () { return skip; };
83
+ }
84
+ var lastResultProps;
85
+ return function (WrappedComponent) {
86
+ var graphQLDisplayName = "".concat(alias, "(").concat(getDisplayName$1(WrappedComponent), ")");
87
+ var GraphQL = (function (_super) {
88
+ tslib.__extends(GraphQL, _super);
89
+ function GraphQL() {
90
+ return _super !== null && _super.apply(this, arguments) || this;
91
+ }
92
+ GraphQL.prototype.render = function () {
93
+ var _this = this;
94
+ var props = this.props;
95
+ var shouldSkip = mapPropsToSkip(props);
96
+ var opts = shouldSkip
97
+ ? Object.create(null)
98
+ : tslib.__assign({}, mapPropsToOptions(props));
99
+ if (!shouldSkip && !opts.variables && operation.variables.length > 0) {
100
+ opts.variables = calculateVariablesFromProps(operation, props);
101
+ }
102
+ return (React__namespace.createElement(components.Query, tslib.__assign({}, opts, { displayName: graphQLDisplayName, skip: shouldSkip, query: document }), function (_a) {
103
+ var _b, _c;
104
+ _a.client; var data = _a.data, r = tslib.__rest(_a, ["client", "data"]);
105
+ if (operationOptions.withRef) {
106
+ _this.withRef = true;
107
+ props = Object.assign({}, props, {
108
+ ref: _this.setWrappedInstance
109
+ });
110
+ }
111
+ if (shouldSkip) {
112
+ return (React__namespace.createElement(WrappedComponent, tslib.__assign({}, props, {})));
113
+ }
114
+ var result = Object.assign(r, data || {});
115
+ var name = operationOptions.name || 'data';
116
+ var childProps = (_b = {}, _b[name] = result, _b);
117
+ if (operationOptions.props) {
118
+ var newResult = (_c = {},
119
+ _c[name] = result,
120
+ _c.ownProps = props,
121
+ _c);
122
+ lastResultProps = operationOptions.props(newResult, lastResultProps);
123
+ childProps = lastResultProps;
124
+ }
125
+ return (React__namespace.createElement(WrappedComponent, tslib.__assign({}, props, childProps)));
126
+ }));
127
+ };
128
+ GraphQL.displayName = graphQLDisplayName;
129
+ GraphQL.WrappedComponent = WrappedComponent;
130
+ return GraphQL;
131
+ }(GraphQLBase));
132
+ return hoistNonReactStatics__default(GraphQL, WrappedComponent, {});
133
+ };
134
+ }
135
+
136
+ function withMutation(document, operationOptions) {
137
+ if (operationOptions === void 0) { operationOptions = {}; }
138
+ var operation = parser.parser(document);
139
+ var _a = operationOptions.options, options = _a === void 0 ? defaultMapPropsToOptions : _a, _b = operationOptions.alias, alias = _b === void 0 ? 'Apollo' : _b;
140
+ var mapPropsToOptions = options;
141
+ if (typeof mapPropsToOptions !== 'function')
142
+ mapPropsToOptions = function () { return options; };
143
+ return function (WrappedComponent) {
144
+ var graphQLDisplayName = "".concat(alias, "(").concat(getDisplayName$1(WrappedComponent), ")");
145
+ var GraphQL = (function (_super) {
146
+ tslib.__extends(GraphQL, _super);
147
+ function GraphQL() {
148
+ return _super !== null && _super.apply(this, arguments) || this;
149
+ }
150
+ GraphQL.prototype.render = function () {
151
+ var props = this.props;
152
+ var opts = mapPropsToOptions(props);
153
+ if (operationOptions.withRef) {
154
+ this.withRef = true;
155
+ props = Object.assign({}, props, {
156
+ ref: this.setWrappedInstance
157
+ });
158
+ }
159
+ if (!opts.variables && operation.variables.length > 0) {
160
+ opts.variables = calculateVariablesFromProps(operation, props);
161
+ }
162
+ return (React__namespace.createElement(components.Mutation, tslib.__assign({ ignoreResults: true }, opts, { mutation: document }), function (mutate, _a) {
163
+ var _b, _c;
164
+ var data = _a.data, r = tslib.__rest(_a, ["data"]);
165
+ var result = Object.assign(r, data || {});
166
+ var name = operationOptions.name || 'mutate';
167
+ var resultName = operationOptions.name
168
+ ? "".concat(name, "Result")
169
+ : 'result';
170
+ var childProps = (_b = {},
171
+ _b[name] = mutate,
172
+ _b[resultName] = result,
173
+ _b);
174
+ if (operationOptions.props) {
175
+ var newResult = (_c = {},
176
+ _c[name] = mutate,
177
+ _c[resultName] = result,
178
+ _c.ownProps = props,
179
+ _c);
180
+ childProps = operationOptions.props(newResult);
181
+ }
182
+ return React__namespace.createElement(WrappedComponent, tslib.__assign({}, props, childProps));
183
+ }));
184
+ };
185
+ GraphQL.displayName = graphQLDisplayName;
186
+ GraphQL.WrappedComponent = WrappedComponent;
187
+ return GraphQL;
188
+ }(GraphQLBase));
189
+ return hoistNonReactStatics__default(GraphQL, WrappedComponent, {});
190
+ };
191
+ }
192
+
193
+ function withSubscription(document, operationOptions) {
194
+ if (operationOptions === void 0) { operationOptions = {}; }
195
+ var operation = parser.parser(document);
196
+ var _a = operationOptions.options, options = _a === void 0 ? defaultMapPropsToOptions : _a, _b = operationOptions.skip, skip = _b === void 0 ? defaultMapPropsToSkip : _b, _c = operationOptions.alias, alias = _c === void 0 ? 'Apollo' : _c, shouldResubscribe = operationOptions.shouldResubscribe;
197
+ var mapPropsToOptions = options;
198
+ if (typeof mapPropsToOptions !== 'function')
199
+ mapPropsToOptions = function () { return options; };
200
+ var mapPropsToSkip = skip;
201
+ if (typeof mapPropsToSkip !== 'function')
202
+ mapPropsToSkip = function () { return skip; };
203
+ var lastResultProps;
204
+ return function (WrappedComponent) {
205
+ var graphQLDisplayName = "".concat(alias, "(").concat(getDisplayName$1(WrappedComponent), ")");
206
+ var GraphQL = (function (_super) {
207
+ tslib.__extends(GraphQL, _super);
208
+ function GraphQL(props) {
209
+ var _this = _super.call(this, props) || this;
210
+ _this.state = { resubscribe: false };
211
+ return _this;
212
+ }
213
+ GraphQL.prototype.updateResubscribe = function (resubscribe) {
214
+ this.setState({ resubscribe: resubscribe });
215
+ };
216
+ GraphQL.prototype.componentDidUpdate = function (prevProps) {
217
+ var resubscribe = !!(shouldResubscribe &&
218
+ shouldResubscribe(prevProps, this.props));
219
+ if (this.state.resubscribe !== resubscribe) {
220
+ this.updateResubscribe(resubscribe);
221
+ }
222
+ };
223
+ GraphQL.prototype.render = function () {
224
+ var _this = this;
225
+ var props = this.props;
226
+ var shouldSkip = mapPropsToSkip(props);
227
+ var opts = shouldSkip
228
+ ? Object.create(null)
229
+ : mapPropsToOptions(props);
230
+ if (!shouldSkip && !opts.variables && operation.variables.length > 0) {
231
+ opts.variables = calculateVariablesFromProps(operation, props);
232
+ }
233
+ return (React__namespace.createElement(components.Subscription, tslib.__assign({}, opts, { displayName: graphQLDisplayName, skip: shouldSkip, subscription: document, shouldResubscribe: this.state.resubscribe }), function (_a) {
234
+ var _b, _c;
235
+ var data = _a.data, r = tslib.__rest(_a, ["data"]);
236
+ if (operationOptions.withRef) {
237
+ _this.withRef = true;
238
+ props = Object.assign({}, props, {
239
+ ref: _this.setWrappedInstance
240
+ });
241
+ }
242
+ if (shouldSkip) {
243
+ return (React__namespace.createElement(WrappedComponent, tslib.__assign({}, props, {})));
244
+ }
245
+ var result = Object.assign(r, data || {});
246
+ var name = operationOptions.name || 'data';
247
+ var childProps = (_b = {}, _b[name] = result, _b);
248
+ if (operationOptions.props) {
249
+ var newResult = (_c = {},
250
+ _c[name] = result,
251
+ _c.ownProps = props,
252
+ _c);
253
+ lastResultProps = operationOptions.props(newResult, lastResultProps);
254
+ childProps = lastResultProps;
255
+ }
256
+ return (React__namespace.createElement(WrappedComponent, tslib.__assign({}, props, childProps)));
257
+ }));
258
+ };
259
+ GraphQL.displayName = graphQLDisplayName;
260
+ GraphQL.WrappedComponent = WrappedComponent;
261
+ return GraphQL;
262
+ }(GraphQLBase));
263
+ return hoistNonReactStatics__default(GraphQL, WrappedComponent, {});
264
+ };
265
+ }
266
+
267
+ function graphql(document, operationOptions) {
268
+ if (operationOptions === void 0) { operationOptions = {}; }
269
+ switch (parser.parser(document).type) {
270
+ case parser.DocumentType.Mutation:
271
+ return withMutation(document, operationOptions);
272
+ case parser.DocumentType.Subscription:
273
+ return withSubscription(document, operationOptions);
274
+ case parser.DocumentType.Query:
275
+ default:
276
+ return withQuery(document, operationOptions);
277
+ }
278
+ }
279
+
280
+ function getDisplayName(WrappedComponent) {
281
+ return WrappedComponent.displayName || WrappedComponent.name || 'Component';
282
+ }
283
+ function withApollo(WrappedComponent, operationOptions) {
284
+ if (operationOptions === void 0) { operationOptions = {}; }
285
+ var withDisplayName = "withApollo(".concat(getDisplayName(WrappedComponent), ")");
286
+ var WithApollo = (function (_super) {
287
+ tslib.__extends(WithApollo, _super);
288
+ function WithApollo(props) {
289
+ var _this = _super.call(this, props) || this;
290
+ _this.setWrappedInstance = _this.setWrappedInstance.bind(_this);
291
+ return _this;
292
+ }
293
+ WithApollo.prototype.getWrappedInstance = function () {
294
+ __DEV__ ? globals.invariant(operationOptions.withRef, "To access the wrapped instance, you need to specify " +
295
+ "{ withRef: true } in the options") : globals.invariant(operationOptions.withRef, 28);
296
+ return this.wrappedInstance;
297
+ };
298
+ WithApollo.prototype.setWrappedInstance = function (ref) {
299
+ this.wrappedInstance = ref;
300
+ };
301
+ WithApollo.prototype.render = function () {
302
+ var _this = this;
303
+ return (React__namespace.createElement(context.ApolloConsumer, null, function (client) {
304
+ var props = Object.assign({}, _this.props, {
305
+ client: client,
306
+ ref: operationOptions.withRef
307
+ ? _this.setWrappedInstance
308
+ : undefined
309
+ });
310
+ return React__namespace.createElement(WrappedComponent, tslib.__assign({}, props));
311
+ }));
312
+ };
313
+ WithApollo.displayName = withDisplayName;
314
+ WithApollo.WrappedComponent = WrappedComponent;
315
+ return WithApollo;
316
+ }(React__namespace.Component));
317
+ return hoistNonReactStatics__default(WithApollo, WrappedComponent, {});
318
+ }
319
+
320
+ exports.graphql = graphql;
321
+ exports.withApollo = withApollo;
322
+ exports.withMutation = withMutation;
323
+ exports.withQuery = withQuery;
324
+ exports.withSubscription = withSubscription;
325
+ //# sourceMappingURL=hoc.cjs.map