@apollo/client 3.8.0-rc.1 → 3.8.0-rc.2

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 (292) hide show
  1. package/apollo-client.cjs +231 -202
  2. package/apollo-client.cjs.map +1 -1
  3. package/apollo-client.min.cjs +1 -1
  4. package/cache/index.d.ts +13 -7
  5. package/cache/index.d.ts.map +1 -1
  6. package/cache/index.js +4 -4
  7. package/cache/index.js.map +1 -1
  8. package/cache/inmemory/types.d.ts +2 -2
  9. package/cache/inmemory/types.d.ts.map +1 -1
  10. package/cache/inmemory/types.js.map +1 -1
  11. package/core/core.cjs +2 -2
  12. package/core/core.cjs.map +1 -1
  13. package/core/core.cjs.native.js +2 -2
  14. package/core/equalByQuery.d.ts +2 -2
  15. package/core/equalByQuery.js +3 -3
  16. package/core/equalByQuery.js.map +1 -1
  17. package/core/index.d.ts +19 -14
  18. package/core/index.d.ts.map +1 -1
  19. package/core/index.js +12 -12
  20. package/core/index.js.map +1 -1
  21. package/core/types.d.ts +1 -1
  22. package/core/types.d.ts.map +1 -1
  23. package/core/types.js.map +1 -1
  24. package/dev/dev.cjs +22 -24
  25. package/dev/dev.cjs.map +1 -1
  26. package/dev/dev.cjs.native.js +22 -24
  27. package/dev/index.d.ts +3 -3
  28. package/dev/index.js +3 -3
  29. package/dev/index.js.map +1 -1
  30. package/dev/loadDevMessages.js +2 -2
  31. package/dev/loadDevMessages.js.map +1 -1
  32. package/dev/loadErrorMessageHandler.d.ts +1 -1
  33. package/dev/loadErrorMessageHandler.js +4 -4
  34. package/dev/loadErrorMessageHandler.js.map +1 -1
  35. package/dev/loadErrorMessages.js +2 -2
  36. package/dev/loadErrorMessages.js.map +1 -1
  37. package/invariantErrorCodes.js +16 -18
  38. package/link/batch/batchLink.d.ts +2 -1
  39. package/link/batch/batchLink.d.ts.map +1 -1
  40. package/link/batch/batchLink.js.map +1 -1
  41. package/link/core/types.d.ts +2 -2
  42. package/link/core/types.d.ts.map +1 -1
  43. package/link/core/types.js.map +1 -1
  44. package/link/http/index.d.ts +6 -3
  45. package/link/http/index.d.ts.map +1 -1
  46. package/link/http/index.js +1 -1
  47. package/link/http/index.js.map +1 -1
  48. package/link/remove-typename/index.d.ts +2 -1
  49. package/link/remove-typename/index.d.ts.map +1 -1
  50. package/link/remove-typename/index.js +1 -1
  51. package/link/remove-typename/index.js.map +1 -1
  52. package/link/remove-typename/remove-typename.cjs +2 -2
  53. package/link/remove-typename/remove-typename.cjs.map +1 -1
  54. package/link/remove-typename/remove-typename.cjs.native.js +2 -2
  55. package/link/remove-typename/removeTypenameFromVariables.d.ts +1 -1
  56. package/link/remove-typename/removeTypenameFromVariables.js +6 -6
  57. package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
  58. package/link/utils/index.d.ts +2 -1
  59. package/link/utils/index.d.ts.map +1 -1
  60. package/link/utils/index.js.map +1 -1
  61. package/package.json +2 -10
  62. package/react/cache/QueryReference.d.ts +10 -6
  63. package/react/cache/QueryReference.d.ts.map +1 -1
  64. package/react/cache/QueryReference.js +42 -31
  65. package/react/cache/QueryReference.js.map +1 -1
  66. package/react/cache/SuspenseCache.d.ts +3 -3
  67. package/react/cache/SuspenseCache.d.ts.map +1 -1
  68. package/react/cache/SuspenseCache.js +3 -3
  69. package/react/cache/SuspenseCache.js.map +1 -1
  70. package/react/cache/getSuspenseCache.d.ts +4 -4
  71. package/react/cache/getSuspenseCache.js +2 -2
  72. package/react/cache/getSuspenseCache.js.map +1 -1
  73. package/react/cache/index.d.ts +3 -3
  74. package/react/cache/index.js +5 -5
  75. package/react/cache/index.js.map +1 -1
  76. package/react/cache/types.d.ts +5 -1
  77. package/react/cache/types.d.ts.map +1 -1
  78. package/react/cache/types.js.map +1 -1
  79. package/react/components/Mutation.d.ts +3 -3
  80. package/react/components/Mutation.js +3 -3
  81. package/react/components/Mutation.js.map +1 -1
  82. package/react/components/Query.d.ts +3 -3
  83. package/react/components/Query.d.ts.map +1 -1
  84. package/react/components/Query.js +3 -3
  85. package/react/components/Query.js.map +1 -1
  86. package/react/components/Subscription.d.ts +3 -3
  87. package/react/components/Subscription.d.ts.map +1 -1
  88. package/react/components/Subscription.js +3 -3
  89. package/react/components/Subscription.js.map +1 -1
  90. package/react/components/components.cjs +3 -3
  91. package/react/components/components.cjs.map +1 -1
  92. package/react/components/components.cjs.native.js +3 -3
  93. package/react/components/index.d.ts +4 -4
  94. package/react/components/index.js +4 -4
  95. package/react/components/index.js.map +1 -1
  96. package/react/components/types.d.ts +4 -4
  97. package/react/components/types.d.ts.map +1 -1
  98. package/react/components/types.js.map +1 -1
  99. package/react/context/ApolloConsumer.d.ts +2 -2
  100. package/react/context/ApolloConsumer.js +3 -3
  101. package/react/context/ApolloConsumer.js.map +1 -1
  102. package/react/context/ApolloContext.d.ts +3 -10
  103. package/react/context/ApolloContext.d.ts.map +1 -1
  104. package/react/context/ApolloContext.js +15 -13
  105. package/react/context/ApolloContext.js.map +1 -1
  106. package/react/context/ApolloProvider.d.ts +2 -2
  107. package/react/context/ApolloProvider.js +3 -3
  108. package/react/context/ApolloProvider.js.map +1 -1
  109. package/react/context/context.cjs +12 -10
  110. package/react/context/context.cjs.map +1 -1
  111. package/react/context/context.cjs.native.js +12 -10
  112. package/react/context/index.d.ts +7 -4
  113. package/react/context/index.d.ts.map +1 -1
  114. package/react/context/index.js +4 -4
  115. package/react/context/index.js.map +1 -1
  116. package/react/hoc/graphql.d.ts +3 -3
  117. package/react/hoc/graphql.js +4 -4
  118. package/react/hoc/graphql.js.map +1 -1
  119. package/react/hoc/hoc-utils.d.ts +3 -3
  120. package/react/hoc/hoc-utils.d.ts.map +1 -1
  121. package/react/hoc/hoc-utils.js +5 -5
  122. package/react/hoc/hoc-utils.js.map +1 -1
  123. package/react/hoc/hoc.cjs +24 -23
  124. package/react/hoc/hoc.cjs.map +1 -1
  125. package/react/hoc/hoc.cjs.native.js +24 -23
  126. package/react/hoc/index.d.ts +7 -7
  127. package/react/hoc/index.js +7 -7
  128. package/react/hoc/index.js.map +1 -1
  129. package/react/hoc/mutation-hoc.d.ts +5 -5
  130. package/react/hoc/mutation-hoc.d.ts.map +1 -1
  131. package/react/hoc/mutation-hoc.js +13 -11
  132. package/react/hoc/mutation-hoc.js.map +1 -1
  133. package/react/hoc/query-hoc.d.ts +3 -3
  134. package/react/hoc/query-hoc.d.ts.map +1 -1
  135. package/react/hoc/query-hoc.js +10 -10
  136. package/react/hoc/query-hoc.js.map +1 -1
  137. package/react/hoc/subscription-hoc.d.ts +3 -3
  138. package/react/hoc/subscription-hoc.d.ts.map +1 -1
  139. package/react/hoc/subscription-hoc.js +11 -12
  140. package/react/hoc/subscription-hoc.js.map +1 -1
  141. package/react/hoc/types.d.ts +4 -4
  142. package/react/hoc/types.d.ts.map +1 -1
  143. package/react/hoc/types.js.map +1 -1
  144. package/react/hoc/withApollo.d.ts +3 -3
  145. package/react/hoc/withApollo.js +6 -6
  146. package/react/hoc/withApollo.js.map +1 -1
  147. package/react/hooks/constants.d.ts +3 -0
  148. package/react/hooks/constants.d.ts.map +1 -0
  149. package/react/hooks/constants.js +2 -0
  150. package/react/hooks/constants.js.map +1 -0
  151. package/react/hooks/hooks.cjs +182 -160
  152. package/react/hooks/hooks.cjs.map +1 -1
  153. package/react/hooks/hooks.cjs.native.js +182 -160
  154. package/react/hooks/index.d.ts +15 -11
  155. package/react/hooks/index.d.ts.map +1 -1
  156. package/react/hooks/index.js +12 -11
  157. package/react/hooks/index.js.map +1 -1
  158. package/react/hooks/internal/__use.js +6 -6
  159. package/react/hooks/internal/__use.js.map +1 -1
  160. package/react/hooks/internal/index.d.ts +3 -3
  161. package/react/hooks/internal/index.js +3 -3
  162. package/react/hooks/internal/index.js.map +1 -1
  163. package/react/hooks/internal/useDeepMemo.d.ts +1 -1
  164. package/react/hooks/internal/useDeepMemo.js +2 -2
  165. package/react/hooks/internal/useDeepMemo.js.map +1 -1
  166. package/react/hooks/internal/useIsomorphicLayoutEffect.d.ts +1 -1
  167. package/react/hooks/internal/useIsomorphicLayoutEffect.js +2 -2
  168. package/react/hooks/internal/useIsomorphicLayoutEffect.js.map +1 -1
  169. package/react/hooks/useApolloClient.d.ts +1 -1
  170. package/react/hooks/useApolloClient.js +3 -3
  171. package/react/hooks/useApolloClient.js.map +1 -1
  172. package/react/hooks/useBackgroundQuery.d.ts +48 -21
  173. package/react/hooks/useBackgroundQuery.d.ts.map +1 -1
  174. package/react/hooks/useBackgroundQuery.js +14 -17
  175. package/react/hooks/useBackgroundQuery.js.map +1 -1
  176. package/react/hooks/useFragment.d.ts.map +1 -1
  177. package/react/hooks/useFragment.js +7 -2
  178. package/react/hooks/useFragment.js.map +1 -1
  179. package/react/hooks/useLazyQuery.d.ts +4 -4
  180. package/react/hooks/useLazyQuery.d.ts.map +1 -1
  181. package/react/hooks/useLazyQuery.js +13 -12
  182. package/react/hooks/useLazyQuery.js.map +1 -1
  183. package/react/hooks/useMutation.d.ts +4 -4
  184. package/react/hooks/useMutation.d.ts.map +1 -1
  185. package/react/hooks/useMutation.js +28 -18
  186. package/react/hooks/useMutation.js.map +1 -1
  187. package/react/hooks/useQuery.d.ts +6 -5
  188. package/react/hooks/useQuery.d.ts.map +1 -1
  189. package/react/hooks/useQuery.js +45 -40
  190. package/react/hooks/useQuery.js.map +1 -1
  191. package/react/hooks/useReactiveVar.d.ts +1 -1
  192. package/react/hooks/useReactiveVar.js +1 -1
  193. package/react/hooks/useReactiveVar.js.map +1 -1
  194. package/react/hooks/useReadQuery.d.ts +2 -3
  195. package/react/hooks/useReadQuery.d.ts.map +1 -1
  196. package/react/hooks/useReadQuery.js +11 -24
  197. package/react/hooks/useReadQuery.js.map +1 -1
  198. package/react/hooks/useSubscription.d.ts +4 -4
  199. package/react/hooks/useSubscription.d.ts.map +1 -1
  200. package/react/hooks/useSubscription.js +10 -10
  201. package/react/hooks/useSubscription.js.map +1 -1
  202. package/react/hooks/useSuspenseQuery.d.ts +15 -10
  203. package/react/hooks/useSuspenseQuery.d.ts.map +1 -1
  204. package/react/hooks/useSuspenseQuery.js +22 -18
  205. package/react/hooks/useSuspenseQuery.js.map +1 -1
  206. package/react/hooks/useSyncExternalStore.d.ts.map +1 -1
  207. package/react/hooks/useSyncExternalStore.js +33 -30
  208. package/react/hooks/useSyncExternalStore.js.map +1 -1
  209. package/react/index.d.ts +8 -6
  210. package/react/index.d.ts.map +1 -1
  211. package/react/index.js +6 -6
  212. package/react/index.js.map +1 -1
  213. package/react/parser/index.d.ts +1 -1
  214. package/react/parser/index.d.ts.map +1 -1
  215. package/react/parser/index.js +14 -12
  216. package/react/parser/index.js.map +1 -1
  217. package/react/parser/parser.cjs +13 -11
  218. package/react/parser/parser.cjs.map +1 -1
  219. package/react/parser/parser.cjs.native.js +13 -11
  220. package/react/react.cjs +34 -30
  221. package/react/react.cjs.map +1 -1
  222. package/react/react.cjs.native.js +34 -30
  223. package/react/ssr/RenderPromises.d.ts +2 -2
  224. package/react/ssr/RenderPromises.d.ts.map +1 -1
  225. package/react/ssr/RenderPromises.js +17 -15
  226. package/react/ssr/RenderPromises.js.map +1 -1
  227. package/react/ssr/getDataFromTree.d.ts +2 -2
  228. package/react/ssr/getDataFromTree.d.ts.map +1 -1
  229. package/react/ssr/getDataFromTree.js +9 -7
  230. package/react/ssr/getDataFromTree.js.map +1 -1
  231. package/react/ssr/index.d.ts +3 -3
  232. package/react/ssr/index.js +3 -3
  233. package/react/ssr/index.js.map +1 -1
  234. package/react/ssr/renderToStringWithData.d.ts +1 -1
  235. package/react/ssr/renderToStringWithData.js +3 -3
  236. package/react/ssr/renderToStringWithData.js.map +1 -1
  237. package/react/ssr/ssr.cjs +23 -19
  238. package/react/ssr/ssr.cjs.map +1 -1
  239. package/react/ssr/ssr.cjs.native.js +23 -19
  240. package/react/types/types.d.ts +18 -19
  241. package/react/types/types.d.ts.map +1 -1
  242. package/react/types/types.js.map +1 -1
  243. package/testing/core/index.d.ts +8 -7
  244. package/testing/core/index.d.ts.map +1 -1
  245. package/testing/core/index.js +7 -7
  246. package/testing/core/index.js.map +1 -1
  247. package/testing/index.d.ts +2 -1
  248. package/testing/index.d.ts.map +1 -1
  249. package/testing/index.js.map +1 -1
  250. package/testing/matchers/index.js +3 -3
  251. package/testing/matchers/index.js.map +1 -1
  252. package/testing/matchers/toHaveSuspenseCacheEntryUsing.d.ts +3 -3
  253. package/testing/matchers/toHaveSuspenseCacheEntryUsing.js +6 -6
  254. package/testing/matchers/toHaveSuspenseCacheEntryUsing.js.map +1 -1
  255. package/testing/matchers/toMatchDocument.d.ts +2 -2
  256. package/testing/matchers/toMatchDocument.js +8 -8
  257. package/testing/matchers/toMatchDocument.js.map +1 -1
  258. package/utilities/common/omitDeep.d.ts +1 -1
  259. package/utilities/common/omitDeep.js +1 -1
  260. package/utilities/common/omitDeep.js.map +1 -1
  261. package/utilities/common/stripTypename.js +2 -2
  262. package/utilities/common/stripTypename.js.map +1 -1
  263. package/utilities/globals/globals.cjs +4 -4
  264. package/utilities/globals/globals.cjs.map +1 -1
  265. package/utilities/globals/globals.cjs.native.js +4 -4
  266. package/utilities/globals/invariantWrappers.d.ts +2 -2
  267. package/utilities/globals/invariantWrappers.js +7 -7
  268. package/utilities/globals/invariantWrappers.js.map +1 -1
  269. package/utilities/graphql/DocumentTransform.d.ts +1 -1
  270. package/utilities/graphql/DocumentTransform.js +4 -4
  271. package/utilities/graphql/DocumentTransform.js.map +1 -1
  272. package/utilities/graphql/operations.d.ts +1 -1
  273. package/utilities/graphql/operations.js +4 -4
  274. package/utilities/graphql/operations.js.map +1 -1
  275. package/utilities/graphql/print.d.ts +1 -1
  276. package/utilities/graphql/print.js +2 -2
  277. package/utilities/graphql/print.js.map +1 -1
  278. package/utilities/index.d.ts +40 -34
  279. package/utilities/index.d.ts.map +1 -1
  280. package/utilities/index.js +32 -32
  281. package/utilities/index.js.map +1 -1
  282. package/utilities/promises/decoration.d.ts +3 -3
  283. package/utilities/promises/decoration.js +8 -8
  284. package/utilities/promises/decoration.js.map +1 -1
  285. package/utilities/types/DeepOmit.d.ts +1 -1
  286. package/utilities/types/DeepOmit.js.map +1 -1
  287. package/utilities/types/DeepPartial.d.ts +1 -1
  288. package/utilities/types/DeepPartial.js.map +1 -1
  289. package/utilities/utilities.cjs +12 -12
  290. package/utilities/utilities.cjs.map +1 -1
  291. package/utilities/utilities.cjs.native.js +12 -12
  292. package/version.js +1 -1
@@ -30,7 +30,7 @@ var hoistNonReactStatics__default = /*#__PURE__*/_interopDefaultLegacy(hoistNonR
30
30
  var defaultMapPropsToOptions = function () { return ({}); };
31
31
  var defaultMapPropsToSkip = function () { return false; };
32
32
  function getDisplayName$1(WrappedComponent) {
33
- return WrappedComponent.displayName || WrappedComponent.name || 'Component';
33
+ return WrappedComponent.displayName || WrappedComponent.name || "Component";
34
34
  }
35
35
  function calculateVariablesFromProps(operation, props) {
36
36
  var variables = {};
@@ -40,11 +40,11 @@ function calculateVariablesFromProps(operation, props) {
40
40
  continue;
41
41
  var variableName = variable.name.value;
42
42
  var variableProp = props[variableName];
43
- if (typeof variableProp !== 'undefined') {
43
+ if (typeof variableProp !== "undefined") {
44
44
  variables[variableName] = variableProp;
45
45
  continue;
46
46
  }
47
- if (type.kind !== 'NonNullType') {
47
+ if (type.kind !== "NonNullType") {
48
48
  variables[variableName] = undefined;
49
49
  }
50
50
  }
@@ -71,13 +71,13 @@ var GraphQLBase = (function (_super) {
71
71
  function withQuery(document, operationOptions) {
72
72
  if (operationOptions === void 0) { operationOptions = {}; }
73
73
  var operation = parser.parser(document);
74
- 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;
74
+ 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;
75
75
  var mapPropsToOptions = options;
76
- if (typeof mapPropsToOptions !== 'function') {
76
+ if (typeof mapPropsToOptions !== "function") {
77
77
  mapPropsToOptions = function () { return options; };
78
78
  }
79
79
  var mapPropsToSkip = skip;
80
- if (typeof mapPropsToSkip !== 'function') {
80
+ if (typeof mapPropsToSkip !== "function") {
81
81
  mapPropsToSkip = function () { return skip; };
82
82
  }
83
83
  var lastResultProps;
@@ -104,14 +104,14 @@ function withQuery(document, operationOptions) {
104
104
  if (operationOptions.withRef) {
105
105
  _this.withRef = true;
106
106
  props = Object.assign({}, props, {
107
- ref: _this.setWrappedInstance
107
+ ref: _this.setWrappedInstance,
108
108
  });
109
109
  }
110
110
  if (shouldSkip) {
111
111
  return (React__namespace.createElement(WrappedComponent, tslib.__assign({}, props, {})));
112
112
  }
113
113
  var result = Object.assign(r, data || {});
114
- var name = operationOptions.name || 'data';
114
+ var name = operationOptions.name || "data";
115
115
  var childProps = (_b = {}, _b[name] = result, _b);
116
116
  if (operationOptions.props) {
117
117
  var newResult = (_c = {},
@@ -135,10 +135,12 @@ function withQuery(document, operationOptions) {
135
135
  function withMutation(document, operationOptions) {
136
136
  if (operationOptions === void 0) { operationOptions = {}; }
137
137
  var operation = parser.parser(document);
138
- var _a = operationOptions.options, options = _a === void 0 ? defaultMapPropsToOptions : _a, _b = operationOptions.alias, alias = _b === void 0 ? 'Apollo' : _b;
138
+ var _a = operationOptions.options, options = _a === void 0 ? defaultMapPropsToOptions : _a, _b = operationOptions.alias, alias = _b === void 0 ? "Apollo" : _b;
139
139
  var mapPropsToOptions = options;
140
- if (typeof mapPropsToOptions !== 'function')
141
- mapPropsToOptions = function () { return options; };
140
+ if (typeof mapPropsToOptions !== "function")
141
+ mapPropsToOptions = function () {
142
+ return options;
143
+ };
142
144
  return function (WrappedComponent) {
143
145
  var graphQLDisplayName = "".concat(alias, "(").concat(getDisplayName$1(WrappedComponent), ")");
144
146
  var GraphQL = (function (_super) {
@@ -152,7 +154,7 @@ function withMutation(document, operationOptions) {
152
154
  if (operationOptions.withRef) {
153
155
  this.withRef = true;
154
156
  props = Object.assign({}, props, {
155
- ref: this.setWrappedInstance
157
+ ref: this.setWrappedInstance,
156
158
  });
157
159
  }
158
160
  if (!opts.variables && operation.variables.length > 0) {
@@ -162,10 +164,10 @@ function withMutation(document, operationOptions) {
162
164
  var _b, _c;
163
165
  var data = _a.data, r = tslib.__rest(_a, ["data"]);
164
166
  var result = Object.assign(r, data || {});
165
- var name = operationOptions.name || 'mutate';
167
+ var name = operationOptions.name || "mutate";
166
168
  var resultName = operationOptions.name
167
169
  ? "".concat(name, "Result")
168
- : 'result';
170
+ : "result";
169
171
  var childProps = (_b = {},
170
172
  _b[name] = mutate,
171
173
  _b[resultName] = result,
@@ -192,12 +194,12 @@ function withMutation(document, operationOptions) {
192
194
  function withSubscription(document, operationOptions) {
193
195
  if (operationOptions === void 0) { operationOptions = {}; }
194
196
  var operation = parser.parser(document);
195
- 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 _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;
196
198
  var mapPropsToOptions = options;
197
- if (typeof mapPropsToOptions !== 'function')
199
+ if (typeof mapPropsToOptions !== "function")
198
200
  mapPropsToOptions = function () { return options; };
199
201
  var mapPropsToSkip = skip;
200
- if (typeof mapPropsToSkip !== 'function')
202
+ if (typeof mapPropsToSkip !== "function")
201
203
  mapPropsToSkip = function () { return skip; };
202
204
  var lastResultProps;
203
205
  return function (WrappedComponent) {
@@ -213,8 +215,7 @@ function withSubscription(document, operationOptions) {
213
215
  this.setState({ resubscribe: resubscribe });
214
216
  };
215
217
  GraphQL.prototype.componentDidUpdate = function (prevProps) {
216
- var resubscribe = !!(shouldResubscribe &&
217
- shouldResubscribe(prevProps, this.props));
218
+ var resubscribe = !!(shouldResubscribe && shouldResubscribe(prevProps, this.props));
218
219
  if (this.state.resubscribe !== resubscribe) {
219
220
  this.updateResubscribe(resubscribe);
220
221
  }
@@ -235,14 +236,14 @@ function withSubscription(document, operationOptions) {
235
236
  if (operationOptions.withRef) {
236
237
  _this.withRef = true;
237
238
  props = Object.assign({}, props, {
238
- ref: _this.setWrappedInstance
239
+ ref: _this.setWrappedInstance,
239
240
  });
240
241
  }
241
242
  if (shouldSkip) {
242
243
  return (React__namespace.createElement(WrappedComponent, tslib.__assign({}, props, {})));
243
244
  }
244
245
  var result = Object.assign(r, data || {});
245
- var name = operationOptions.name || 'data';
246
+ var name = operationOptions.name || "data";
246
247
  var childProps = (_b = {}, _b[name] = result, _b);
247
248
  if (operationOptions.props) {
248
249
  var newResult = (_c = {},
@@ -277,7 +278,7 @@ function graphql(document, operationOptions) {
277
278
  }
278
279
 
279
280
  function getDisplayName(WrappedComponent) {
280
- return WrappedComponent.displayName || WrappedComponent.name || 'Component';
281
+ return WrappedComponent.displayName || WrappedComponent.name || "Component";
281
282
  }
282
283
  function withApollo(WrappedComponent, operationOptions) {
283
284
  if (operationOptions === void 0) { operationOptions = {}; }
@@ -303,7 +304,7 @@ function withApollo(WrappedComponent, operationOptions) {
303
304
  client: client,
304
305
  ref: operationOptions.withRef
305
306
  ? _this.setWrappedInstance
306
- : undefined
307
+ : undefined,
307
308
  });
308
309
  return React__namespace.createElement(WrappedComponent, tslib.__assign({}, props));
309
310
  }));
@@ -1,8 +1,8 @@
1
- import '../../utilities/globals/index.js';
2
- export { graphql } from './graphql.js';
3
- export { withQuery } from './query-hoc.js';
4
- export { withMutation } from './mutation-hoc.js';
5
- export { withSubscription } from './subscription-hoc.js';
6
- export { withApollo } from './withApollo.js';
7
- export * from './types.js';
1
+ import "../../utilities/globals/index.js";
2
+ export { graphql } from "./graphql.js";
3
+ export { withQuery } from "./query-hoc.js";
4
+ export { withMutation } from "./mutation-hoc.js";
5
+ export { withSubscription } from "./subscription-hoc.js";
6
+ export { withApollo } from "./withApollo.js";
7
+ export * from "./types.js";
8
8
  //# sourceMappingURL=index.d.ts.map
@@ -1,8 +1,8 @@
1
- import '../../utilities/globals/index.js';
2
- export { graphql } from './graphql.js';
3
- export { withQuery } from './query-hoc.js';
4
- export { withMutation } from './mutation-hoc.js';
5
- export { withSubscription } from './subscription-hoc.js';
6
- export { withApollo } from './withApollo.js';
7
- export * from './types.js';
1
+ import "../../utilities/globals/index.js";
2
+ export { graphql } from "./graphql.js";
3
+ export { withQuery } from "./query-hoc.js";
4
+ export { withMutation } from "./mutation-hoc.js";
5
+ export { withSubscription } from "./subscription-hoc.js";
6
+ export { withApollo } from "./withApollo.js";
7
+ export * from "./types.js";
8
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/hoc/index.ts"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAC;AAE1C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,cAAc,YAAY,CAAC","sourcesContent":["import '../../utilities/globals/index.js';\n\nexport { graphql } from './graphql.js';\n\nexport { withQuery } from './query-hoc.js';\nexport { withMutation } from './mutation-hoc.js';\nexport { withSubscription } from './subscription-hoc.js';\nexport { withApollo } from './withApollo.js';\n\nexport * from './types.js';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/hoc/index.ts"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,CAAC;AAE1C,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAEvC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,cAAc,YAAY,CAAC","sourcesContent":["import \"../../utilities/globals/index.js\";\n\nexport { graphql } from \"./graphql.js\";\n\nexport { withQuery } from \"./query-hoc.js\";\nexport { withMutation } from \"./mutation-hoc.js\";\nexport { withSubscription } from \"./subscription-hoc.js\";\nexport { withApollo } from \"./withApollo.js\";\n\nexport * from \"./types.js\";\n"]}
@@ -1,7 +1,7 @@
1
- import * as React from 'react';
2
- import type { DocumentNode } from 'graphql';
3
- import type { DefaultContext, OperationVariables } from '../../core/types.js';
4
- import type { OperationOption, MutateProps } from './types.js';
5
- import type { ApolloCache } from '../../core/index.js';
1
+ import * as React from "react";
2
+ import type { DocumentNode } from "graphql";
3
+ import type { DefaultContext, OperationVariables } from "../../core/types.js";
4
+ import type { OperationOption, MutateProps } from "./types.js";
5
+ import type { ApolloCache } from "../../core/index.js";
6
6
  export declare function withMutation<TProps extends TGraphQLVariables | {} = {}, TData extends Record<string, any> = {}, TGraphQLVariables extends OperationVariables = {}, TChildProps = MutateProps<TData, TGraphQLVariables>, TContext extends Record<string, any> = DefaultContext, TCache extends ApolloCache<any> = ApolloCache<any>>(document: DocumentNode, operationOptions?: OperationOption<TProps, TData, TGraphQLVariables, TChildProps>): (WrappedComponent: React.ComponentType<TProps & TChildProps>) => React.ComponentClass<TProps>;
7
7
  //# sourceMappingURL=mutation-hoc.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"mutation-hoc.d.ts","sourceRoot":"","sources":["../../../src/react/hoc/mutation-hoc.tsx"],"names":[],"mappings":"AAAA,OA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,MAAM,qBAAqB,CAAC;AAEvD,wBAAgB,YAAY,CAC1B,MAAM,SAAS,iBAAiB,GAAG,EAAE,GAAG,EAAE,EAC1C,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,EAAE,EACtC,iBAAiB,SAAS,kBAAkB,GAAG,EAAE,EACjD,WAAW,GAAG,WAAW,CAAC,KAAK,EAAE,iBAAiB,CAAC,EACnD,QAAQ,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,cAAc,EACrD,MAAM,SAAS,WAAW,CAAC,GAAG,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,EAElD,QAAQ,EAAE,YAAY,EACtB,gBAAgB,GAAE,eAAe,CAC/B,MAAM,EACN,KAAK,EACL,iBAAiB,EACjB,WAAW,CACP,sBAsBc,MAAM,aAAa,CAAC,MAAM,GAAG,WAAW,CAAC,KAC1D,MAAM,cAAc,CAAC,MAAM,CAAC,CAkEhC"}
@@ -1,16 +1,18 @@
1
1
  import { __assign, __extends, __rest } from "tslib";
2
- import * as React from 'react';
3
- import hoistNonReactStatics from 'hoist-non-react-statics';
4
- import { parser } from '../parser/index.js';
5
- import { Mutation } from '../components/index.js';
6
- import { defaultMapPropsToOptions, getDisplayName, calculateVariablesFromProps, GraphQLBase } from './hoc-utils.js';
2
+ import * as React from "react";
3
+ import hoistNonReactStatics from "hoist-non-react-statics";
4
+ import { parser } from "../parser/index.js";
5
+ import { Mutation } from "../components/index.js";
6
+ import { defaultMapPropsToOptions, getDisplayName, calculateVariablesFromProps, GraphQLBase, } from "./hoc-utils.js";
7
7
  export function withMutation(document, operationOptions) {
8
8
  if (operationOptions === void 0) { operationOptions = {}; }
9
9
  var operation = parser(document);
10
- var _a = operationOptions.options, options = _a === void 0 ? defaultMapPropsToOptions : _a, _b = operationOptions.alias, alias = _b === void 0 ? 'Apollo' : _b;
10
+ var _a = operationOptions.options, options = _a === void 0 ? defaultMapPropsToOptions : _a, _b = operationOptions.alias, alias = _b === void 0 ? "Apollo" : _b;
11
11
  var mapPropsToOptions = options;
12
- if (typeof mapPropsToOptions !== 'function')
13
- mapPropsToOptions = function () { return options; };
12
+ if (typeof mapPropsToOptions !== "function")
13
+ mapPropsToOptions = function () {
14
+ return options;
15
+ };
14
16
  return function (WrappedComponent) {
15
17
  var graphQLDisplayName = "".concat(alias, "(").concat(getDisplayName(WrappedComponent), ")");
16
18
  var GraphQL = (function (_super) {
@@ -24,7 +26,7 @@ export function withMutation(document, operationOptions) {
24
26
  if (operationOptions.withRef) {
25
27
  this.withRef = true;
26
28
  props = Object.assign({}, props, {
27
- ref: this.setWrappedInstance
29
+ ref: this.setWrappedInstance,
28
30
  });
29
31
  }
30
32
  if (!opts.variables && operation.variables.length > 0) {
@@ -34,10 +36,10 @@ export function withMutation(document, operationOptions) {
34
36
  var _b, _c;
35
37
  var data = _a.data, r = __rest(_a, ["data"]);
36
38
  var result = Object.assign(r, data || {});
37
- var name = operationOptions.name || 'mutate';
39
+ var name = operationOptions.name || "mutate";
38
40
  var resultName = operationOptions.name
39
41
  ? "".concat(name, "Result")
40
- : 'result';
42
+ : "result";
41
43
  var childProps = (_b = {},
42
44
  _b[name] = mutate,
43
45
  _b[resultName] = result,
@@ -1 +1 @@
1
- {"version":3,"file":"mutation-hoc.js","sourceRoot":"","sources":["../../../src/react/hoc/mutation-hoc.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAO5C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,OAAO,EACL,wBAAwB,EACxB,cAAc,EACd,2BAA2B,EAC3B,WAAW,EACZ,MAAM,gBAAgB,CAAC;AAIxB,MAAM,UAAU,YAAY,CAQ1B,QAAsB,EACtB,gBAKM;IALN,iCAAA,EAAA,qBAKM;IAGN,IAAM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I,IAAI,EAAE,CAAC,CAAC;oBAC5C,IAAM,IAAI,GAAG,gBAAgB,CAAC,IAAI,IAAI,QAAQ,CAAC;oBAC/C,IAAM,UAAU,GAAG,gBAAgB,CAAC,IAAI;wBACtC,CAAC,CAAC,UAAG,IAAI,WAAQ;wBACjB,CAAC,CAAC,QAAQ,CAAC;oBACb,IAAI,UAAU,GAAG,CAAC;wBAChB,GAAC,IAAI,IAAG,MAAM;wBACd,GAAC,UAAU,IAAG,MAAM;0BACE,CAAA,CAAC;oBACzB,IAAI,gBAAgB,CAAC,KAAK,EAAE;wBAC1B,IAAM,SAAS;4BAKb,GAAC,IAAI,IAAG,MAAM;4BACd,GAAC,UAAU,IAAG,MAAM;4BACpB,WAAQ,GAAE,KAAK;+BAChB,CAAC;wBACF,UAAU,GAAG,gBAAgB,CAAC,KAAK,CAAC,SAAS,CAAQ,CAAC;qBACvD;oBAED,OAAO,oBAAC,gBAAgB,eAAK,KAAK,EAAM,UAAU,EAAI,CAAC;gBACzD,CAAC,CACQ,CACZ,CAAC;YACJ,CAAC;YApDM,mBAAW,GAAG,kBAAkB,CAAC;YACjC,wBAAgB,GAAG,gBAAgB,CAAC;YAoD7C,cAAC;SAAA,AAtDD,CAAsB,WAAW,GAsDhC;QAGD,OAAO,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport type { DocumentNode } from 'graphql';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\n\nimport { parser } from '../parser/index.js';\nimport type { DefaultContext, OperationVariables } from '../../core/types.js';\nimport type {\n BaseMutationOptions,\n MutationFunction,\n MutationResult\n} from '../types/types.js';\nimport { Mutation } from '../components/index.js';\n\nimport {\n defaultMapPropsToOptions,\n getDisplayName,\n calculateVariablesFromProps,\n GraphQLBase\n} from './hoc-utils.js';\nimport type { OperationOption, OptionProps, MutateProps } from './types.js';\nimport type { ApolloCache } from '../../core/index.js';\n\nexport function withMutation<\n TProps extends TGraphQLVariables | {} = {},\n TData extends Record<string, any> = {},\n TGraphQLVariables extends OperationVariables = {},\n TChildProps = MutateProps<TData, TGraphQLVariables>,\n TContext extends Record<string, any> = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n>(\n document: DocumentNode,\n operationOptions: OperationOption<\n TProps,\n TData,\n TGraphQLVariables,\n TChildProps\n > = {}\n) {\n // this is memoized so if coming from `graphql` there is nearly no extra cost\n const operation = parser(document);\n // extract options\n\n const {\n options = defaultMapPropsToOptions,\n alias = 'Apollo'\n } = operationOptions;\n\n let mapPropsToOptions = options as (props: any) => BaseMutationOptions<TData, TGraphQLVariables, TContext, TCache>;\n if (typeof mapPropsToOptions !== 'function')\n mapPropsToOptions = () => options as BaseMutationOptions<TData, TGraphQLVariables, TContext, TCache>;\n\n return (\n WrappedComponent: React.ComponentType<TProps & TChildProps>\n ): React.ComponentClass<TProps> => {\n const graphQLDisplayName = `${alias}(${getDisplayName(WrappedComponent)})`;\n class GraphQL extends GraphQLBase<TProps, TChildProps> {\n static displayName = graphQLDisplayName;\n static WrappedComponent = WrappedComponent;\n render() {\n let props = this.props as TProps;\n const opts = mapPropsToOptions(props) as BaseMutationOptions<TData, TGraphQLVariables, TContext, TCache>;\n\n if (operationOptions.withRef) {\n this.withRef = true;\n props = Object.assign({}, props, {\n ref: this.setWrappedInstance\n });\n }\n if (!opts.variables && operation.variables.length > 0) {\n opts.variables = calculateVariablesFromProps(operation, props) as TGraphQLVariables;\n }\n\n return (\n <Mutation ignoreResults {...opts} mutation={document}>\n {(\n mutate: MutationFunction<TData, TGraphQLVariables>,\n { data, ...r }: MutationResult<TData>\n ) => {\n // the HOC's historically hoisted the data from the execution result\n // up onto the result since it was passed as a nested prop\n // we massage the Mutation component's shape here to replicate that\n // this matches the query HoC\n const result = Object.assign(r, data || {});\n const name = operationOptions.name || 'mutate';\n const resultName = operationOptions.name\n ? `${name}Result`\n : 'result';\n let childProps = ({\n [name]: mutate,\n [resultName]: result\n } as any) as TChildProps;\n if (operationOptions.props) {\n const newResult: OptionProps<\n TProps,\n TData,\n TGraphQLVariables\n > = {\n [name]: mutate,\n [resultName]: result,\n ownProps: props\n };\n childProps = operationOptions.props(newResult) as any;\n }\n\n return <WrappedComponent {...props} {...childProps} />;\n }}\n </Mutation>\n );\n }\n }\n\n // Make sure we preserve any custom statics on the original component.\n return hoistNonReactStatics(GraphQL, WrappedComponent, {});\n };\n}\n"]}
1
+ {"version":3,"file":"mutation-hoc.js","sourceRoot":"","sources":["../../../src/react/hoc/mutation-hoc.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAO5C,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAElD,OAAO,EACL,wBAAwB,EACxB,cAAc,EACd,2BAA2B,EAC3B,WAAW,GACZ,MAAM,gBAAgB,CAAC;AAIxB,MAAM,UAAU,YAAY,CAQ1B,QAAsB,EACtB,gBAKM;IALN,iCAAA,EAAA,qBAKM;IAGN,IAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAG3B,IAAA,KACN,gBAAgB,QADwB,EAAlC,OAAO,mBAAG,wBAAwB,KAAA,EAAE,KAC1C,gBAAgB,MAD0C,EAAhB,KAAK,mBAAG,QAAQ,KAAA,CACzC;IAEnB,IAAI,iBAAiB,GAAG,OAE4C,CAAC;IACrE,IAAI,OAAO,iBAAiB,KAAK,UAAU;QACzC,iBAAiB,GAAG;YAClB,OAAA,OAKC;QALD,CAKC,CAAC;IAEN,OAAO,UACL,gBAA2D;QAE3D,IAAM,kBAAkB,GAAG,UAAG,KAAK,cAAI,cAAc,CAAC,gBAAgB,CAAC,MAAG,CAAC;QAC3E;YAAsB,2BAAgC;YAAtD;;YA2DA,CAAC;Y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AAC;wBACJ,UAAU,GAAG,gBAAgB,CAAC,KAAK,CAAC,SAAS,CAAQ,CAAC;qBACvD;oBAED,OAAO,oBAAC,gBAAgB,eAAK,KAAK,EAAM,UAAU,EAAI,CAAC;gBACzD,CAAC,CACQ,CACZ,CAAC;YACJ,CAAC;YAzDM,mBAAW,GAAG,kBAAkB,CAAC;YACjC,wBAAgB,GAAG,gBAAgB,CAAC;YAyD7C,cAAC;SAAA,AA3DD,CAAsB,WAAW,GA2DhC;QAGD,OAAO,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import * as React from \"react\";\nimport type { DocumentNode } from \"graphql\";\nimport hoistNonReactStatics from \"hoist-non-react-statics\";\n\nimport { parser } from \"../parser/index.js\";\nimport type { DefaultContext, OperationVariables } from \"../../core/types.js\";\nimport type {\n BaseMutationOptions,\n MutationFunction,\n MutationResult,\n} from \"../types/types.js\";\nimport { Mutation } from \"../components/index.js\";\n\nimport {\n defaultMapPropsToOptions,\n getDisplayName,\n calculateVariablesFromProps,\n GraphQLBase,\n} from \"./hoc-utils.js\";\nimport type { OperationOption, OptionProps, MutateProps } from \"./types.js\";\nimport type { ApolloCache } from \"../../core/index.js\";\n\nexport function withMutation<\n TProps extends TGraphQLVariables | {} = {},\n TData extends Record<string, any> = {},\n TGraphQLVariables extends OperationVariables = {},\n TChildProps = MutateProps<TData, TGraphQLVariables>,\n TContext extends Record<string, any> = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n>(\n document: DocumentNode,\n operationOptions: OperationOption<\n TProps,\n TData,\n TGraphQLVariables,\n TChildProps\n > = {}\n) {\n // this is memoized so if coming from `graphql` there is nearly no extra cost\n const operation = parser(document);\n // extract options\n\n const { options = defaultMapPropsToOptions, alias = \"Apollo\" } =\n operationOptions;\n\n let mapPropsToOptions = options as (\n props: any\n ) => BaseMutationOptions<TData, TGraphQLVariables, TContext, TCache>;\n if (typeof mapPropsToOptions !== \"function\")\n mapPropsToOptions = () =>\n options as BaseMutationOptions<\n TData,\n TGraphQLVariables,\n TContext,\n TCache\n >;\n\n return (\n WrappedComponent: React.ComponentType<TProps & TChildProps>\n ): React.ComponentClass<TProps> => {\n const graphQLDisplayName = `${alias}(${getDisplayName(WrappedComponent)})`;\n class GraphQL extends GraphQLBase<TProps, TChildProps> {\n static displayName = graphQLDisplayName;\n static WrappedComponent = WrappedComponent;\n render() {\n let props = this.props as TProps;\n const opts = mapPropsToOptions(props) as BaseMutationOptions<\n TData,\n TGraphQLVariables,\n TContext,\n TCache\n >;\n\n if (operationOptions.withRef) {\n this.withRef = true;\n props = Object.assign({}, props, {\n ref: this.setWrappedInstance,\n });\n }\n if (!opts.variables && operation.variables.length > 0) {\n opts.variables = calculateVariablesFromProps(\n operation,\n props\n ) as TGraphQLVariables;\n }\n\n return (\n <Mutation ignoreResults {...opts} mutation={document}>\n {(\n mutate: MutationFunction<TData, TGraphQLVariables>,\n { data, ...r }: MutationResult<TData>\n ) => {\n // the HOC's historically hoisted the data from the execution result\n // up onto the result since it was passed as a nested prop\n // we massage the Mutation component's shape here to replicate that\n // this matches the query HoC\n const result = Object.assign(r, data || {});\n const name = operationOptions.name || \"mutate\";\n const resultName = operationOptions.name\n ? `${name}Result`\n : \"result\";\n let childProps = {\n [name]: mutate,\n [resultName]: result,\n } as any as TChildProps;\n if (operationOptions.props) {\n const newResult: OptionProps<TProps, TData, TGraphQLVariables> =\n {\n [name]: mutate,\n [resultName]: result,\n ownProps: props,\n };\n childProps = operationOptions.props(newResult) as any;\n }\n\n return <WrappedComponent {...props} {...childProps} />;\n }}\n </Mutation>\n );\n }\n }\n\n // Make sure we preserve any custom statics on the original component.\n return hoistNonReactStatics(GraphQL, WrappedComponent, {});\n };\n}\n"]}
@@ -1,5 +1,5 @@
1
- import * as React from 'react';
2
- import type { DocumentNode } from 'graphql';
3
- import type { OperationOption, DataProps } from './types.js';
1
+ import * as React from "react";
2
+ import type { DocumentNode } from "graphql";
3
+ import type { OperationOption, DataProps } from "./types.js";
4
4
  export declare function withQuery<TProps extends TGraphQLVariables | Record<string, any> = Record<string, any>, TData extends object = {}, TGraphQLVariables extends object = {}, TChildProps extends object = DataProps<TData, TGraphQLVariables>>(document: DocumentNode, operationOptions?: OperationOption<TProps, TData, TGraphQLVariables, TChildProps>): (WrappedComponent: React.ComponentType<TProps & TChildProps>) => React.ComponentClass<TProps>;
5
5
  //# sourceMappingURL=query-hoc.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"query-hoc.d.ts","sourceRoot":"","sources":["../../../src/react/hoc/query-hoc.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAa5C,OAAO,KAAK,EAAE,eAAe,EAAe,SAAS,EAAE,MAAM,YAAY,CAAC;AAE1E,wBAAgB,SAAS,CACvB,MAAM,SAAS,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5E,KAAK,SAAS,MAAM,GAAG,EAAE,EACzB,iBAAiB,SAAS,MAAM,GAAG,EAAE,EACrC,WAAW,SAAS,MAAM,GAAG,SAAS,CAAC,KAAK,EAAE,iBAAiB,CAAC,EAEhE,QAAQ,EAAE,YAAY,EACtB,gBAAgB,GAAE,eAAe,CAC/B,MAAM,EACN,KAAK,EACL,iBAAiB,EACjB,WAAW,CACP,sBAwBc,MAAM,aAAa,CAAC,MAAM,GAAG,WAAW,CAAC,KAC1D,MAAM,cAAc,CAAC,MAAM,CAAC,CA+EhC"}
1
+ {"version":3,"file":"query-hoc.d.ts","sourceRoot":"","sources":["../../../src/react/hoc/query-hoc.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAC/B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAa5C,OAAO,KAAK,EAAE,eAAe,EAAe,SAAS,EAAE,MAAM,YAAY,CAAC;AAE1E,wBAAgB,SAAS,CACvB,MAAM,SAAS,iBAAiB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5E,KAAK,SAAS,MAAM,GAAG,EAAE,EACzB,iBAAiB,SAAS,MAAM,GAAG,EAAE,EACrC,WAAW,SAAS,MAAM,GAAG,SAAS,CAAC,KAAK,EAAE,iBAAiB,CAAC,EAEhE,QAAQ,EAAE,YAAY,EACtB,gBAAgB,GAAE,eAAe,CAC/B,MAAM,EACN,KAAK,EACL,iBAAiB,EACjB,WAAW,CACP,sBAwBc,MAAM,aAAa,CAAC,MAAM,GAAG,WAAW,CAAC,KAC1D,MAAM,cAAc,CAAC,MAAM,CAAC,CA4EhC"}
@@ -1,19 +1,19 @@
1
1
  import { __assign, __extends, __rest } from "tslib";
2
- import * as React from 'react';
3
- import hoistNonReactStatics from 'hoist-non-react-statics';
4
- import { parser } from '../parser/index.js';
5
- import { Query } from '../components/index.js';
6
- import { getDisplayName, GraphQLBase, calculateVariablesFromProps, defaultMapPropsToOptions, defaultMapPropsToSkip } from './hoc-utils.js';
2
+ import * as React from "react";
3
+ import hoistNonReactStatics from "hoist-non-react-statics";
4
+ import { parser } from "../parser/index.js";
5
+ import { Query } from "../components/index.js";
6
+ import { getDisplayName, GraphQLBase, calculateVariablesFromProps, defaultMapPropsToOptions, defaultMapPropsToSkip, } from "./hoc-utils.js";
7
7
  export function withQuery(document, operationOptions) {
8
8
  if (operationOptions === void 0) { operationOptions = {}; }
9
9
  var operation = parser(document);
10
- 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;
10
+ 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;
11
11
  var mapPropsToOptions = options;
12
- if (typeof mapPropsToOptions !== 'function') {
12
+ if (typeof mapPropsToOptions !== "function") {
13
13
  mapPropsToOptions = function () { return options; };
14
14
  }
15
15
  var mapPropsToSkip = skip;
16
- if (typeof mapPropsToSkip !== 'function') {
16
+ if (typeof mapPropsToSkip !== "function") {
17
17
  mapPropsToSkip = function () { return skip; };
18
18
  }
19
19
  var lastResultProps;
@@ -40,14 +40,14 @@ export function withQuery(document, operationOptions) {
40
40
  if (operationOptions.withRef) {
41
41
  _this.withRef = true;
42
42
  props = Object.assign({}, props, {
43
- ref: _this.setWrappedInstance
43
+ ref: _this.setWrappedInstance,
44
44
  });
45
45
  }
46
46
  if (shouldSkip) {
47
47
  return (React.createElement(WrappedComponent, __assign({}, props, {})));
48
48
  }
49
49
  var result = Object.assign(r, data || {});
50
- var name = operationOptions.name || 'data';
50
+ var name = operationOptions.name || "data";
51
51
  var childProps = (_b = {}, _b[name] = result, _b);
52
52
  if (operationOptions.props) {
53
53
  var newResult = (_c = {},
@@ -1 +1 @@
1
- {"version":3,"file":"query-hoc.js","sourceRoot":"","sources":["../../../src/react/hoc/query-hoc.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EACL,cAAc,EACd,WAAW,EACX,2BAA2B,EAC3B,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AAGxB,MAAM,UAAU,SAAS,CAMvB,QAAsB,EACtB,gBAKM;IALN,iCAAA,EAAA,qBAKM;IAGN,IAAM,SAAS,G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,EAAE,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport type { DocumentNode } from 'graphql';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\n\nimport { parser } from '../parser/index.js';\nimport type { BaseQueryOptions } from '../types/types.js';\nimport { Query } from '../components/index.js';\nimport {\n getDisplayName,\n GraphQLBase,\n calculateVariablesFromProps,\n defaultMapPropsToOptions,\n defaultMapPropsToSkip\n} from './hoc-utils.js';\nimport type { OperationOption, OptionProps, DataProps } from './types.js';\n\nexport function withQuery<\n TProps extends TGraphQLVariables | Record<string, any> = Record<string, any>,\n TData extends object = {},\n TGraphQLVariables extends object = {},\n TChildProps extends object = DataProps<TData, TGraphQLVariables>\n>(\n document: DocumentNode,\n operationOptions: OperationOption<\n TProps,\n TData,\n TGraphQLVariables,\n TChildProps\n > = {}\n) {\n // this is memoized so if coming from `graphql` there is nearly no extra cost\n const operation = parser(document);\n // extract options\n const {\n options = defaultMapPropsToOptions,\n skip = defaultMapPropsToSkip,\n alias = 'Apollo'\n } = operationOptions;\n\n let mapPropsToOptions = options as (props: any) => BaseQueryOptions;\n if (typeof mapPropsToOptions !== 'function') {\n mapPropsToOptions = () => options as BaseQueryOptions;\n }\n\n let mapPropsToSkip = skip as (props: any) => boolean;\n if (typeof mapPropsToSkip !== 'function') {\n mapPropsToSkip = () => skip as any;\n }\n\n // allow for advanced referential equality checks\n let lastResultProps: TChildProps | void;\n return (\n WrappedComponent: React.ComponentType<TProps & TChildProps>\n ): React.ComponentClass<TProps> => {\n const graphQLDisplayName = `${alias}(${getDisplayName(WrappedComponent)})`;\n class GraphQL extends GraphQLBase<TProps, TChildProps> {\n static displayName = graphQLDisplayName;\n static WrappedComponent = WrappedComponent;\n\n render() {\n let props = this.props;\n const shouldSkip = mapPropsToSkip(props);\n const opts = shouldSkip\n ? Object.create(null)\n : { ...mapPropsToOptions(props) };\n\n if (!shouldSkip && !opts.variables && operation.variables.length > 0) {\n opts.variables = calculateVariablesFromProps(operation, props);\n }\n\n return (\n <Query\n {...opts}\n displayName={graphQLDisplayName}\n skip={shouldSkip}\n query={document}\n >\n {({ client: _, data, ...r }: any) => {\n if (operationOptions.withRef) {\n this.withRef = true;\n props = Object.assign({}, props, {\n ref: this.setWrappedInstance\n });\n }\n\n // if we have skipped, no reason to manage any reshaping\n if (shouldSkip) {\n return (\n <WrappedComponent\n {...(props as TProps)}\n {...({} as TChildProps)}\n />\n );\n }\n\n // the HOC's historically hoisted the data from the execution result\n // up onto the result since it was passed as a nested prop\n // we massage the Query components shape here to replicate that\n const result = Object.assign(r, data || {});\n const name = operationOptions.name || 'data';\n let childProps = { [name]: result };\n if (operationOptions.props) {\n const newResult: OptionProps<\n TProps,\n TData,\n TGraphQLVariables\n > = {\n [name]: result,\n ownProps: props as TProps\n };\n lastResultProps = operationOptions.props(\n newResult,\n lastResultProps\n );\n childProps = lastResultProps;\n }\n\n return (\n <WrappedComponent\n {...(props as TProps)}\n {...(childProps as TChildProps)}\n />\n );\n }}\n </Query>\n );\n }\n }\n\n // Make sure we preserve any custom statics on the original component.\n return hoistNonReactStatics(GraphQL, WrappedComponent, {});\n };\n}\n"]}
1
+ {"version":3,"file":"query-hoc.js","sourceRoot":"","sources":["../../../src/react/hoc/query-hoc.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EACL,cAAc,EACd,WAAW,EACX,2BAA2B,EAC3B,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AAGxB,MAAM,UAAU,SAAS,CAMvB,QAAsB,EACtB,gBAKM;IALN,iCAAA,EAAA,qBAKM;IAGN,IAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,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C;IAC7D,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import * as React from \"react\";\nimport type { DocumentNode } from \"graphql\";\nimport hoistNonReactStatics from \"hoist-non-react-statics\";\n\nimport { parser } from \"../parser/index.js\";\nimport type { BaseQueryOptions } from \"../types/types.js\";\nimport { Query } from \"../components/index.js\";\nimport {\n getDisplayName,\n GraphQLBase,\n calculateVariablesFromProps,\n defaultMapPropsToOptions,\n defaultMapPropsToSkip,\n} from \"./hoc-utils.js\";\nimport type { OperationOption, OptionProps, DataProps } from \"./types.js\";\n\nexport function withQuery<\n TProps extends TGraphQLVariables | Record<string, any> = Record<string, any>,\n TData extends object = {},\n TGraphQLVariables extends object = {},\n TChildProps extends object = DataProps<TData, TGraphQLVariables>,\n>(\n document: DocumentNode,\n operationOptions: OperationOption<\n TProps,\n TData,\n TGraphQLVariables,\n TChildProps\n > = {}\n) {\n // this is memoized so if coming from `graphql` there is nearly no extra cost\n const operation = parser(document);\n // extract options\n const {\n options = defaultMapPropsToOptions,\n skip = defaultMapPropsToSkip,\n alias = \"Apollo\",\n } = operationOptions;\n\n let mapPropsToOptions = options as (props: any) => BaseQueryOptions;\n if (typeof mapPropsToOptions !== \"function\") {\n mapPropsToOptions = () => options as BaseQueryOptions;\n }\n\n let mapPropsToSkip = skip as (props: any) => boolean;\n if (typeof mapPropsToSkip !== \"function\") {\n mapPropsToSkip = () => skip as any;\n }\n\n // allow for advanced referential equality checks\n let lastResultProps: TChildProps | void;\n return (\n WrappedComponent: React.ComponentType<TProps & TChildProps>\n ): React.ComponentClass<TProps> => {\n const graphQLDisplayName = `${alias}(${getDisplayName(WrappedComponent)})`;\n class GraphQL extends GraphQLBase<TProps, TChildProps> {\n static displayName = graphQLDisplayName;\n static WrappedComponent = WrappedComponent;\n\n render() {\n let props = this.props;\n const shouldSkip = mapPropsToSkip(props);\n const opts = shouldSkip\n ? Object.create(null)\n : { ...mapPropsToOptions(props) };\n\n if (!shouldSkip && !opts.variables && operation.variables.length > 0) {\n opts.variables = calculateVariablesFromProps(operation, props);\n }\n\n return (\n <Query\n {...opts}\n displayName={graphQLDisplayName}\n skip={shouldSkip}\n query={document}\n >\n {({ client: _, data, ...r }: any) => {\n if (operationOptions.withRef) {\n this.withRef = true;\n props = Object.assign({}, props, {\n ref: this.setWrappedInstance,\n });\n }\n\n // if we have skipped, no reason to manage any reshaping\n if (shouldSkip) {\n return (\n <WrappedComponent\n {...(props as TProps)}\n {...({} as TChildProps)}\n />\n );\n }\n\n // the HOC's historically hoisted the data from the execution result\n // up onto the result since it was passed as a nested prop\n // we massage the Query components shape here to replicate that\n const result = Object.assign(r, data || {});\n const name = operationOptions.name || \"data\";\n let childProps = { [name]: result };\n if (operationOptions.props) {\n const newResult: OptionProps<TProps, TData, TGraphQLVariables> =\n {\n [name]: result,\n ownProps: props as TProps,\n };\n lastResultProps = operationOptions.props(\n newResult,\n lastResultProps\n );\n childProps = lastResultProps;\n }\n\n return (\n <WrappedComponent\n {...(props as TProps)}\n {...(childProps as TChildProps)}\n />\n );\n }}\n </Query>\n );\n }\n }\n\n // Make sure we preserve any custom statics on the original component.\n return hoistNonReactStatics(GraphQL, WrappedComponent, {});\n };\n}\n"]}
@@ -1,5 +1,5 @@
1
- import * as React from 'react';
2
- import type { DocumentNode } from 'graphql';
3
- import type { OperationOption, DataProps } from './types.js';
1
+ import * as React from "react";
2
+ import type { DocumentNode } from "graphql";
3
+ import type { OperationOption, DataProps } from "./types.js";
4
4
  export declare function withSubscription<TProps extends TGraphQLVariables | {} = {}, TData extends object = {}, TGraphQLVariables extends object = {}, TChildProps extends object = DataProps<TData, TGraphQLVariables>>(document: DocumentNode, operationOptions?: OperationOption<TProps, TData, TGraphQLVariables, TChildProps>): (WrappedComponent: React.ComponentType<TProps & TChildProps>) => React.ComponentClass<TProps>;
5
5
  //# sourceMappingURL=subscription-hoc.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"subscription-hoc.d.ts","sourceRoot":"","sources":["../../../src/react/hoc/subscription-hoc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WAAW,CAAC,KAC1D,MAAM,cAAc,CAAC,MAAM,CAAC,CAgGhC"}
@@ -1,18 +1,18 @@
1
1
  import { __assign, __extends, __rest } from "tslib";
2
- import * as React from 'react';
3
- import hoistNonReactStatics from 'hoist-non-react-statics';
4
- import { parser } from '../parser/index.js';
5
- import { Subscription } from '../components/index.js';
6
- import { getDisplayName, GraphQLBase, calculateVariablesFromProps, defaultMapPropsToOptions, defaultMapPropsToSkip } from './hoc-utils.js';
2
+ import * as React from "react";
3
+ import hoistNonReactStatics from "hoist-non-react-statics";
4
+ import { parser } from "../parser/index.js";
5
+ import { Subscription } from "../components/index.js";
6
+ import { getDisplayName, GraphQLBase, calculateVariablesFromProps, defaultMapPropsToOptions, defaultMapPropsToSkip, } from "./hoc-utils.js";
7
7
  export function withSubscription(document, operationOptions) {
8
8
  if (operationOptions === void 0) { operationOptions = {}; }
9
9
  var operation = parser(document);
10
- 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;
10
+ 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;
11
11
  var mapPropsToOptions = options;
12
- if (typeof mapPropsToOptions !== 'function')
12
+ if (typeof mapPropsToOptions !== "function")
13
13
  mapPropsToOptions = function () { return options; };
14
14
  var mapPropsToSkip = skip;
15
- if (typeof mapPropsToSkip !== 'function')
15
+ if (typeof mapPropsToSkip !== "function")
16
16
  mapPropsToSkip = function () { return skip; };
17
17
  var lastResultProps;
18
18
  return function (WrappedComponent) {
@@ -28,8 +28,7 @@ export function withSubscription(document, operationOptions) {
28
28
  this.setState({ resubscribe: resubscribe });
29
29
  };
30
30
  GraphQL.prototype.componentDidUpdate = function (prevProps) {
31
- var resubscribe = !!(shouldResubscribe &&
32
- shouldResubscribe(prevProps, this.props));
31
+ var resubscribe = !!(shouldResubscribe && shouldResubscribe(prevProps, this.props));
33
32
  if (this.state.resubscribe !== resubscribe) {
34
33
  this.updateResubscribe(resubscribe);
35
34
  }
@@ -50,14 +49,14 @@ export function withSubscription(document, operationOptions) {
50
49
  if (operationOptions.withRef) {
51
50
  _this.withRef = true;
52
51
  props = Object.assign({}, props, {
53
- ref: _this.setWrappedInstance
52
+ ref: _this.setWrappedInstance,
54
53
  });
55
54
  }
56
55
  if (shouldSkip) {
57
56
  return (React.createElement(WrappedComponent, __assign({}, props, {})));
58
57
  }
59
58
  var result = Object.assign(r, data || {});
60
- var name = operationOptions.name || 'data';
59
+ var name = operationOptions.name || "data";
61
60
  var childProps = (_b = {}, _b[name] = result, _b);
62
61
  if (operationOptions.props) {
63
62
  var newResult = (_c = {},
@@ -1 +1 @@
1
- {"version":3,"file":"subscription-hoc.js","sourceRoot":"","sources":["../../../src/react/hoc/subscription-hoc.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EACL,cAAc,EACd,WAAW,EACX,2BAA2B,EAC3B,wBAAwB,EACxB,qBAAqB,EACtB,MAAM,gBAAgB,CAAC;AAGxB,MAAM,UAAU,gBAAgB,CAM9B,QAAsB,EACtB,gBAKM;IALN,iCAAA,EAAA,qBAKM;IAGN,IAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAGjC,IAAA,KAIE,gBAAgB,QAJgB,EAAlC,OAAO,mBAAG,wBAAwB,KAAA,EAClC,KAGE,gBAAgB,KAHU,EAA5B,IA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Ae;+BAC1B,CAAC;wBACF,eAAe,GAAG,gBAAgB,CAAC,KAAK,CACtC,SAAS,EACT,eAAe,CAChB,CAAC;wBACF,UAAU,GAAG,eAAe,CAAC;qBAC9B;oBAED,OAAO,CACL,oBAAC,gBAAgB,eACV,KAAgB,EAChB,UAA0B,EAC/B,CACH,CAAC;gBACJ,CAAC,CACY,CAChB,CAAC;YACJ,CAAC;YAvFM,mBAAW,GAAG,kBAAkB,CAAC;YACjC,wBAAgB,GAAG,gBAAgB,CAAC;YAuF7C,cAAC;SAAA,AA7FD,CAAsB,WAAW,GA6FhC;QAGD,OAAO,oBAAoB,CAAC,OAAO,EAAE,gBAAgB,EAAE,EAAE,CAAC,CAAC;IAC7D,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import * as React from 'react';\nimport type { DocumentNode } from 'graphql';\nimport hoistNonReactStatics from 'hoist-non-react-statics';\n\nimport { parser } from '../parser/index.js';\nimport type { BaseQueryOptions } from '../types/types.js';\nimport { Subscription } from '../components/index.js';\nimport {\n getDisplayName,\n GraphQLBase,\n calculateVariablesFromProps,\n defaultMapPropsToOptions,\n defaultMapPropsToSkip\n} from './hoc-utils.js';\nimport type { OperationOption, OptionProps, DataProps } from './types.js';\n\nexport function withSubscription<\n TProps extends TGraphQLVariables | {} = {},\n TData extends object = {},\n TGraphQLVariables extends object = {},\n TChildProps extends object = DataProps<TData, TGraphQLVariables>\n>(\n document: DocumentNode,\n operationOptions: OperationOption<\n TProps,\n TData,\n TGraphQLVariables,\n TChildProps\n > = {}\n) {\n // this is memoized so if coming from `graphql` there is nearly no extra cost\n const operation = parser(document);\n // extract options\n const {\n options = defaultMapPropsToOptions,\n skip = defaultMapPropsToSkip,\n alias = 'Apollo',\n shouldResubscribe\n } = operationOptions;\n\n let mapPropsToOptions = options as (props: any) => BaseQueryOptions;\n if (typeof mapPropsToOptions !== 'function')\n mapPropsToOptions = () => options as BaseQueryOptions;\n\n let mapPropsToSkip = skip as (props: any) => boolean;\n if (typeof mapPropsToSkip !== 'function') mapPropsToSkip = () => skip as any;\n\n // allow for advanced referential equality checks\n let lastResultProps: TChildProps | void;\n return (\n WrappedComponent: React.ComponentType<TProps & TChildProps>\n ): React.ComponentClass<TProps> => {\n const graphQLDisplayName = `${alias}(${getDisplayName(WrappedComponent)})`;\n class GraphQL extends GraphQLBase<\n TProps,\n TChildProps,\n { resubscribe: boolean }\n > {\n static displayName = graphQLDisplayName;\n static WrappedComponent = WrappedComponent;\n constructor(props: TProps) {\n super(props);\n this.state = { resubscribe: false };\n }\n\n updateResubscribe(resubscribe: boolean) {\n this.setState({ resubscribe });\n }\n\n componentDidUpdate(prevProps: TProps) {\n const resubscribe = !!(\n shouldResubscribe &&\n shouldResubscribe(prevProps, this.props)\n );\n if (this.state.resubscribe !== resubscribe) {\n this.updateResubscribe(resubscribe);\n }\n }\n\n render() {\n let props = this.props;\n const shouldSkip = mapPropsToSkip(props);\n const opts = shouldSkip\n ? Object.create(null)\n : mapPropsToOptions(props);\n\n if (!shouldSkip && !opts.variables && operation.variables.length > 0) {\n opts.variables = calculateVariablesFromProps(operation, props);\n }\n return (\n <Subscription\n {...opts}\n displayName={graphQLDisplayName}\n skip={shouldSkip}\n subscription={document}\n shouldResubscribe={this.state.resubscribe}\n >\n {({ data, ...r }: any) => {\n if (operationOptions.withRef) {\n this.withRef = true;\n props = Object.assign({}, props, {\n ref: this.setWrappedInstance\n });\n }\n // if we have skipped, no reason to manage any reshaping\n if (shouldSkip) {\n return (\n <WrappedComponent\n {...(props as TProps)}\n {...({} as TChildProps)}\n />\n );\n }\n\n // the HOC's historically hoisted the data from the execution result\n // up onto the result since it was passed as a nested prop\n // we massage the Query components shape here to replicate that\n const result = Object.assign(r, data || {});\n const name = operationOptions.name || 'data';\n let childProps = { [name]: result };\n if (operationOptions.props) {\n const newResult: OptionProps<\n TProps,\n TData,\n TGraphQLVariables\n > = {\n [name]: result,\n ownProps: props as TProps\n };\n lastResultProps = operationOptions.props(\n newResult,\n lastResultProps\n );\n childProps = lastResultProps;\n }\n\n return (\n <WrappedComponent\n {...(props as TProps)}\n {...(childProps as TChildProps)}\n />\n );\n }}\n </Subscription>\n );\n }\n }\n\n // Make sure we preserve any custom statics on the original component.\n return hoistNonReactStatics(GraphQL, WrappedComponent, {});\n };\n}\n"]}
1
+ {"version":3,"file":"subscription-hoc.js","sourceRoot":"","sources":["../../../src/react/hoc/subscription-hoc.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,oBAAoB,MAAM,yBAAyB,CAAC;AAE3D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EACL,cAAc,EACd,WAAW,EACX,2BAA2B,EAC3B,wBAAwB,EACxB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC;AAGxB,MAAM,UAAU,gBAAgB,CAM9B,QAAsB,EACtB,gBAKM;IALN,iCAAA,EAAA,qBAKM;IAGN,IAAM,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC;IAGjC,IAAA,KAIE,gBAAgB,QAJgB,EAAlC,OAAO,mBAAG,wBAAwB,KAAA,EAClC,KAGE,gBAAgB,KAHU,EAA5B,IAAI,mBAAG,qBAAqB,KAAA,EAC5B,KAEE,gBAAgB,MAFF,EAAhB,KAAK,mBAAG,QAAQ,KAAA,EAChB,iBAAiB,GACf,gBAAgB,kBADD,CACE;IAErB,IAAI,iBAAiB,GAAG,OAA2C,CAAC;IACpE,IAAI,OAAO,iBAAiB,KAAK,UAAU;QACzC,iBAAiB,GAAG,cAAM,OAAA,OAA2B,EAA3B,CAA2B,CAAC;IAExD,IAAI,cAAc,GAAG,IAA+B,CAAC;IACrD,IAAI,OAAO,cAAc,KAAK,UAAU;QAAE,cAAc,GAAG,cAAM,OAAA,IAAW,EAAX,CAAW,CAAC;IAG7E,IAAI,eAAmC,CAAC;IACxC,OAAO,U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C,CAAC;IAC7D,CAAC,CAAC;AACJ,CAAC","sourcesContent":["import * as React from \"react\";\nimport type { DocumentNode } from \"graphql\";\nimport hoistNonReactStatics from \"hoist-non-react-statics\";\n\nimport { parser } from \"../parser/index.js\";\nimport type { BaseQueryOptions } from \"../types/types.js\";\nimport { Subscription } from \"../components/index.js\";\nimport {\n getDisplayName,\n GraphQLBase,\n calculateVariablesFromProps,\n defaultMapPropsToOptions,\n defaultMapPropsToSkip,\n} from \"./hoc-utils.js\";\nimport type { OperationOption, OptionProps, DataProps } from \"./types.js\";\n\nexport function withSubscription<\n TProps extends TGraphQLVariables | {} = {},\n TData extends object = {},\n TGraphQLVariables extends object = {},\n TChildProps extends object = DataProps<TData, TGraphQLVariables>,\n>(\n document: DocumentNode,\n operationOptions: OperationOption<\n TProps,\n TData,\n TGraphQLVariables,\n TChildProps\n > = {}\n) {\n // this is memoized so if coming from `graphql` there is nearly no extra cost\n const operation = parser(document);\n // extract options\n const {\n options = defaultMapPropsToOptions,\n skip = defaultMapPropsToSkip,\n alias = \"Apollo\",\n shouldResubscribe,\n } = operationOptions;\n\n let mapPropsToOptions = options as (props: any) => BaseQueryOptions;\n if (typeof mapPropsToOptions !== \"function\")\n mapPropsToOptions = () => options as BaseQueryOptions;\n\n let mapPropsToSkip = skip as (props: any) => boolean;\n if (typeof mapPropsToSkip !== \"function\") mapPropsToSkip = () => skip as any;\n\n // allow for advanced referential equality checks\n let lastResultProps: TChildProps | void;\n return (\n WrappedComponent: React.ComponentType<TProps & TChildProps>\n ): React.ComponentClass<TProps> => {\n const graphQLDisplayName = `${alias}(${getDisplayName(WrappedComponent)})`;\n class GraphQL extends GraphQLBase<\n TProps,\n TChildProps,\n { resubscribe: boolean }\n > {\n static displayName = graphQLDisplayName;\n static WrappedComponent = WrappedComponent;\n constructor(props: TProps) {\n super(props);\n this.state = { resubscribe: false };\n }\n\n updateResubscribe(resubscribe: boolean) {\n this.setState({ resubscribe });\n }\n\n componentDidUpdate(prevProps: TProps) {\n const resubscribe = !!(\n shouldResubscribe && shouldResubscribe(prevProps, this.props)\n );\n if (this.state.resubscribe !== resubscribe) {\n this.updateResubscribe(resubscribe);\n }\n }\n\n render() {\n let props = this.props;\n const shouldSkip = mapPropsToSkip(props);\n const opts = shouldSkip\n ? Object.create(null)\n : mapPropsToOptions(props);\n\n if (!shouldSkip && !opts.variables && operation.variables.length > 0) {\n opts.variables = calculateVariablesFromProps(operation, props);\n }\n return (\n <Subscription\n {...opts}\n displayName={graphQLDisplayName}\n skip={shouldSkip}\n subscription={document}\n shouldResubscribe={this.state.resubscribe}\n >\n {({ data, ...r }: any) => {\n if (operationOptions.withRef) {\n this.withRef = true;\n props = Object.assign({}, props, {\n ref: this.setWrappedInstance,\n });\n }\n // if we have skipped, no reason to manage any reshaping\n if (shouldSkip) {\n return (\n <WrappedComponent\n {...(props as TProps)}\n {...({} as TChildProps)}\n />\n );\n }\n\n // the HOC's historically hoisted the data from the execution result\n // up onto the result since it was passed as a nested prop\n // we massage the Query components shape here to replicate that\n const result = Object.assign(r, data || {});\n const name = operationOptions.name || \"data\";\n let childProps = { [name]: result };\n if (operationOptions.props) {\n const newResult: OptionProps<TProps, TData, TGraphQLVariables> =\n {\n [name]: result,\n ownProps: props as TProps,\n };\n lastResultProps = operationOptions.props(\n newResult,\n lastResultProps\n );\n childProps = lastResultProps;\n }\n\n return (\n <WrappedComponent\n {...(props as TProps)}\n {...(childProps as TChildProps)}\n />\n );\n }}\n </Subscription>\n );\n }\n }\n\n // Make sure we preserve any custom statics on the original component.\n return hoistNonReactStatics(GraphQL, WrappedComponent, {});\n };\n}\n"]}
@@ -1,7 +1,7 @@
1
- import type { ApolloCache, ApolloClient } from '../../core/index.js';
2
- import type { ApolloError } from '../../errors/index.js';
3
- import type { ApolloQueryResult, OperationVariables, FetchMoreOptions, UpdateQueryOptions, FetchMoreQueryOptions, SubscribeToMoreOptions, DefaultContext } from '../../core/index.js';
4
- import type { MutationFunction, BaseQueryOptions, BaseMutationOptions, MutationResult } from '../types/types.js';
1
+ import type { ApolloCache, ApolloClient } from "../../core/index.js";
2
+ import type { ApolloError } from "../../errors/index.js";
3
+ import type { ApolloQueryResult, OperationVariables, FetchMoreOptions, UpdateQueryOptions, FetchMoreQueryOptions, SubscribeToMoreOptions, DefaultContext } from "../../core/index.js";
4
+ import type { MutationFunction, BaseQueryOptions, BaseMutationOptions, MutationResult } from "../types/types.js";
5
5
  export interface QueryControls<TData = any, TGraphQLVariables = OperationVariables> {
6
6
  error?: ApolloError;
7
7
  networkStatus: number;
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/react/hoc/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACtB,cAAc,EACf,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,mBAAmB,EACnB,cAAc,EACf,MAAM,mBAAmB,CAAC;AAE3B,MAAM,WAAW,aAAa,CAC5B,KAAK,GAAG,GAAG,EACX,iBAAiB,GAAG,kBAAkB;IAEtC,KAAK,CAAC,EAAE,WAAW,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,OAAO,EAAE,OAAO,CAAC;IACjB,SAAS,EAAE,iBAAiB,CAAC;IAC7B,SAAS,EAAE,CACT,gBAAgB,EAAE,qBAAqB,CAAC,iBAAiB,EAAE,KAAK,CAAC,GAC/D,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,CAAC,KACzC,OAAO,CAAC,iBAAiB,CAAC,KAAK,CAAC,CAAC,CAAC;IACvC,OAAO,EAAE,CAAC,SAAS,CAAC,EAAE,iBAAiB,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AE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,iBAAiB,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,OAAO,CAAC;IAClE,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,MAAM,gBAAgB,CAAC,CAAC,IAAI,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,YAAY,CAAC,GAAG,CAAC,CAAA;CAAE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/react/hoc/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ApolloCache, ApolloClient } from '../../core/index.js';\nimport type { ApolloError } from '../../errors/index.js';\nimport type {\n ApolloQueryResult,\n OperationVariables,\n FetchMoreOptions,\n UpdateQueryOptions,\n FetchMoreQueryOptions,\n SubscribeToMoreOptions,\n DefaultContext,\n} from '../../core/index.js';\nimport type {\n MutationFunction,\n BaseQueryOptions,\n BaseMutationOptions,\n MutationResult\n} from '../types/types.js';\n\nexport interface QueryControls<\n TData = any,\n TGraphQLVariables = OperationVariables\n> {\n error?: ApolloError;\n networkStatus: number;\n loading: boolean;\n variables: TGraphQLVariables;\n fetchMore: (\n fetchMoreOptions: FetchMoreQueryOptions<TGraphQLVariables, TData> &\n FetchMoreOptions<TData, TGraphQLVariables>\n ) => Promise<ApolloQueryResult<TData>>;\n refetch: (variables?: TGraphQLVariables) => Promise<ApolloQueryResult<TData>>;\n startPolling: (pollInterval: number) => void;\n stopPolling: () => void;\n subscribeToMore: (options: SubscribeToMoreOptions) => () => void;\n updateQuery: (\n mapFn: (previousQueryResult: any, options: UpdateQueryOptions<any>) => any\n ) => void;\n}\n\nexport type DataValue<\n TData,\n TGraphQLVariables = OperationVariables\n> = QueryControls<TData, TGraphQLVariables> &\n // data may not yet be loaded\n Partial<TData>;\n\nexport interface DataProps<TData, TGraphQLVariables = OperationVariables> {\n data: DataValue<TData, TGraphQLVariables>;\n}\n\nexport interface MutateProps<\n TData = any,\n TGraphQLVariables = OperationVariables\n> {\n mutate: MutationFunction<TData, TGraphQLVariables>;\n result: MutationResult<TData>;\n}\n\nexport type ChildProps<\n TProps = {},\n TData = {},\n TGraphQLVariables = OperationVariables\n> = TProps &\n Partial<DataProps<TData, TGraphQLVariables>> &\n Partial<MutateProps<TData, TGraphQLVariables>>;\n\nexport type ChildDataProps<\n TProps = {},\n TData = {},\n TGraphQLVariables = OperationVariables\n> = TProps & DataProps<TData, TGraphQLVariables>;\n\nexport type ChildMutateProps<\n TProps = {},\n TData = {},\n TGraphQLVariables = OperationVariables\n> = TProps & MutateProps<TData, TGraphQLVariables>;\n\nexport interface OptionProps<\n TProps = any,\n TData = any,\n TGraphQLVariables = OperationVariables\n>\n extends Partial<DataProps<TData, TGraphQLVariables>>,\n Partial<MutateProps<TData, TGraphQLVariables>> {\n ownProps: TProps;\n}\n\nexport interface OperationOption<\n TProps,\n TData,\n TGraphQLVariables extends OperationVariables = OperationVariables,\n TChildProps = ChildProps<TProps, TData, TGraphQLVariables>,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n> {\n options?:\n | BaseQueryOptions<TGraphQLVariables>\n | BaseMutationOptions<TData, TGraphQLVariables, TContext, TCache>\n | ((\n props: TProps\n ) =>\n | BaseQueryOptions<TGraphQLVariables>\n | BaseMutationOptions<TData, TGraphQLVariables, TContext, TCache>\n );\n props?: (\n props: OptionProps<TProps, TData, TGraphQLVariables>,\n lastProps?: TChildProps | void\n ) => TChildProps;\n skip?: boolean | ((props: TProps) => boolean);\n name?: string;\n withRef?: boolean;\n shouldResubscribe?: (props: TProps, nextProps: TProps) => boolean;\n alias?: string;\n}\n\nexport type WithApolloClient<P> = P & { client?: ApolloClient<any> };\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/react/hoc/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { ApolloCache, ApolloClient } from \"../../core/index.js\";\nimport type { ApolloError } from \"../../errors/index.js\";\nimport type {\n ApolloQueryResult,\n OperationVariables,\n FetchMoreOptions,\n UpdateQueryOptions,\n FetchMoreQueryOptions,\n SubscribeToMoreOptions,\n DefaultContext,\n} from \"../../core/index.js\";\nimport type {\n MutationFunction,\n BaseQueryOptions,\n BaseMutationOptions,\n MutationResult,\n} from \"../types/types.js\";\n\nexport interface QueryControls<\n TData = any,\n TGraphQLVariables = OperationVariables,\n> {\n error?: ApolloError;\n networkStatus: number;\n loading: boolean;\n variables: TGraphQLVariables;\n fetchMore: (\n fetchMoreOptions: FetchMoreQueryOptions<TGraphQLVariables, TData> &\n FetchMoreOptions<TData, TGraphQLVariables>\n ) => Promise<ApolloQueryResult<TData>>;\n refetch: (variables?: TGraphQLVariables) => Promise<ApolloQueryResult<TData>>;\n startPolling: (pollInterval: number) => void;\n stopPolling: () => void;\n subscribeToMore: (options: SubscribeToMoreOptions) => () => void;\n updateQuery: (\n mapFn: (previousQueryResult: any, options: UpdateQueryOptions<any>) => any\n ) => void;\n}\n\nexport type DataValue<\n TData,\n TGraphQLVariables = OperationVariables,\n> = QueryControls<TData, TGraphQLVariables> &\n // data may not yet be loaded\n Partial<TData>;\n\nexport interface DataProps<TData, TGraphQLVariables = OperationVariables> {\n data: DataValue<TData, TGraphQLVariables>;\n}\n\nexport interface MutateProps<\n TData = any,\n TGraphQLVariables = OperationVariables,\n> {\n mutate: MutationFunction<TData, TGraphQLVariables>;\n result: MutationResult<TData>;\n}\n\nexport type ChildProps<\n TProps = {},\n TData = {},\n TGraphQLVariables = OperationVariables,\n> = TProps &\n Partial<DataProps<TData, TGraphQLVariables>> &\n Partial<MutateProps<TData, TGraphQLVariables>>;\n\nexport type ChildDataProps<\n TProps = {},\n TData = {},\n TGraphQLVariables = OperationVariables,\n> = TProps & DataProps<TData, TGraphQLVariables>;\n\nexport type ChildMutateProps<\n TProps = {},\n TData = {},\n TGraphQLVariables = OperationVariables,\n> = TProps & MutateProps<TData, TGraphQLVariables>;\n\nexport interface OptionProps<\n TProps = any,\n TData = any,\n TGraphQLVariables = OperationVariables,\n> extends Partial<DataProps<TData, TGraphQLVariables>>,\n Partial<MutateProps<TData, TGraphQLVariables>> {\n ownProps: TProps;\n}\n\nexport interface OperationOption<\n TProps,\n TData,\n TGraphQLVariables extends OperationVariables = OperationVariables,\n TChildProps = ChildProps<TProps, TData, TGraphQLVariables>,\n TContext = DefaultContext,\n TCache extends ApolloCache<any> = ApolloCache<any>,\n> {\n options?:\n | BaseQueryOptions<TGraphQLVariables>\n | BaseMutationOptions<TData, TGraphQLVariables, TContext, TCache>\n | ((\n props: TProps\n ) =>\n | BaseQueryOptions<TGraphQLVariables>\n | BaseMutationOptions<TData, TGraphQLVariables, TContext, TCache>);\n props?: (\n props: OptionProps<TProps, TData, TGraphQLVariables>,\n lastProps?: TChildProps | void\n ) => TChildProps;\n skip?: boolean | ((props: TProps) => boolean);\n name?: string;\n withRef?: boolean;\n shouldResubscribe?: (props: TProps, nextProps: TProps) => boolean;\n alias?: string;\n}\n\nexport type WithApolloClient<P> = P & { client?: ApolloClient<any> };\n"]}
@@ -1,4 +1,4 @@
1
- import * as React from 'react';
2
- import type { OperationOption, WithApolloClient } from './types.js';
3
- export declare function withApollo<TProps, TResult = any>(WrappedComponent: React.ComponentType<WithApolloClient<Omit<TProps, 'client'>>>, operationOptions?: OperationOption<TProps, TResult>): React.ComponentClass<Omit<TProps, 'client'>>;
1
+ import * as React from "react";
2
+ import type { OperationOption, WithApolloClient } from "./types.js";
3
+ export declare function withApollo<TProps, TResult = any>(WrappedComponent: React.ComponentType<WithApolloClient<Omit<TProps, "client">>>, operationOptions?: OperationOption<TProps, TResult>): React.ComponentClass<Omit<TProps, "client">>;
4
4
  //# sourceMappingURL=withApollo.d.ts.map