@apollo/client 3.4.17 → 3.5.6

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 (421) hide show
  1. package/README.md +1 -1
  2. package/{apollo-client.cjs.js → apollo-client.cjs} +1219 -1280
  3. package/apollo-client.cjs.map +1 -0
  4. package/apollo-client.min.cjs +1 -0
  5. package/cache/{cache.cjs.js → cache.cjs} +757 -601
  6. package/cache/cache.cjs.map +1 -0
  7. package/cache/core/cache.d.ts +6 -4
  8. package/cache/core/cache.d.ts.map +1 -1
  9. package/cache/core/cache.js +28 -1
  10. package/cache/core/cache.js.map +1 -1
  11. package/cache/core/types/Cache.d.ts +12 -10
  12. package/cache/core/types/Cache.d.ts.map +1 -1
  13. package/cache/core/types/Cache.js.map +1 -1
  14. package/cache/core/types/DataProxy.d.ts +4 -0
  15. package/cache/core/types/DataProxy.d.ts.map +1 -1
  16. package/cache/core/types/DataProxy.js.map +1 -1
  17. package/cache/core/types/common.d.ts +8 -5
  18. package/cache/core/types/common.d.ts.map +1 -1
  19. package/cache/core/types/common.js +6 -11
  20. package/cache/core/types/common.js.map +1 -1
  21. package/cache/inmemory/helpers.js +1 -1
  22. package/cache/inmemory/helpers.js.map +1 -1
  23. package/cache/inmemory/inMemoryCache.d.ts +4 -4
  24. package/cache/inmemory/inMemoryCache.d.ts.map +1 -1
  25. package/cache/inmemory/inMemoryCache.js +12 -3
  26. package/cache/inmemory/inMemoryCache.js.map +1 -1
  27. package/cache/inmemory/key-extractor.d.ts +9 -0
  28. package/cache/inmemory/key-extractor.d.ts.map +1 -0
  29. package/cache/inmemory/key-extractor.js +118 -0
  30. package/cache/inmemory/key-extractor.js.map +1 -0
  31. package/cache/inmemory/policies.d.ts +7 -3
  32. package/cache/inmemory/policies.d.ts.map +1 -1
  33. package/cache/inmemory/policies.js +47 -118
  34. package/cache/inmemory/policies.js.map +1 -1
  35. package/cache/inmemory/readFromStore.d.ts +2 -2
  36. package/cache/inmemory/readFromStore.d.ts.map +1 -1
  37. package/cache/inmemory/readFromStore.js +54 -42
  38. package/cache/inmemory/readFromStore.js.map +1 -1
  39. package/cache/inmemory/writeToStore.d.ts +8 -3
  40. package/cache/inmemory/writeToStore.d.ts.map +1 -1
  41. package/cache/inmemory/writeToStore.js +166 -95
  42. package/cache/inmemory/writeToStore.js.map +1 -1
  43. package/cache/package.json +2 -1
  44. package/core/ApolloClient.d.ts +0 -1
  45. package/core/ApolloClient.d.ts.map +1 -1
  46. package/core/ApolloClient.js +3 -3
  47. package/core/ApolloClient.js.map +1 -1
  48. package/core/LocalState.js +1 -1
  49. package/core/LocalState.js.map +1 -1
  50. package/core/ObservableQuery.d.ts +2 -2
  51. package/core/ObservableQuery.d.ts.map +1 -1
  52. package/core/ObservableQuery.js +19 -14
  53. package/core/ObservableQuery.js.map +1 -1
  54. package/core/QueryInfo.d.ts +2 -2
  55. package/core/QueryInfo.d.ts.map +1 -1
  56. package/core/QueryInfo.js.map +1 -1
  57. package/core/QueryManager.d.ts +0 -1
  58. package/core/QueryManager.d.ts.map +1 -1
  59. package/core/QueryManager.js +10 -10
  60. package/core/QueryManager.js.map +1 -1
  61. package/core/{core.cjs.js → core.cjs} +38 -34
  62. package/core/core.cjs.map +1 -0
  63. package/core/package.json +2 -1
  64. package/errors/{errors.cjs.js → errors.cjs} +3 -3
  65. package/errors/errors.cjs.map +1 -0
  66. package/errors/index.d.ts +3 -1
  67. package/errors/index.d.ts.map +1 -1
  68. package/errors/index.js +2 -2
  69. package/errors/index.js.map +1 -1
  70. package/errors/package.json +2 -1
  71. package/invariantErrorCodes.js +84 -104
  72. package/link/batch/{batch.cjs.js → batch.cjs} +2 -2
  73. package/link/batch/batch.cjs.map +1 -0
  74. package/link/batch/batchLink.d.ts +0 -1
  75. package/link/batch/batchLink.d.ts.map +1 -1
  76. package/link/batch/batching.d.ts +0 -1
  77. package/link/batch/batching.d.ts.map +1 -1
  78. package/link/batch/batching.js +1 -1
  79. package/link/batch/batching.js.map +1 -1
  80. package/link/batch/package.json +2 -1
  81. package/link/batch-http/{batch-http.cjs.js → batch-http.cjs} +3 -3
  82. package/link/batch-http/batch-http.cjs.map +1 -0
  83. package/link/batch-http/batchHttpLink.d.ts +0 -1
  84. package/link/batch-http/batchHttpLink.d.ts.map +1 -1
  85. package/link/batch-http/batchHttpLink.js +3 -3
  86. package/link/batch-http/batchHttpLink.js.map +1 -1
  87. package/link/batch-http/package.json +2 -1
  88. package/link/context/{context.cjs.js → context.cjs} +1 -1
  89. package/link/context/context.cjs.map +1 -0
  90. package/link/context/index.js.map +1 -1
  91. package/link/context/package.json +2 -1
  92. package/link/core/ApolloLink.d.ts +2 -3
  93. package/link/core/ApolloLink.d.ts.map +1 -1
  94. package/link/core/ApolloLink.js +1 -1
  95. package/link/core/ApolloLink.js.map +1 -1
  96. package/link/core/{core.cjs.js → core.cjs} +2 -2
  97. package/link/core/core.cjs.map +1 -0
  98. package/link/core/package.json +2 -1
  99. package/link/core/types.d.ts +4 -7
  100. package/link/core/types.d.ts.map +1 -1
  101. package/link/core/types.js.map +1 -1
  102. package/link/error/{error.cjs.js → error.cjs} +2 -2
  103. package/link/error/error.cjs.map +1 -0
  104. package/link/error/index.d.ts +5 -7
  105. package/link/error/index.d.ts.map +1 -1
  106. package/link/error/index.js +1 -1
  107. package/link/error/index.js.map +1 -1
  108. package/link/error/package.json +2 -1
  109. package/link/http/checkFetcher.js +1 -1
  110. package/link/http/createHttpLink.d.ts.map +1 -1
  111. package/link/http/createHttpLink.js +3 -3
  112. package/link/http/createHttpLink.js.map +1 -1
  113. package/link/http/{http.cjs.js → http.cjs} +28 -15
  114. package/link/http/http.cjs.map +1 -0
  115. package/link/http/index.d.ts +1 -1
  116. package/link/http/index.d.ts.map +1 -1
  117. package/link/http/index.js +1 -1
  118. package/link/http/index.js.map +1 -1
  119. package/link/http/package.json +2 -1
  120. package/link/http/parseAndCheckHttpResponse.js +3 -3
  121. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  122. package/link/http/rewriteURIForGET.js +1 -1
  123. package/link/http/rewriteURIForGET.js.map +1 -1
  124. package/link/http/selectHttpOptionsAndBody.d.ts +11 -1
  125. package/link/http/selectHttpOptionsAndBody.d.ts.map +1 -1
  126. package/link/http/selectHttpOptionsAndBody.js +20 -7
  127. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  128. package/link/http/serializeFetchParameter.js +1 -1
  129. package/link/http/serializeFetchParameter.js.map +1 -1
  130. package/link/persisted-queries/index.d.ts.map +1 -1
  131. package/link/persisted-queries/index.js +3 -3
  132. package/link/persisted-queries/index.js.map +1 -1
  133. package/link/persisted-queries/package.json +2 -1
  134. package/link/persisted-queries/{persisted-queries.cjs.js → persisted-queries.cjs} +3 -3
  135. package/link/persisted-queries/persisted-queries.cjs.map +1 -0
  136. package/link/retry/package.json +2 -1
  137. package/link/retry/{retry.cjs.js → retry.cjs} +1 -1
  138. package/link/retry/retry.cjs.map +1 -0
  139. package/link/retry/retryLink.d.ts +0 -1
  140. package/link/retry/retryLink.d.ts.map +1 -1
  141. package/link/retry/retryLink.js.map +1 -1
  142. package/link/schema/index.d.ts +0 -1
  143. package/link/schema/index.d.ts.map +1 -1
  144. package/link/schema/index.js +8 -1
  145. package/link/schema/index.js.map +1 -1
  146. package/link/schema/package.json +2 -1
  147. package/link/schema/{schema.cjs.js → schema.cjs} +9 -2
  148. package/link/schema/schema.cjs.map +1 -0
  149. package/link/utils/fromError.d.ts +0 -1
  150. package/link/utils/fromError.d.ts.map +1 -1
  151. package/link/utils/fromPromise.d.ts +0 -1
  152. package/link/utils/fromPromise.d.ts.map +1 -1
  153. package/link/utils/package.json +2 -1
  154. package/link/utils/toPromise.d.ts +0 -1
  155. package/link/utils/toPromise.d.ts.map +1 -1
  156. package/link/utils/{utils.cjs.js → utils.cjs} +2 -2
  157. package/link/utils/utils.cjs.map +1 -0
  158. package/link/utils/validateOperation.js +1 -1
  159. package/link/utils/validateOperation.js.map +1 -1
  160. package/link/ws/index.d.ts +0 -1
  161. package/link/ws/index.d.ts.map +1 -1
  162. package/link/ws/package.json +2 -1
  163. package/link/ws/{ws.cjs.js → ws.cjs} +1 -1
  164. package/link/ws/ws.cjs.map +1 -0
  165. package/{main.cjs.js → main.cjs} +5 -5
  166. package/main.cjs.map +1 -0
  167. package/package.json +20 -19
  168. package/react/components/Query.js.map +1 -1
  169. package/react/components/{components.cjs.js → components.cjs} +4 -4
  170. package/react/components/components.cjs.map +1 -0
  171. package/react/components/package.json +2 -1
  172. package/react/context/ApolloConsumer.js +1 -1
  173. package/react/context/ApolloProvider.js +1 -1
  174. package/react/context/{context.cjs.js → context.cjs} +6 -6
  175. package/react/context/context.cjs.map +1 -0
  176. package/react/context/index.d.ts +3 -3
  177. package/react/context/index.d.ts.map +1 -1
  178. package/react/context/index.js +3 -3
  179. package/react/context/index.js.map +1 -1
  180. package/react/context/package.json +2 -1
  181. package/react/hoc/hoc-utils.js +1 -1
  182. package/react/hoc/{hoc.cjs.js → hoc.cjs} +12 -12
  183. package/react/hoc/hoc.cjs.map +1 -0
  184. package/react/hoc/mutation-hoc.js +2 -2
  185. package/react/hoc/mutation-hoc.js.map +1 -1
  186. package/react/hoc/package.json +2 -1
  187. package/react/hoc/query-hoc.js +1 -1
  188. package/react/hoc/query-hoc.js.map +1 -1
  189. package/react/hoc/subscription-hoc.js +1 -1
  190. package/react/hoc/subscription-hoc.js.map +1 -1
  191. package/react/hoc/withApollo.js +2 -2
  192. package/react/hoc/withApollo.js.map +1 -1
  193. package/react/hooks/hooks.cjs +502 -0
  194. package/react/hooks/hooks.cjs.map +1 -0
  195. package/react/hooks/package.json +2 -1
  196. package/react/hooks/useApolloClient.d.ts +1 -1
  197. package/react/hooks/useApolloClient.d.ts.map +1 -1
  198. package/react/hooks/useApolloClient.js +7 -5
  199. package/react/hooks/useApolloClient.js.map +1 -1
  200. package/react/hooks/useLazyQuery.d.ts.map +1 -1
  201. package/react/hooks/useLazyQuery.js +56 -2
  202. package/react/hooks/useLazyQuery.js.map +1 -1
  203. package/react/hooks/useMutation.d.ts.map +1 -1
  204. package/react/hooks/useMutation.js +89 -21
  205. package/react/hooks/useMutation.js.map +1 -1
  206. package/react/hooks/useQuery.d.ts +2 -3
  207. package/react/hooks/useQuery.d.ts.map +1 -1
  208. package/react/hooks/useQuery.js +224 -2
  209. package/react/hooks/useQuery.js.map +1 -1
  210. package/react/hooks/useSubscription.d.ts +2 -7
  211. package/react/hooks/useSubscription.d.ts.map +1 -1
  212. package/react/hooks/useSubscription.js +89 -32
  213. package/react/hooks/useSubscription.js.map +1 -1
  214. package/react/package.json +2 -1
  215. package/react/parser/index.d.ts +1 -0
  216. package/react/parser/index.d.ts.map +1 -1
  217. package/react/parser/index.js +16 -9
  218. package/react/parser/index.js.map +1 -1
  219. package/react/parser/package.json +2 -1
  220. package/react/parser/{parser.cjs.js → parser.cjs} +18 -10
  221. package/react/parser/parser.cjs.map +1 -0
  222. package/react/{react.cjs.js → react.cjs} +3 -3
  223. package/react/react.cjs.map +1 -0
  224. package/react/ssr/RenderPromises.d.ts +7 -3
  225. package/react/ssr/RenderPromises.d.ts.map +1 -1
  226. package/react/ssr/RenderPromises.js.map +1 -1
  227. package/react/ssr/package.json +2 -1
  228. package/react/ssr/{ssr.cjs.js → ssr.cjs} +4 -4
  229. package/react/ssr/ssr.cjs.map +1 -0
  230. package/react/types/types.d.ts +7 -18
  231. package/react/types/types.d.ts.map +1 -1
  232. package/react/types/types.js.map +1 -1
  233. package/testing/{testing.cjs.js → core/core.cjs} +10 -104
  234. package/testing/core/core.cjs.map +1 -0
  235. package/{utilities/testing → testing/core}/index.d.ts +0 -1
  236. package/testing/core/index.d.ts.map +1 -0
  237. package/{utilities/testing → testing/core}/index.js +0 -1
  238. package/testing/core/index.js.map +1 -0
  239. package/{utilities/testing → testing/core}/itAsync.d.ts +0 -0
  240. package/testing/core/itAsync.d.ts.map +1 -0
  241. package/{utilities/testing → testing/core}/itAsync.js +0 -0
  242. package/testing/core/itAsync.js.map +1 -0
  243. package/{utilities/testing → testing/core}/mocking/mockClient.d.ts +0 -0
  244. package/testing/core/mocking/mockClient.d.ts.map +1 -0
  245. package/{utilities/testing → testing/core}/mocking/mockClient.js +0 -0
  246. package/testing/core/mocking/mockClient.js.map +1 -0
  247. package/{utilities/testing → testing/core}/mocking/mockFetch.d.ts +0 -0
  248. package/testing/core/mocking/mockFetch.d.ts.map +1 -0
  249. package/{utilities/testing → testing/core}/mocking/mockFetch.js +1 -1
  250. package/testing/core/mocking/mockFetch.js.map +1 -0
  251. package/{utilities/testing → testing/core}/mocking/mockLink.d.ts +0 -1
  252. package/testing/core/mocking/mockLink.d.ts.map +1 -0
  253. package/{utilities/testing → testing/core}/mocking/mockLink.js +5 -5
  254. package/testing/core/mocking/mockLink.js.map +1 -0
  255. package/{utilities/testing → testing/core}/mocking/mockQueryManager.d.ts +1 -1
  256. package/testing/core/mocking/mockQueryManager.d.ts.map +1 -0
  257. package/{utilities/testing → testing/core}/mocking/mockQueryManager.js +1 -1
  258. package/testing/core/mocking/mockQueryManager.js.map +1 -0
  259. package/{utilities/testing → testing/core}/mocking/mockSubscriptionLink.d.ts +1 -4
  260. package/testing/core/mocking/mockSubscriptionLink.d.ts.map +1 -0
  261. package/{utilities/testing → testing/core}/mocking/mockSubscriptionLink.js +1 -1
  262. package/testing/core/mocking/mockSubscriptionLink.js.map +1 -0
  263. package/{utilities/testing → testing/core}/mocking/mockWatchQuery.d.ts +1 -1
  264. package/testing/core/mocking/mockWatchQuery.d.ts.map +1 -0
  265. package/{utilities/testing → testing/core}/mocking/mockWatchQuery.js +0 -0
  266. package/testing/core/mocking/mockWatchQuery.js.map +1 -0
  267. package/{utilities/testing → testing/core}/observableToPromise.d.ts +2 -3
  268. package/testing/core/observableToPromise.d.ts.map +1 -0
  269. package/{utilities/testing → testing/core}/observableToPromise.js +1 -1
  270. package/testing/core/observableToPromise.js.map +1 -0
  271. package/testing/core/package.json +8 -0
  272. package/testing/core/subscribeAndCount.d.ts +4 -0
  273. package/testing/core/subscribeAndCount.d.ts.map +1 -0
  274. package/{utilities/testing → testing/core}/subscribeAndCount.js +1 -1
  275. package/testing/core/subscribeAndCount.js.map +1 -0
  276. package/{utilities/testing → testing/core}/withConsoleSpy.d.ts +0 -0
  277. package/testing/core/withConsoleSpy.d.ts.map +1 -0
  278. package/{utilities/testing → testing/core}/withConsoleSpy.js +0 -0
  279. package/testing/core/withConsoleSpy.js.map +1 -0
  280. package/{utilities/testing → testing/core}/wrap.d.ts +0 -0
  281. package/testing/core/wrap.d.ts.map +1 -0
  282. package/{utilities/testing → testing/core}/wrap.js +0 -0
  283. package/testing/core/wrap.js.map +1 -0
  284. package/testing/index.d.ts +2 -1
  285. package/testing/index.d.ts.map +1 -1
  286. package/testing/index.js +2 -1
  287. package/testing/index.js.map +1 -1
  288. package/testing/package.json +2 -1
  289. package/{utilities/testing/mocking → testing/react}/MockedProvider.d.ts +5 -5
  290. package/testing/react/MockedProvider.d.ts.map +1 -0
  291. package/{utilities/testing/mocking → testing/react}/MockedProvider.js +4 -4
  292. package/testing/react/MockedProvider.js.map +1 -0
  293. package/testing/testing.cjs +58 -0
  294. package/testing/testing.cjs.map +1 -0
  295. package/utilities/common/errorHandling.d.ts +1 -1
  296. package/utilities/common/errorHandling.d.ts.map +1 -1
  297. package/utilities/common/errorHandling.js.map +1 -1
  298. package/utilities/common/makeUniqueId.js +1 -1
  299. package/utilities/common/makeUniqueId.js.map +1 -1
  300. package/utilities/common/mergeDeep.d.ts.map +1 -1
  301. package/utilities/common/mergeDeep.js +6 -1
  302. package/utilities/common/mergeDeep.js.map +1 -1
  303. package/utilities/globals/fix-graphql.js +1 -1
  304. package/utilities/globals/global.d.ts.map +1 -1
  305. package/utilities/globals/global.js +1 -1
  306. package/utilities/globals/global.js.map +1 -1
  307. package/utilities/globals/{globals.cjs.js → globals.cjs} +3 -3
  308. package/utilities/globals/globals.cjs.map +1 -0
  309. package/utilities/globals/index.js +1 -1
  310. package/utilities/globals/package.json +2 -1
  311. package/utilities/graphql/directives.js +5 -5
  312. package/utilities/graphql/directives.js.map +1 -1
  313. package/utilities/graphql/fragments.d.ts.map +1 -1
  314. package/utilities/graphql/fragments.js +4 -4
  315. package/utilities/graphql/fragments.js.map +1 -1
  316. package/utilities/graphql/getFromAST.js +8 -8
  317. package/utilities/graphql/getFromAST.js.map +1 -1
  318. package/utilities/graphql/storeUtils.js +6 -6
  319. package/utilities/graphql/storeUtils.js.map +1 -1
  320. package/utilities/graphql/transform.d.ts.map +1 -1
  321. package/utilities/graphql/transform.js.map +1 -1
  322. package/utilities/observables/Concast.d.ts +0 -1
  323. package/utilities/observables/Concast.d.ts.map +1 -1
  324. package/utilities/observables/asyncMap.d.ts +0 -1
  325. package/utilities/observables/asyncMap.d.ts.map +1 -1
  326. package/utilities/observables/subclassing.d.ts +0 -1
  327. package/utilities/observables/subclassing.d.ts.map +1 -1
  328. package/utilities/package.json +2 -1
  329. package/utilities/{utilities.cjs.js → utilities.cjs} +31 -26
  330. package/utilities/utilities.cjs.map +1 -0
  331. package/version.js +1 -1
  332. package/apollo-client.cjs.js.map +0 -1
  333. package/apollo-client.cjs.min.js +0 -1
  334. package/cache/cache.cjs.js.map +0 -1
  335. package/core/core.cjs.js.map +0 -1
  336. package/errors/errors.cjs.js.map +0 -1
  337. package/link/batch/batch.cjs.js.map +0 -1
  338. package/link/batch-http/batch-http.cjs.js.map +0 -1
  339. package/link/context/context.cjs.js.map +0 -1
  340. package/link/core/core.cjs.js.map +0 -1
  341. package/link/error/error.cjs.js.map +0 -1
  342. package/link/http/http.cjs.js.map +0 -1
  343. package/link/persisted-queries/persisted-queries.cjs.js.map +0 -1
  344. package/link/retry/retry.cjs.js.map +0 -1
  345. package/link/schema/schema.cjs.js.map +0 -1
  346. package/link/utils/utils.cjs.js.map +0 -1
  347. package/link/ws/ws.cjs.js.map +0 -1
  348. package/main.cjs.js.map +0 -1
  349. package/react/components/components.cjs.js.map +0 -1
  350. package/react/context/context.cjs.js.map +0 -1
  351. package/react/data/MutationData.d.ts +0 -29
  352. package/react/data/MutationData.d.ts.map +0 -1
  353. package/react/data/MutationData.js +0 -115
  354. package/react/data/MutationData.js.map +0 -1
  355. package/react/data/OperationData.d.ts +0 -24
  356. package/react/data/OperationData.d.ts.map +0 -1
  357. package/react/data/OperationData.js +0 -53
  358. package/react/data/OperationData.js.map +0 -1
  359. package/react/data/QueryData.d.ts +0 -44
  360. package/react/data/QueryData.d.ts.map +0 -1
  361. package/react/data/QueryData.js +0 -298
  362. package/react/data/QueryData.js.map +0 -1
  363. package/react/data/SubscriptionData.d.ts +0 -28
  364. package/react/data/SubscriptionData.d.ts.map +0 -1
  365. package/react/data/SubscriptionData.js +0 -122
  366. package/react/data/SubscriptionData.js.map +0 -1
  367. package/react/data/data.cjs.js +0 -581
  368. package/react/data/data.cjs.js.map +0 -1
  369. package/react/data/index.d.ts +0 -6
  370. package/react/data/index.d.ts.map +0 -1
  371. package/react/data/index.js +0 -6
  372. package/react/data/index.js.map +0 -1
  373. package/react/data/package.json +0 -7
  374. package/react/hoc/hoc.cjs.js.map +0 -1
  375. package/react/hooks/hooks.cjs.js +0 -195
  376. package/react/hooks/hooks.cjs.js.map +0 -1
  377. package/react/hooks/utils/useAfterFastRefresh.d.ts +0 -3
  378. package/react/hooks/utils/useAfterFastRefresh.d.ts.map +0 -1
  379. package/react/hooks/utils/useAfterFastRefresh.js +0 -19
  380. package/react/hooks/utils/useAfterFastRefresh.js.map +0 -1
  381. package/react/hooks/utils/useBaseQuery.d.ts +0 -7
  382. package/react/hooks/utils/useBaseQuery.d.ts.map +0 -1
  383. package/react/hooks/utils/useBaseQuery.js +0 -55
  384. package/react/hooks/utils/useBaseQuery.js.map +0 -1
  385. package/react/hooks/utils/useDeepMemo.d.ts +0 -2
  386. package/react/hooks/utils/useDeepMemo.d.ts.map +0 -1
  387. package/react/hooks/utils/useDeepMemo.js +0 -10
  388. package/react/hooks/utils/useDeepMemo.js.map +0 -1
  389. package/react/parser/parser.cjs.js.map +0 -1
  390. package/react/react.cjs.js.map +0 -1
  391. package/react/ssr/ssr.cjs.js.map +0 -1
  392. package/testing/testing.cjs.js.map +0 -1
  393. package/utilities/globals/globals.cjs.js.map +0 -1
  394. package/utilities/testing/index.d.ts.map +0 -1
  395. package/utilities/testing/index.js.map +0 -1
  396. package/utilities/testing/itAsync.d.ts.map +0 -1
  397. package/utilities/testing/itAsync.js.map +0 -1
  398. package/utilities/testing/mocking/MockedProvider.d.ts.map +0 -1
  399. package/utilities/testing/mocking/MockedProvider.js.map +0 -1
  400. package/utilities/testing/mocking/mockClient.d.ts.map +0 -1
  401. package/utilities/testing/mocking/mockClient.js.map +0 -1
  402. package/utilities/testing/mocking/mockFetch.d.ts.map +0 -1
  403. package/utilities/testing/mocking/mockFetch.js.map +0 -1
  404. package/utilities/testing/mocking/mockLink.d.ts.map +0 -1
  405. package/utilities/testing/mocking/mockLink.js.map +0 -1
  406. package/utilities/testing/mocking/mockQueryManager.d.ts.map +0 -1
  407. package/utilities/testing/mocking/mockQueryManager.js.map +0 -1
  408. package/utilities/testing/mocking/mockSubscriptionLink.d.ts.map +0 -1
  409. package/utilities/testing/mocking/mockSubscriptionLink.js.map +0 -1
  410. package/utilities/testing/mocking/mockWatchQuery.d.ts.map +0 -1
  411. package/utilities/testing/mocking/mockWatchQuery.js.map +0 -1
  412. package/utilities/testing/observableToPromise.d.ts.map +0 -1
  413. package/utilities/testing/observableToPromise.js.map +0 -1
  414. package/utilities/testing/subscribeAndCount.d.ts +0 -5
  415. package/utilities/testing/subscribeAndCount.d.ts.map +0 -1
  416. package/utilities/testing/subscribeAndCount.js.map +0 -1
  417. package/utilities/testing/withConsoleSpy.d.ts.map +0 -1
  418. package/utilities/testing/withConsoleSpy.js.map +0 -1
  419. package/utilities/testing/wrap.d.ts.map +0 -1
  420. package/utilities/testing/wrap.js.map +0 -1
  421. package/utilities/utilities.cjs.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"observableToPromise.js","sourceRoot":"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O,EAAE,CAAC,MAAM,CAAC,CAAC;oBAC1B,MAAM,CAAC,IAAI,KAAK,CAAC,oDAA6C,GAAG,CAAC,MAAM,WAAQ,CAAC,CAAC,CAAC;gBACrF,CAAC,CAAC,CAAC,IAAI,CACL,UAAA,GAAG;oBACD,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;oBAClB,YAAY,EAAE,CAAC;gBACjB,CAAC,EACD,MAAM,CACP,CAAC;YACJ,CAAC;YACD,KAAK,EAAL,UAAM,KAAY;gBAChB,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC;oBACjB,IAAM,OAAO,GAAG,cAAc,CAAC,UAAU,EAAE,CAAC,CAAC;oBAC7C,IAAI,OAAO;wBAAE,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC;oBACnC,MAAM,CAAC,KAAK,CAAC,CAAC;gBAChB,CAAC,CAAC,CAAC,IAAI,CACL,YAAY,EACZ,MAAM,CACP,CAAC;YACJ,CAAC;SACF,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO;QACL,OAAO,SAAA;QACP,YAAY,cAAA;KACb,CAAC;AACJ,CAAC;AAED,MAAM,CAAC,OAAO,WACZ,OAAgB;IAChB,aAAwB;SAAxB,UAAwB,EAAxB,qBAAwB,EAAxB,IAAwB;QAAxB,4BAAwB;;IAExB,OAAO,kCAAkC,8BAAC,OAAO,GAAK,GAAG,UAAE,OAAO,CAAC;AACrE,CAAC","sourcesContent":["import { ObservableQuery, ApolloQueryResult } from '../../core';\nimport { ObservableSubscription } from '../../utilities';\n\n/**\n *\n * @param observable the observable query to subscribe to\n * @param shouldResolve should we resolve after seeing all our callbacks [default: true]\n * (use this if you are racing the promise against another)\n * @param wait how long to wait after seeing desired callbacks before resolving\n * [default: -1 => don't wait]\n * @param errorCallbacks an expected set of errors\n */\nexport type Options = {\n observable: ObservableQuery<any>;\n shouldResolve?: boolean;\n wait?: number;\n errorCallbacks?: ((error: Error) => any)[];\n};\n\nexport type ResultCallback = ((result: ApolloQueryResult<any>) => any);\n\n// Take an observable and N callbacks, and observe the observable,\n// ensuring it is called exactly N times, resolving once it has done so.\n// Optionally takes a timeout, which it will wait X ms after the Nth callback\n// to ensure it is not called again.\nexport function observableToPromiseAndSubscription(\n { observable, shouldResolve = true, wait = -1, errorCallbacks = [] }: Options,\n ...cbs: ResultCallback[]\n): { promise: Promise<any[]>; subscription: ObservableSubscription } {\n let subscription: ObservableSubscription = null as never;\n const promise = new Promise<any[]>((resolve, reject) => {\n let errorIndex = 0;\n let cbIndex = 0;\n const results: any[] = [];\n\n const tryToResolve = () => {\n if (!shouldResolve) {\n return;\n }\n\n const done = () => {\n subscription.unsubscribe();\n // XXX: we could pass a few other things out here?\n resolve(results);\n };\n\n if (cbIndex === cbs.length && errorIndex === errorCallbacks.length) {\n if (wait === -1) {\n done();\n } else {\n setTimeout(done, wait);\n }\n }\n };\n\n let queue = Promise.resolve();\n\n subscription = observable.subscribe({\n next(result: ApolloQueryResult<any>) {\n queue = queue.then(() => {\n const cb = cbs[cbIndex++];\n if (cb) return cb(result);\n reject(new Error(`Observable 'next' method called more than ${cbs.length} times`));\n }).then(\n res => {\n results.push(res);\n tryToResolve();\n },\n reject,\n );\n },\n error(error: Error) {\n queue = queue.then(() => {\n const errorCb = errorCallbacks[errorIndex++];\n if (errorCb) return errorCb(error);\n reject(error);\n }).then(\n tryToResolve,\n reject,\n );\n },\n });\n });\n\n return {\n promise,\n subscription,\n };\n}\n\nexport default function(\n options: Options,\n ...cbs: ResultCallback[]\n): Promise<any[]> {\n return observableToPromiseAndSubscription(options, ...cbs).promise;\n}\n"]}
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "@apollo/client/testing/core",
3
+ "type": "module",
4
+ "main": "core.cjs",
5
+ "module": "index.js",
6
+ "types": "index.d.ts",
7
+ "sideEffects": false
8
+ }
@@ -0,0 +1,4 @@
1
+ import { ObservableQuery, ApolloQueryResult, OperationVariables } from '../../core';
2
+ import { ObservableSubscription } from '../../utilities';
3
+ export default function subscribeAndCount<TData, TVariables = OperationVariables>(reject: (reason: any) => any, observable: ObservableQuery<TData, TVariables>, cb: (handleCount: number, result: ApolloQueryResult<TData>) => any): ObservableSubscription;
4
+ //# sourceMappingURL=subscribeAndCount.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscribeAndCount.d.ts","sourceRoot":"","sources":["../../../src/testing/core/subscribeAndCount.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AACpF,OAAO,EAAE,sBAAsB,EAAY,MAAM,iBAAiB,CAAC;AAEnE,MAAM,CAAC,OAAO,UAAU,iBAAiB,CACvC,KAAK,EACL,UAAU,GAAG,kBAAkB,EAE/B,MAAM,EAAE,CAAC,MAAM,EAAE,GAAG,KAAK,GAAG,EAC5B,UAAU,EAAE,eAAe,CAAC,KAAK,EAAE,UAAU,CAAC,EAC9C,EAAE,EAAE,CAAC,WAAW,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,CAAC,KAAK,CAAC,KAAK,GAAG,GACjE,sBAAsB,CAsBxB"}
@@ -1,4 +1,4 @@
1
- import { asyncMap } from "../observables/asyncMap.js";
1
+ import { asyncMap } from "../../utilities/index.js";
2
2
  export default function subscribeAndCount(reject, observable, cb) {
3
3
  var queue = Promise.resolve();
4
4
  var handleCount = 0;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscribeAndCount.js","sourceRoot":"","sources":["../../../src/testing/core/subscribeAndCount.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEnE,MAAM,CAAC,OAAO,UAAU,iBAAiB,CAIvC,MAA4B,EAC5B,UAA8C,EAC9C,EAAkE;IAGlE,IAAI,KAAK,GAAG,OAAO,CAAC,OAAO,EAAE,CAAC;IAC9B,IAAI,WAAW,GAAG,CAAC,CAAC;IAEpB,IAAM,YAAY,GAAG,QAAQ,CAC3B,UAAU,EACV,UAAC,MAAgC;QAG/B,OAAO,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC;YACxB,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,MAAM,CAAC,CAAC;QACnC,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IAClB,CAAC,CACF,CAAC,SAAS,CAAC,EAAE,KAAK,OAAA,EAAE,CAAC,CAAC;IAEvB,SAAS,KAAK,CAAC,CAAM;QACnB,YAAY,CAAC,WAAW,EAAE,CAAC;QAC3B,MAAM,CAAC,CAAC,CAAC,CAAC;IACZ,CAAC;IAED,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import { ObservableQuery, ApolloQueryResult, OperationVariables } from '../../core';\nimport { ObservableSubscription, asyncMap } from '../../utilities';\n\nexport default function subscribeAndCount<\n TData,\n TVariables = OperationVariables,\n>(\n reject: (reason: any) => any,\n observable: ObservableQuery<TData, TVariables>,\n cb: (handleCount: number, result: ApolloQueryResult<TData>) => any,\n): ObservableSubscription {\n // Use a Promise queue to prevent callbacks from being run out of order.\n let queue = Promise.resolve();\n let handleCount = 0;\n\n const subscription = asyncMap(\n observable,\n (result: ApolloQueryResult<TData>) => {\n // All previous asynchronous callbacks must complete before cb can\n // be invoked with this result.\n return queue = queue.then(() => {\n return cb(++handleCount, result);\n }).catch(error);\n },\n ).subscribe({ error });\n\n function error(e: any) {\n subscription.unsubscribe();\n reject(e);\n }\n\n return subscription;\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"withConsoleSpy.d.ts","sourceRoot":"","sources":["../../../src/testing/core/withConsoleSpy.ts"],"names":[],"mappings":"AAiBA,wBAAgB,YAAY,CAC1B,KAAK,SAAS,GAAG,EAAE,EACnB,OAAO,EAEP,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,EAC/B,GAAG,IAAI,EAAE,KAAK,WAIf;AAED,wBAAgB,cAAc,CAC5B,KAAK,SAAS,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CAI5B,EAA+B;IAC/B,cAAc;SAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;QAAd,6BAAc;;IAEd,IAAI,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,CAAC;IAC5C,OAAO,EAAE,eAAI,IAAI,EAAE;AACrB,CAAC;AAED,MAAM,UAAU,UAAU,CAIxB,EAA+B;IAC/B,cAAc;SAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;QAAd,6BAAc;;IAEd,IAAI,CAAC,CAAC,CAAC,GAAG,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC;IAC3C,OAAO,EAAE,eAAI,IAAI,EAAE;AACrB,CAAC","sourcesContent":["function wrapTestFunction(\n fn: (...args: any[]) => any,\n consoleMethodName: \"log\" | \"warn\" | \"error\",\n) {\n return function () {\n const args = arguments;\n const spy = jest.spyOn(console, consoleMethodName);\n spy.mockImplementation(() => {});\n return new Promise(resolve => {\n resolve(fn?.apply(this, args));\n }).finally(() => {\n expect(spy).toMatchSnapshot();\n spy.mockReset();\n });\n };\n}\n\nexport function withErrorSpy<\n TArgs extends any[],\n TResult,\n>(\n it: (...args: TArgs) => TResult,\n ...args: TArgs\n) {\n args[1] = wrapTestFunction(args[1], \"error\");\n return it(...args);\n}\n\nexport function withWarningSpy<\n TArgs extends any[],\n TResult,\n>(\n it: (...args: TArgs) => TResult,\n ...args: TArgs\n) {\n args[1] = wrapTestFunction(args[1], \"warn\");\n return it(...args);\n}\n\nexport function withLogSpy<\n TArgs extends any[],\n TResult,\n>(\n it: (...args: TArgs) => TResult,\n ...args: TArgs\n) {\n args[1] = wrapTestFunction(args[1], \"log\");\n return it(...args);\n}\n"]}
File without changes
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrap.d.ts","sourceRoot":"","sources":["../../../src/testing/core/wrap.ts"],"names":[],"mappings":"wEAGmB,GAAG,KAAK,GAAG;AAD9B,wBASE;AAEF,wBAAgB,SAAS,CAAC,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,OAatD"}
File without changes
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrap.js","sourceRoot":"","sources":["../../../src/testing/core/wrap.ts"],"names":[],"mappings":"AAEA,gBAAe,UACb,MAA4B,EAC5B,EAA+B,IAC5B,OAAA;IAAC,cAAc;SAAd,UAAc,EAAd,qBAAc,EAAd,IAAc;QAAd,yBAAc;;IAClB,IAAI;QACF,OAAO,EAAE,eAAI,IAAI,EAAE;KACpB;IAAC,OAAO,CAAC,EAAE;QACV,MAAM,CAAC,CAAC,CAAC,CAAC;KACX;AACH,CAAC,EANI,CAMJ,EAAC;AAEF,MAAM,UAAU,SAAS,CAAC,IAAc,EAAE,KAAa;IACrD,IAAI,OAAO,GAAW,IAAa,CAAC;IACpC,IAAM,QAAQ,GAAG,OAAO,CAAC,KAAK,CAAC;IAE/B,OAAO,CAAC,KAAK,GAAG,UAAC,CAAS,IAAK,OAAA,CAAC,OAAO,GAAG,CAAC,CAAC,EAAb,CAAa,CAAC;IAE7C,IAAI;QACF,IAAM,MAAM,GAAG,IAAI,EAAE,CAAC;QACtB,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC/B,OAAO,MAAM,CAAC;KACf;YAAS;QACR,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC;KAC1B;AACH,CAAC","sourcesContent":["// I'm not sure why mocha doesn't provide something like this, you can't\n// always use promises\nexport default <TArgs extends any[], TResult>(\n reject: (reason: any) => any,\n cb: (...args: TArgs) => TResult,\n) => (...args: TArgs) => {\n try {\n return cb(...args);\n } catch (e) {\n reject(e);\n }\n};\n\nexport function withError(func: Function, regex: RegExp) {\n let message: string = null as never;\n const oldError = console.error;\n\n console.error = (m: string) => (message = m);\n\n try {\n const result = func();\n expect(message).toMatch(regex);\n return result;\n } finally {\n console.error = oldError;\n }\n}\n"]}
@@ -1,3 +1,4 @@
1
1
  import '../utilities/globals';
2
- export * from '../utilities/testing';
2
+ export { MockedProvider, MockedProviderProps } from './react/MockedProvider';
3
+ export * from './core';
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,cAAc,sBAAsB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7E,cAAc,QAAQ,CAAC"}
package/testing/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  import "../utilities/globals/index.js";
2
- export * from "../utilities/testing/index.js";
2
+ export { MockedProvider } from "./react/MockedProvider.js";
3
+ export * from "./core/index.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,cAAc,sBAAsB,CAAC","sourcesContent":["import '../utilities/globals';\nexport * from '../utilities/testing';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/testing/index.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAuB,MAAM,wBAAwB,CAAC;AAC7E,cAAc,QAAQ,CAAC","sourcesContent":["import '../utilities/globals';\nexport { MockedProvider, MockedProviderProps } from './react/MockedProvider';\nexport * from './core';\n"]}
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@apollo/client/testing",
3
- "main": "testing.cjs.js",
3
+ "type": "module",
4
+ "main": "testing.cjs",
4
5
  "module": "index.js",
5
6
  "types": "index.d.ts",
6
7
  "sideEffects": false
@@ -1,9 +1,9 @@
1
1
  import * as React from 'react';
2
- import { ApolloClient, DefaultOptions } from '../../../core';
3
- import { MockedResponse } from './mockLink';
4
- import { ApolloLink } from '../../../link/core';
5
- import { Resolvers } from '../../../core';
6
- import { ApolloCache } from '../../../cache';
2
+ import { ApolloClient, DefaultOptions } from '../../core';
3
+ import { MockedResponse } from '../core';
4
+ import { ApolloLink } from '../../link/core';
5
+ import { Resolvers } from '../../core';
6
+ import { ApolloCache } from '../../cache';
7
7
  export interface MockedProviderProps<TSerializedCache = {}> {
8
8
  mocks?: ReadonlyArray<MockedResponse>;
9
9
  addTypename?: boolean;
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MockedProvider.d.ts","sourceRoot":"","sources":["../../../src/testing/react/MockedProvider.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAG1D,OAAO,EAAY,cAAc,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAE1C,MAAM,WAAW,mBAAmB,CAAC,gBAAgB,GAAG,EAAE;IACxD,KAAK,CAAC,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;IACtC,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,cAAc,CAAC,EAAE,cAAc,CAAC;IAChC,KAAK,CAAC,EAAE,WAAW,CAAC,gBAAgB,CAAC,CAAC;IACtC,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,IAAI,CAAC,EAAE,UAAU,CAAC;CACnB;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,YAAY,CAAC,GAAG,CAAC,CAAC;CAC3B;AAED,qBAAa,cAAe,SAAQ,KAAK,CAAC,SAAS,CACjD,mBAAmB,EACnB,mBAAmB,CACpB;IACC,OAAc,YAAY,EAAE,mBAAmB,CAE7C;gBAEU,KAAK,EAAE,mBAAmB;IAwB/B,MAAM;IASN,oBAAoB;CAK5B"}
@@ -1,9 +1,9 @@
1
1
  import { __assign, __extends } from "tslib";
2
2
  import * as React from 'react';
3
- import { ApolloClient } from "../../../core/index.js";
4
- import { InMemoryCache as Cache } from "../../../cache/index.js";
5
- import { ApolloProvider } from "../../../react/context/index.js";
6
- import { MockLink } from "./mockLink.js";
3
+ import { ApolloClient } from "../../core/index.js";
4
+ import { InMemoryCache as Cache } from "../../cache/index.js";
5
+ import { ApolloProvider } from "../../react/context/index.js";
6
+ import { MockLink } from "../core/index.js";
7
7
  var MockedProvider = (function (_super) {
8
8
  __extends(MockedProvider, _super);
9
9
  function MockedProvider(props) {
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MockedProvider.js","sourceRoot":"","sources":["../../../src/testing/react/MockedProvider.tsx"],"names":[],"mappings":";AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,OAAO,EAAE,YAAY,EAAkB,MAAM,YAAY,CAAC;AAC1D,OAAO,EAAE,aAAa,IAAI,KAAK,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAkB,MAAM,SAAS,CAAC;AAoBnD;IAAoC,kCAGnC;IAKC,wBAAY,KAA0B;QAAtC,YACE,kBAAM,KAAK,CAAC,SAqBb;QAnBO,IAAA,KAOF,KAAI,CAAC,KAAK,EANZ,KAAK,WAAA,EACL,WAAW,iBAAA,EACX,cAAc,oBAAA,EACd,KAAK,WAAA,EACL,SAAS,eAAA,EACT,IAAI,UACQ,CAAC;QACf,IAAM,MAAM,GAAG,IAAI,YAAY,CAAC;YAC9B,KAAK,EAAE,KAAK,IAAI,IAAI,KAAK,CAAC,EAAE,WAAW,aAAA,EAAE,CAAC;YAC1C,cAAc,gBAAA;YACd,IAAI,EAAE,IAAI,IAAI,IAAI,QAAQ,CACxB,KAAK,IAAI,EAAE,EACX,WAAW,CACZ;YACD,SAAS,WAAA;SACV,CAAC,CAAC;QAEH,KAAI,CAAC,KAAK,GAAG,EAAE,MAAM,QAAA,EAAE,CAAC;;IAC1B,CAAC;IAEM,+BAAM,GAAb;QACQ,IAAA,KAA2B,IAAI,CAAC,KAAK,EAAnC,QAAQ,cAAA,EAAE,UAAU,gBAAe,CAAC;QAC5C,OAAO,KAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CACtC,oBAAC,cAAc,IAAC,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,IACtC,KAAK,CAAC,YAAY,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,eAAO,UAAU,EAAG,CACtD,CAClB,CAAC,CAAC,CAAC,IAAI,CAAC;IACX,CAAC;IAEM,6CAAoB,GAA3B;QAGE,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;IAC3B,CAAC;IAzCa,2BAAY,GAAwB;QAChD,WAAW,EAAE,IAAI;KAClB,CAAC;IAwCJ,qBAAC;CAAA,AA9CD,CAAoC,KAAK,CAAC,SAAS,GA8ClD;SA9CY,cAAc","sourcesContent":["import * as React from 'react';\n\nimport { ApolloClient, DefaultOptions } from '../../core';\nimport { InMemoryCache as Cache } from '../../cache';\nimport { ApolloProvider } from '../../react/context';\nimport { MockLink, MockedResponse } from '../core';\nimport { ApolloLink } from '../../link/core';\nimport { Resolvers } from '../../core';\nimport { ApolloCache } from '../../cache';\n\nexport interface MockedProviderProps<TSerializedCache = {}> {\n mocks?: ReadonlyArray<MockedResponse>;\n addTypename?: boolean;\n defaultOptions?: DefaultOptions;\n cache?: ApolloCache<TSerializedCache>;\n resolvers?: Resolvers;\n childProps?: object;\n children?: any;\n link?: ApolloLink;\n}\n\nexport interface MockedProviderState {\n client: ApolloClient<any>;\n}\n\nexport class MockedProvider extends React.Component<\n MockedProviderProps,\n MockedProviderState\n> {\n public static defaultProps: MockedProviderProps = {\n addTypename: true\n };\n\n constructor(props: MockedProviderProps) {\n super(props);\n\n const {\n mocks,\n addTypename,\n defaultOptions,\n cache,\n resolvers,\n link\n } = this.props;\n const client = new ApolloClient({\n cache: cache || new Cache({ addTypename }),\n defaultOptions,\n link: link || new MockLink(\n mocks || [],\n addTypename,\n ),\n resolvers,\n });\n\n this.state = { client };\n }\n\n public render() {\n const { children, childProps } = this.props;\n return React.isValidElement(children) ? (\n <ApolloProvider client={this.state.client}>\n {React.cloneElement(React.Children.only(children), { ...childProps })}\n </ApolloProvider>\n ) : null;\n }\n\n public componentWillUnmount() {\n // Since this.state.client was created in the constructor, it's this\n // MockedProvider's responsibility to terminate it.\n this.state.client.stop();\n }\n}\n"]}
@@ -0,0 +1,58 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ require('../utilities/globals');
6
+ var tslib = require('tslib');
7
+ var React = require('react');
8
+ var core$1 = require('../core');
9
+ var cache = require('../cache');
10
+ var context = require('../react/context');
11
+ var core = require('./core');
12
+
13
+ function _interopNamespace(e) {
14
+ if (e && e.__esModule) return e;
15
+ var n = Object.create(null);
16
+ if (e) {
17
+ for (var k in e) {
18
+ n[k] = e[k];
19
+ }
20
+ }
21
+ n["default"] = e;
22
+ return Object.freeze(n);
23
+ }
24
+
25
+ var React__namespace = /*#__PURE__*/_interopNamespace(React);
26
+
27
+ var MockedProvider = (function (_super) {
28
+ tslib.__extends(MockedProvider, _super);
29
+ function MockedProvider(props) {
30
+ var _this = _super.call(this, props) || this;
31
+ var _a = _this.props, mocks = _a.mocks, addTypename = _a.addTypename, defaultOptions = _a.defaultOptions, cache$1 = _a.cache, resolvers = _a.resolvers, link = _a.link;
32
+ var client = new core$1.ApolloClient({
33
+ cache: cache$1 || new cache.InMemoryCache({ addTypename: addTypename }),
34
+ defaultOptions: defaultOptions,
35
+ link: link || new core.MockLink(mocks || [], addTypename),
36
+ resolvers: resolvers,
37
+ });
38
+ _this.state = { client: client };
39
+ return _this;
40
+ }
41
+ MockedProvider.prototype.render = function () {
42
+ var _a = this.props, children = _a.children, childProps = _a.childProps;
43
+ return React__namespace.isValidElement(children) ? (React__namespace.createElement(context.ApolloProvider, { client: this.state.client }, React__namespace.cloneElement(React__namespace.Children.only(children), tslib.__assign({}, childProps)))) : null;
44
+ };
45
+ MockedProvider.prototype.componentWillUnmount = function () {
46
+ this.state.client.stop();
47
+ };
48
+ MockedProvider.defaultProps = {
49
+ addTypename: true
50
+ };
51
+ return MockedProvider;
52
+ }(React__namespace.Component));
53
+
54
+ exports.MockedProvider = MockedProvider;
55
+ for (var k in core) {
56
+ if (k !== 'default' && !exports.hasOwnProperty(k)) exports[k] = core[k];
57
+ }
58
+ //# sourceMappingURL=testing.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"testing.cjs","sources":["react/MockedProvider.js"],"sourcesContent":["import { __assign, __extends } from \"tslib\";\nimport * as React from 'react';\nimport { ApolloClient } from '../../core';\nimport { InMemoryCache as Cache } from '../../cache';\nimport { ApolloProvider } from '../../react/context';\nimport { MockLink } from '../core';\nvar MockedProvider = (function (_super) {\n __extends(MockedProvider, _super);\n function MockedProvider(props) {\n var _this = _super.call(this, props) || this;\n var _a = _this.props, mocks = _a.mocks, addTypename = _a.addTypename, defaultOptions = _a.defaultOptions, cache = _a.cache, resolvers = _a.resolvers, link = _a.link;\n var client = new ApolloClient({\n cache: cache || new Cache({ addTypename: addTypename }),\n defaultOptions: defaultOptions,\n link: link || new MockLink(mocks || [], addTypename),\n resolvers: resolvers,\n });\n _this.state = { client: client };\n return _this;\n }\n MockedProvider.prototype.render = function () {\n var _a = this.props, children = _a.children, childProps = _a.childProps;\n return React.isValidElement(children) ? (React.createElement(ApolloProvider, { client: this.state.client }, React.cloneElement(React.Children.only(children), __assign({}, childProps)))) : null;\n };\n MockedProvider.prototype.componentWillUnmount = function () {\n this.state.client.stop();\n };\n MockedProvider.defaultProps = {\n addTypename: true\n };\n return MockedProvider;\n}(React.Component));\nexport { MockedProvider };\n//# sourceMappingURL=MockedProvider.js.map"],"names":["__extends","cache","ApolloClient","Cache","MockLink","React","ApolloProvider","__assign"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAMG,IAAC,cAAc,IAAI,UAAU,MAAM,EAAE;AACxC,IAAIA,eAAS,CAAC,cAAc,EAAE,MAAM,CAAC,CAAC;AACtC,IAAI,SAAS,cAAc,CAAC,KAAK,EAAE;AACnC,QAAQ,IAAI,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC;AACrD,QAAQ,IAAI,EAAE,GAAG,KAAK,CAAC,KAAK,EAAE,KAAK,GAAG,EAAE,CAAC,KAAK,EAAE,WAAW,GAAG,EAAE,CAAC,WAAW,EAAE,cAAc,GAAG,EAAE,CAAC,cAAc,EAAEC,OAAK,GAAG,EAAE,CAAC,KAAK,EAAE,SAAS,GAAG,EAAE,CAAC,SAAS,EAAE,IAAI,GAAG,EAAE,CAAC,IAAI,CAAC;AAC7K,QAAQ,IAAI,MAAM,GAAG,IAAIC,mBAAY,CAAC;AACtC,YAAY,KAAK,EAAED,OAAK,IAAI,IAAIE,mBAAK,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,CAAC;AACnE,YAAY,cAAc,EAAE,cAAc;AAC1C,YAAY,IAAI,EAAE,IAAI,IAAI,IAAIC,aAAQ,CAAC,KAAK,IAAI,EAAE,EAAE,WAAW,CAAC;AAChE,YAAY,SAAS,EAAE,SAAS;AAChC,SAAS,CAAC,CAAC;AACX,QAAQ,KAAK,CAAC,KAAK,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC;AACzC,QAAQ,OAAO,KAAK,CAAC;AACrB,KAAK;AACL,IAAI,cAAc,CAAC,SAAS,CAAC,MAAM,GAAG,YAAY;AAClD,QAAQ,IAAI,EAAE,GAAG,IAAI,CAAC,KAAK,EAAE,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,UAAU,GAAG,EAAE,CAAC,UAAU,CAAC;AAChF,QAAQ,OAAOC,gBAAK,CAAC,cAAc,CAAC,QAAQ,CAAC,IAAIA,gBAAK,CAAC,aAAa,CAACC,sBAAc,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,EAAED,gBAAK,CAAC,YAAY,CAACA,gBAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAEE,cAAQ,CAAC,EAAE,EAAE,UAAU,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC;AACzM,KAAK,CAAC;AACN,IAAI,cAAc,CAAC,SAAS,CAAC,oBAAoB,GAAG,YAAY;AAChE,QAAQ,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;AACjC,KAAK,CAAC;AACN,IAAI,cAAc,CAAC,YAAY,GAAG;AAClC,QAAQ,WAAW,EAAE,IAAI;AACzB,KAAK,CAAC;AACN,IAAI,OAAO,cAAc,CAAC;AAC1B,CAAC,CAACF,gBAAK,CAAC,SAAS,CAAC;;;;;;;"}
@@ -1,3 +1,3 @@
1
1
  import { ExecutionResult } from 'graphql';
2
- export declare function graphQLResultHasError(result: ExecutionResult): boolean;
2
+ export declare function graphQLResultHasError(result: ExecutionResult<unknown>): boolean;
3
3
  //# sourceMappingURL=errorHandling.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errorHandling.d.ts","sourceRoot":"","sources":["../../../src/utilities/common/errorHandling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,GAAG,OAAO,CAEtE"}
1
+ {"version":3,"file":"errorHandling.d.ts","sourceRoot":"","sources":["../../../src/utilities/common/errorHandling.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE1C,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,eAAe,CAAC,OAAO,CAAC,GAAG,OAAO,CAE/E"}
@@ -1 +1 @@
1
- {"version":3,"file":"errorHandling.js","sourceRoot":"","sources":["../../../src/utilities/common/errorHandling.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,qBAAqB,CAAC,MAAuB;IAC3D,OAAO,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC;AAC9D,CAAC","sourcesContent":["import { ExecutionResult } from 'graphql';\n\nexport function graphQLResultHasError(result: ExecutionResult): boolean {\n return (result.errors && result.errors.length > 0) || false;\n}\n"]}
1
+ {"version":3,"file":"errorHandling.js","sourceRoot":"","sources":["../../../src/utilities/common/errorHandling.ts"],"names":[],"mappings":"AAEA,MAAM,UAAU,qBAAqB,CAAC,MAAgC;IACpE,OAAO,CAAC,MAAM,CAAC,MAAM,IAAI,MAAM,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,IAAI,KAAK,CAAC;AAC9D,CAAC","sourcesContent":["import { ExecutionResult } from 'graphql';\n\nexport function graphQLResultHasError(result: ExecutionResult<unknown>): boolean {\n return (result.errors && result.errors.length > 0) || false;\n}\n"]}
@@ -2,6 +2,6 @@ var prefixCounts = new Map();
2
2
  export function makeUniqueId(prefix) {
3
3
  var count = prefixCounts.get(prefix) || 1;
4
4
  prefixCounts.set(prefix, count + 1);
5
- return prefix + ":" + count + ":" + Math.random().toString(36).slice(2);
5
+ return "".concat(prefix, ":").concat(count, ":").concat(Math.random().toString(36).slice(2));
6
6
  }
7
7
  //# sourceMappingURL=makeUniqueId.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"makeUniqueId.js","sourceRoot":"","sources":["../../../src/utilities/common/makeUniqueId.ts"],"names":[],"mappings":"AAAA,IAAM,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;AAI/C,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,IAAM,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC5C,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;IACpC,OAAU,MAAM,SAAI,KAAK,SAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAG,CAAC;AACrE,CAAC","sourcesContent":["const prefixCounts = new Map<string, number>();\n\n// These IDs won't be globally unique, but they will be unique within this\n// process, thanks to the counter, and unguessable thanks to the random suffix.\nexport function makeUniqueId(prefix: string) {\n const count = prefixCounts.get(prefix) || 1;\n prefixCounts.set(prefix, count + 1);\n return `${prefix}:${count}:${Math.random().toString(36).slice(2)}`;\n}\n"]}
1
+ {"version":3,"file":"makeUniqueId.js","sourceRoot":"","sources":["../../../src/utilities/common/makeUniqueId.ts"],"names":[],"mappings":"AAAA,IAAM,YAAY,GAAG,IAAI,GAAG,EAAkB,CAAC;AAI/C,MAAM,UAAU,YAAY,CAAC,MAAc;IACzC,IAAM,KAAK,GAAG,YAAY,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;IAC5C,YAAY,CAAC,GAAG,CAAC,MAAM,EAAE,KAAK,GAAG,CAAC,CAAC,CAAC;IACpC,OAAO,UAAG,MAAM,cAAI,KAAK,cAAI,IAAI,CAAC,MAAM,EAAE,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAE,CAAC;AACrE,CAAC","sourcesContent":["const prefixCounts = new Map<string, number>();\n\n// These IDs won't be globally unique, but they will be unique within this\n// process, thanks to the counter, and unguessable thanks to the random suffix.\nexport function makeUniqueId(prefix: string) {\n const count = prefixCounts.get(prefix) || 1;\n prefixCounts.set(prefix, count + 1);\n return `${prefix}:${count}:${Math.random().toString(36).slice(2)}`;\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"mergeDeep.d.ts","sourceRoot":"","sources":["../../../src/utilities/common/mergeDeep.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAkB5C,oBAAY,mBAAmB,CAAC,CAAC,SAAS,GAAG,EAAE,IAC7C,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GACvB,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GACpC,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GACjD,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAC9D,CAAC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAC3E,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC;AAElC,wBAAgB,SAAS,CAAC,CAAC,SAAS,GAAG,EAAE,EACvC,GAAG,OAAO,EAAE,CAAC,GACZ,mBAAmB,CAAC,CAAC,CAAC,CAExB;AAQD,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,CAAC,CAUjD;AAED,oBAAY,kBAAkB,CAAC,YAAY,SAAS,GAAG,EAAE,IAAI,CAC3D,IAAI,EAAE,UAAU,CAAC,Y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MAAM,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAC3E,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,GAAG,GAAG,CAAC;AAElC,wBAAgB,SAAS,CAAC,CAAC,SAAS,GAAG,EAAE,EACvC,GAAG,OAAO,EAAE,CAAC,GACZ,mBAAmB,CAAC,CAAC,CAAC,CAExB;AAQD,wBAAgB,cAAc,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,GAAG,CAAC,CAUjD;AAED,oBAAY,kBAAkB,CAAC,YAAY,SAAS,GAAG,EAAE,IAAI,CAC3D,IAAI,EAAE,UAAU,CAAC,YAAY,CAAC,EAC9B,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EACpC,MAAM,EAAE,MAAM,CAAC,MAAM,GAAG,MAAM,EAAE,GAAG,CAAC,EACpC,QAAQ,EAAE,MAAM,GAAG,MAAM,EACzB,GAAG,OAAO,EAAE,YAAY,KACrB,GAAG,CAAC;AAOT,qBAAa,UAAU,CAAC,YAAY,SAAS,GAAG,EAAE;IAE9C,OAAO,CAAC,UAAU;gBAAV,UAAU,GAAE,kBAAkB,CAAC,YAAY,CAAqB;IAGnE,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,OAAO,EAAE,YAAY,GAAG,GAAG;IA6B9D,QAAQ,yBAAmB;IAElC,OAAO,CAAC,UAAU,CAAkB;IAE7B,mBAAmB,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,CAAC;CAoB3C"}
@@ -57,7 +57,12 @@ var DeepMerger = (function () {
57
57
  return source;
58
58
  };
59
59
  DeepMerger.prototype.shallowCopyForMerge = function (value) {
60
- if (isNonNullObject(value) && !this.pastCopies.has(value)) {
60
+ if (isNonNullObject(value)) {
61
+ if (this.pastCopies.has(value)) {
62
+ if (!Object.isFrozen(value))
63
+ return value;
64
+ this.pastCopies.delete(value);
65
+ }
61
66
  if (Array.isArray(value)) {
62
67
  value = value.slice(0);
63
68
  }
@@ -1 +1 @@
1
- {"version":3,"file":"mergeDeep.js","sourceRoot":"","sources":["../../../src/utilities/common/mergeDeep.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEpC,IAAA,cAAc,GAAK,MAAM,CAAC,SAAS,eAArB,CAAsB;AAwB5C,MAAM,UAAU,SAAS;IACvB,iBAAa;SAAb,UAAa,EAAb,qBAAa,EAAb,IAAa;QAAb,4BAAa;;IAEb,OAAO,cAAc,CAAC,OAAO,CAAC,CAAC;AACjC,CAAC;AAQD,MAAM,UAAU,cAAc,CAAI,OAAY;IAC5C,IAAI,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,IAAK,EAAQ,CAAC;IACrC,IAAM,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC;IAC7B,IAAI,KAAK,GAAG,CAAC,EAAE;QACb,IAAM,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,EAAE,CAAC,EAAE;YAC9B,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC;SAC3C;KACF;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAUD,IAAM,iBAAiB,GACrB,UAAU,MAAM,EAAE,MAAM,EAAE,QAAQ;IAChC,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;AACxD,CAAC,CAAC;AAEJ;IACE,oBACU,UAAgE;QAAhE,2BAAA,EAAA,8BAAgE;QAAhE,eAAU,GAAV,UAAU,CAAsD;QAgCnE,aAAQ,GAAG,eAA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K,CAAC,EAAE;gBACxB,KAAK,GAAI,KAAa,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;aACjC;iBAAM;gBACL,KAAK,cACH,SAAS,EAAE,MAAM,CAAC,cAAc,CAAC,KAAK,CAAC,IACpC,KAAK,CACT,CAAC;aACH;YACD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;SAC5B;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACH,iBAAC;AAAD,CAAC,AApDD,IAoDC","sourcesContent":["import { isNonNullObject } from \"./objects\";\n\nconst { hasOwnProperty } = Object.prototype;\n\n// These mergeDeep and mergeDeepArray utilities merge any number of objects\n// together, sharing as much memory as possible with the source objects, while\n// remaining careful to avoid modifying any source objects.\n\n// Logically, the return type of mergeDeep should be the intersection of\n// all the argument types. The binary call signature is by far the most\n// common, but we support 0- through 5-ary as well. After that, the\n// resulting type is just the inferred array element type. Note to nerds:\n// there is a more clever way of doing this that converts the tuple type\n// first to a union type (easy enough: T[number]) and then converts the\n// union to an intersection type using distributive conditional type\n// inference, but that approach has several fatal flaws (boolean becomes\n// true & false, and the inferred type ends up as unknown in many cases),\n// in addition to being nearly impossible to explain/understand.\nexport type TupleToIntersection<T extends any[]> =\n T extends [infer A] ? A :\n T extends [infer A, infer B] ? A & B :\n T extends [infer A, infer B, infer C] ? A & B & C :\n T extends [infer A, infer B, infer C, infer D] ? A & B & C & D :\n T extends [infer A, infer B, infer C, infer D, infer E] ? A & B & C & D & E :\n T extends (infer U)[] ? U : any;\n\nexport function mergeDeep<T extends any[]>(\n ...sources: T\n): TupleToIntersection<T> {\n return mergeDeepArray(sources);\n}\n\n// In almost any situation where you could succeed in getting the\n// TypeScript compiler to infer a tuple type for the sources array, you\n// could just use mergeDeep instead of mergeDeepArray, so instead of\n// trying to convert T[] to an intersection type we just infer the array\n// element type, which works perfectly when the sources array has a\n// consistent element type.\nexport function mergeDeepArray<T>(sources: T[]): T {\n let target = sources[0] || ({} as T);\n const count = sources.length;\n if (count > 1) {\n const merger = new DeepMerger();\n for (let i = 1; i < count; ++i) {\n target = merger.merge(target, sources[i]);\n }\n }\n return target;\n}\n\nexport type ReconcilerFunction<TContextArgs extends any[]> = (\n this: DeepMerger<TContextArgs>,\n target: Record<string | number, any>,\n source: Record<string | number, any>,\n property: string | number,\n ...context: TContextArgs\n) => any;\n\nconst defaultReconciler: ReconcilerFunction<any[]> =\n function (target, source, property) {\n return this.merge(target[property], source[property]);\n };\n\nexport class DeepMerger<TContextArgs extends any[]> {\n constructor(\n private reconciler: ReconcilerFunction<TContextArgs> = defaultReconciler,\n ) {}\n\n public merge(target: any, source: any, ...context: TContextArgs): any {\n if (isNonNullObject(source) && isNonNullObject(target)) {\n Object.keys(source).forEach(sourceKey => {\n if (hasOwnProperty.call(target, sourceKey)) {\n const targetValue = target[sourceKey];\n if (source[sourceKey] !== targetValue) {\n const result = this.reconciler(target, source, sourceKey, ...context);\n // A well-implemented reconciler may return targetValue to indicate\n // the merge changed nothing about the structure of the target.\n if (result !== targetValue) {\n target = this.shallowCopyForMerge(target);\n target[sourceKey] = result;\n }\n }\n } else {\n // If there is no collision, the target can safely share memory with\n // the source, and the recursion can terminate here.\n target = this.shallowCopyForMerge(target);\n target[sourceKey] = source[sourceKey];\n }\n });\n\n return target;\n }\n\n // If source (or target) is not an object, let source replace target.\n return source;\n }\n\n public isObject = isNonNullObject;\n\n private pastCopies = new Set<any>();\n\n public shallowCopyForMerge<T>(value: T): T {\n if (isNonNullObject(value) && !this.pastCopies.has(value)) {\n if (Array.isArray(value)) {\n value = (value as any).slice(0);\n } else {\n value = {\n __proto__: Object.getPrototypeOf(value),\n ...value,\n };\n }\n this.pastCopies.add(value);\n }\n return value;\n }\n}\n"]}
1
+ {"version":3,"file":"mergeDeep.js","sourceRoot":"","sources":["../../../src/utilities/common/mergeDeep.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAEpC,IAAA,cAAc,GAAK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AAC,KAAK,CAAC,IACpC,KAAK,CACT,CAAC;aACH;YACD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;SAC5B;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IACH,iBAAC;AAAD,CAAC,AA1DD,IA0DC","sourcesContent":["import { isNonNullObject } from \"./objects\";\n\nconst { hasOwnProperty } = Object.prototype;\n\n// These mergeDeep and mergeDeepArray utilities merge any number of objects\n// together, sharing as much memory as possible with the source objects, while\n// remaining careful to avoid modifying any source objects.\n\n// Logically, the return type of mergeDeep should be the intersection of\n// all the argument types. The binary call signature is by far the most\n// common, but we support 0- through 5-ary as well. After that, the\n// resulting type is just the inferred array element type. Note to nerds:\n// there is a more clever way of doing this that converts the tuple type\n// first to a union type (easy enough: T[number]) and then converts the\n// union to an intersection type using distributive conditional type\n// inference, but that approach has several fatal flaws (boolean becomes\n// true & false, and the inferred type ends up as unknown in many cases),\n// in addition to being nearly impossible to explain/understand.\nexport type TupleToIntersection<T extends any[]> =\n T extends [infer A] ? A :\n T extends [infer A, infer B] ? A & B :\n T extends [infer A, infer B, infer C] ? A & B & C :\n T extends [infer A, infer B, infer C, infer D] ? A & B & C & D :\n T extends [infer A, infer B, infer C, infer D, infer E] ? A & B & C & D & E :\n T extends (infer U)[] ? U : any;\n\nexport function mergeDeep<T extends any[]>(\n ...sources: T\n): TupleToIntersection<T> {\n return mergeDeepArray(sources);\n}\n\n// In almost any situation where you could succeed in getting the\n// TypeScript compiler to infer a tuple type for the sources array, you\n// could just use mergeDeep instead of mergeDeepArray, so instead of\n// trying to convert T[] to an intersection type we just infer the array\n// element type, which works perfectly when the sources array has a\n// consistent element type.\nexport function mergeDeepArray<T>(sources: T[]): T {\n let target = sources[0] || ({} as T);\n const count = sources.length;\n if (count > 1) {\n const merger = new DeepMerger();\n for (let i = 1; i < count; ++i) {\n target = merger.merge(target, sources[i]);\n }\n }\n return target;\n}\n\nexport type ReconcilerFunction<TContextArgs extends any[]> = (\n this: DeepMerger<TContextArgs>,\n target: Record<string | number, any>,\n source: Record<string | number, any>,\n property: string | number,\n ...context: TContextArgs\n) => any;\n\nconst defaultReconciler: ReconcilerFunction<any[]> =\n function (target, source, property) {\n return this.merge(target[property], source[property]);\n };\n\nexport class DeepMerger<TContextArgs extends any[]> {\n constructor(\n private reconciler: ReconcilerFunction<TContextArgs> = defaultReconciler,\n ) {}\n\n public merge(target: any, source: any, ...context: TContextArgs): any {\n if (isNonNullObject(source) && isNonNullObject(target)) {\n Object.keys(source).forEach(sourceKey => {\n if (hasOwnProperty.call(target, sourceKey)) {\n const targetValue = target[sourceKey];\n if (source[sourceKey] !== targetValue) {\n const result = this.reconciler(target, source, sourceKey, ...context);\n // A well-implemented reconciler may return targetValue to indicate\n // the merge changed nothing about the structure of the target.\n if (result !== targetValue) {\n target = this.shallowCopyForMerge(target);\n target[sourceKey] = result;\n }\n }\n } else {\n // If there is no collision, the target can safely share memory with\n // the source, and the recursion can terminate here.\n target = this.shallowCopyForMerge(target);\n target[sourceKey] = source[sourceKey];\n }\n });\n\n return target;\n }\n\n // If source (or target) is not an object, let source replace target.\n return source;\n }\n\n public isObject = isNonNullObject;\n\n private pastCopies = new Set<any>();\n\n public shallowCopyForMerge<T>(value: T): T {\n if (isNonNullObject(value)) {\n if (this.pastCopies.has(value)) {\n // In order to reuse a past copy, it must be mutable, but copied objects\n // can sometimes be frozen while this DeepMerger is still active.\n if (!Object.isFrozen(value)) return value;\n this.pastCopies.delete(value);\n }\n if (Array.isArray(value)) {\n value = (value as any).slice(0);\n } else {\n value = {\n __proto__: Object.getPrototypeOf(value),\n ...value,\n };\n }\n this.pastCopies.add(value);\n }\n return value;\n }\n}\n"]}
@@ -1,4 +1,4 @@
1
- import { remove } from 'ts-invariant/process';
1
+ import { remove } from "ts-invariant/process/index.js";
2
2
  import { Source } from 'graphql';
3
3
  export function removeTemporaryGlobals() {
4
4
  return typeof Source === "function" ? remove() : remove();
@@ -1 +1 @@
1
- {"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../../src/utilities/globals/global.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,CAAC;IACb,MAAM,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;CACpC;;aASU,cAAc;;AAPzB,wBAQE"}
1
+ {"version":3,"file":"global.d.ts","sourceRoot":"","sources":["../../../src/utilities/globals/global.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,CAAC;IACb,MAAM,OAAO,EAAE,OAAO,GAAG,SAAS,CAAC;CACpC;;aAeU,cAAc;;AAbzB,wBAcE"}
@@ -3,5 +3,5 @@ export default (maybe(function () { return globalThis; }) ||
3
3
  maybe(function () { return window; }) ||
4
4
  maybe(function () { return self; }) ||
5
5
  maybe(function () { return global; }) ||
6
- maybe(function () { return Function("return this")(); }));
6
+ maybe(function () { return maybe.constructor("return this")(); }));
7
7
  //# sourceMappingURL=global.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"global.js","sourceRoot":"","sources":["../../../src/utilities/globals/global.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAMhC,eAAe,CACb,KAAK,CAAC,cAAM,OAAA,UAAU,EAAV,CAAU,CAAC;IACvB,KAAK,CAAC,cAAM,OAAA,MAAM,EAAN,CAAM,CAAC;IACnB,KAAK,CAAC,cAAM,OAAA,IAAI,EAAJ,CAAI,CAAC;IACjB,KAAK,CAAC,cAAM,OAAA,MAAM,EAAN,CAAM,CAAC;IACnB,KAAK,CAAC,cAAM,OAAA,QAAQ,CAAC,aAAa,CAAC,EAAE,EAAzB,CAAyB,CAAC,CAGvC,CAAC","sourcesContent":["import { maybe } from \"./maybe\";\n\ndeclare global {\n const __DEV__: boolean | undefined;\n}\n\nexport default (\n maybe(() => globalThis) ||\n maybe(() => window) ||\n maybe(() => self) ||\n maybe(() => global) ||\n maybe(() => Function(\"return this\")())\n) as typeof globalThis & {\n __DEV__: typeof __DEV__;\n};\n"]}
1
+ {"version":3,"file":"global.js","sourceRoot":"","sources":["../../../src/utilities/globals/global.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAMhC,eAAe,CACb,KAAK,CAAC,cAAM,OAAA,UAAU,EAAV,CAAU,CAAC;IACvB,KAAK,CAAC,cAAM,OAAA,MAAM,EAAN,CAAM,CAAC;IACnB,KAAK,CAAC,cAAM,OAAA,IAAI,EAAJ,CAAI,CAAC;IACjB,KAAK,CAAC,cAAM,OAAA,MAAM,EAAN,CAAM,CAAC;IAOnB,KAAK,CAAC,cAAa,OAAO,KAAK,CAAC,WAAW,CAAC,aAAa,CAAC,EAAE,CAAA,CAAC,CAAC,CAAC,CAGhE,CAAC","sourcesContent":["import { maybe } from \"./maybe\";\n\ndeclare global {\n const __DEV__: boolean | undefined;\n}\n\nexport default (\n maybe(() => globalThis) ||\n maybe(() => window) ||\n maybe(() => self) ||\n maybe(() => global) ||\n // We don't expect the Function constructor ever to be invoked at runtime, as\n // long as at least one of globalThis, window, self, or global is defined, so\n // we are under no obligation to make it easy for static analysis tools to\n // detect syntactic usage of the Function constructor. If you think you can\n // improve your static analysis to detect this obfuscation, think again. This\n // is an arms race you cannot win, at least not in JavaScript.\n maybe(function() { return maybe.constructor(\"return this\")() })\n) as typeof globalThis & {\n __DEV__: typeof __DEV__;\n};\n"]}
@@ -17,7 +17,7 @@ var global$1 = (maybe(function () { return globalThis; }) ||
17
17
  maybe(function () { return window; }) ||
18
18
  maybe(function () { return self; }) ||
19
19
  maybe(function () { return global; }) ||
20
- maybe(function () { return Function("return this")(); }));
20
+ maybe(function () { return maybe.constructor("return this")(); }));
21
21
 
22
22
  var __ = "__";
23
23
  var GLOBAL_KEY = [__, __].join("DEV");
@@ -42,7 +42,7 @@ function removeTemporaryGlobals() {
42
42
  }
43
43
 
44
44
  function checkDEV() {
45
- __DEV__ ? tsInvariant.invariant("boolean" === typeof DEV, DEV) : tsInvariant.invariant("boolean" === typeof DEV, 38);
45
+ __DEV__ ? tsInvariant.invariant("boolean" === typeof DEV, DEV) : tsInvariant.invariant("boolean" === typeof DEV, 36);
46
46
  }
47
47
  removeTemporaryGlobals();
48
48
  checkDEV();
@@ -53,4 +53,4 @@ exports.DEV = DEV;
53
53
  exports.checkDEV = checkDEV;
54
54
  exports.global = global$1;
55
55
  exports.maybe = maybe;
56
- //# sourceMappingURL=globals.cjs.js.map
56
+ //# sourceMappingURL=globals.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"globals.cjs","sources":["maybe.js","global.js","DEV.js","fix-graphql.js","index.js"],"sourcesContent":["export function maybe(thunk) {\n try {\n return thunk();\n }\n catch (_a) { }\n}\n//# sourceMappingURL=maybe.js.map","import { maybe } from \"./maybe\";\nexport default (maybe(function () { return globalThis; }) ||\n maybe(function () { return window; }) ||\n maybe(function () { return self; }) ||\n maybe(function () { return global; }) ||\n maybe(function () { return maybe.constructor(\"return this\")(); }));\n//# sourceMappingURL=global.js.map","import global from \"./global\";\nimport { maybe } from \"./maybe\";\nvar __ = \"__\";\nvar GLOBAL_KEY = [__, __].join(\"DEV\");\nfunction getDEV() {\n try {\n return Boolean(__DEV__);\n }\n catch (_a) {\n Object.defineProperty(global, GLOBAL_KEY, {\n value: maybe(function () { return process.env.NODE_ENV; }) !== \"production\",\n enumerable: false,\n configurable: true,\n writable: true,\n });\n return global[GLOBAL_KEY];\n }\n}\nexport default getDEV();\n//# sourceMappingURL=DEV.js.map","import { remove } from 'ts-invariant/process';\nimport { Source } from 'graphql';\nexport function removeTemporaryGlobals() {\n return typeof Source === \"function\" ? remove() : remove();\n}\n//# sourceMappingURL=fix-graphql.js.map","import { invariant, InvariantError } from \"ts-invariant\";\nimport DEV from \"./DEV\";\nexport { DEV };\nexport function checkDEV() {\n __DEV__ ? invariant(\"boolean\" === typeof DEV, DEV) : invariant(\"boolean\" === typeof DEV, 36);\n}\nimport { removeTemporaryGlobals } from \"./fix-graphql\";\nremoveTemporaryGlobals();\nexport { maybe } from \"./maybe\";\nexport { default as global } from \"./global\";\nexport { invariant, InvariantError };\ncheckDEV();\n//# sourceMappingURL=index.js.map"],"names":["global","Source","remove","invariant"],"mappings":";;;;;;;;AAAO,SAAS,KAAK,CAAC,KAAK,EAAE;AAC7B,IAAI,IAAI;AACR,QAAQ,OAAO,KAAK,EAAE,CAAC;AACvB,KAAK;AACL,IAAI,OAAO,EAAE,EAAE,GAAG;AAClB;;ACJA,eAAe,CAAC,KAAK,CAAC,YAAY,EAAE,OAAO,UAAU,CAAC,EAAE,CAAC;AACzD,IAAI,KAAK,CAAC,YAAY,EAAE,OAAO,MAAM,CAAC,EAAE,CAAC;AACzC,IAAI,KAAK,CAAC,YAAY,EAAE,OAAO,IAAI,CAAC,EAAE,CAAC;AACvC,IAAI,KAAK,CAAC,YAAY,EAAE,OAAO,MAAM,CAAC,EAAE,CAAC;AACzC,IAAI,KAAK,CAAC,YAAY,EAAE,OAAO,KAAK,CAAC,WAAW,CAAC,aAAa,CAAC,EAAE,CAAC,EAAE,CAAC;;ACHrE,IAAI,EAAE,GAAG,IAAI,CAAC;AACd,IAAI,UAAU,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACtC,SAAS,MAAM,GAAG;AAClB,IAAI,IAAI;AACR,QAAQ,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC;AAChC,KAAK;AACL,IAAI,OAAO,EAAE,EAAE;AACf,QAAQ,MAAM,CAAC,cAAc,CAACA,QAAM,EAAE,UAAU,EAAE;AAClD,YAAY,KAAK,EAAE,KAAK,CAAC,YAAY,EAAE,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,YAAY;AACvF,YAAY,UAAU,EAAE,KAAK;AAC7B,YAAY,YAAY,EAAE,IAAI;AAC9B,YAAY,QAAQ,EAAE,IAAI;AAC1B,SAAS,CAAC,CAAC;AACX,QAAQ,OAAOA,QAAM,CAAC,UAAU,CAAC,CAAC;AAClC,KAAK;AACL,CAAC;AACD,UAAe,MAAM,EAAE;;AChBhB,SAAS,sBAAsB,GAAG;AACzC,IAAI,OAAO,OAAOC,cAAM,KAAK,UAAU,GAAGC,gBAAM,EAAE,GAAGA,gBAAM,EAAE,CAAC;AAC9D;;ACDO,SAAS,QAAQ,GAAG;AAC3B,IAAI,OAAO,GAAGC,qBAAS,CAAC,SAAS,KAAK,OAAO,GAAG,EAAE,GAAG,CAAC,GAAGA,qBAAS,CAAC,SAAS,KAAK,OAAO,GAAG,EAAE,EAAE,CAAC,CAAC;AACjG,CAAC;AAED,sBAAsB,EAAE,CAAC;AAIzB,QAAQ,EAAE;;;;;;;;;"}
@@ -2,7 +2,7 @@ import { invariant, InvariantError } from "ts-invariant";
2
2
  import DEV from "./DEV.js";
3
3
  export { DEV };
4
4
  export function checkDEV() {
5
- __DEV__ ? invariant("boolean" === typeof DEV, DEV) : invariant("boolean" === typeof DEV, 38);
5
+ __DEV__ ? invariant("boolean" === typeof DEV, DEV) : invariant("boolean" === typeof DEV, 36);
6
6
  }
7
7
  import { removeTemporaryGlobals } from "./fix-graphql.js";
8
8
  removeTemporaryGlobals();
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@apollo/client/utilities/globals",
3
- "main": "globals.cjs.js",
3
+ "type": "module",
4
+ "main": "globals.cjs",
4
5
  "module": "index.js",
5
6
  "types": "index.d.ts",
6
7
  "sideEffects": true
@@ -10,7 +10,7 @@ export function shouldInclude(_a, variables) {
10
10
  var evaledValue = false;
11
11
  if (ifArgument.value.kind === 'Variable') {
12
12
  evaledValue = variables && variables[ifArgument.value.name.value];
13
- __DEV__ ? invariant(evaledValue !== void 0, "Invalid variable referenced in @" + directive.name.value + " directive.") : invariant(evaledValue !== void 0, 39);
13
+ __DEV__ ? invariant(evaledValue !== void 0, "Invalid variable referenced in @".concat(directive.name.value, " directive.")) : invariant(evaledValue !== void 0, 37);
14
14
  }
15
15
  else {
16
16
  evaledValue = ifArgument.value.value;
@@ -47,13 +47,13 @@ export function getInclusionDirectives(directives) {
47
47
  return;
48
48
  var directiveArguments = directive.arguments;
49
49
  var directiveName = directive.name.value;
50
- __DEV__ ? invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @" + directiveName + " directive.") : invariant(directiveArguments && directiveArguments.length === 1, 40);
50
+ __DEV__ ? invariant(directiveArguments && directiveArguments.length === 1, "Incorrect number of arguments for the @".concat(directiveName, " directive.")) : invariant(directiveArguments && directiveArguments.length === 1, 38);
51
51
  var ifArgument = directiveArguments[0];
52
- __DEV__ ? invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @" + directiveName + " directive.") : invariant(ifArgument.name && ifArgument.name.value === 'if', 41);
52
+ __DEV__ ? invariant(ifArgument.name && ifArgument.name.value === 'if', "Invalid argument for the @".concat(directiveName, " directive.")) : invariant(ifArgument.name && ifArgument.name.value === 'if', 39);
53
53
  var ifValue = ifArgument.value;
54
54
  __DEV__ ? invariant(ifValue &&
55
- (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @" + directiveName + " directive must be a variable or a boolean value.") : invariant(ifValue &&
56
- (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 42);
55
+ (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), "Argument for the @".concat(directiveName, " directive must be a variable or a boolean value.")) : invariant(ifValue &&
56
+ (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'), 40);
57
57
  result.push({ directive: directive, ifArgument: ifArgument });
58
58
  });
59
59
  }
@@ -1 +1 @@
1
- {"version":3,"file":"directives.js","sourceRoot":"","sources":["../../../src/utilities/graphql/directives.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,OAAO,EASL,KAAK,GACN,MAAM,SAAS,CAAC;AAMjB,MAAM,UAAU,aAAa,CAC3B,EAA6B,EAC7B,SAA+B;QAD7B,UAAU,gBAAA;IAGZ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KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { invariant } from '../globals';\n\n// Provides the methods that allow QueryManager to handle the `skip` and\n// `include` directives within GraphQL.\nimport {\n SelectionNode,\n VariableNode,\n BooleanValueNode,\n DirectiveNode,\n DocumentNode,\n ArgumentNode,\n ValueNode,\n ASTNode,\n visit,\n} from 'graphql';\n\nexport type DirectiveInfo = {\n [fieldName: string]: { [argName: string]: any };\n};\n\nexport function shouldInclude(\n { directives }: SelectionNode,\n variables?: Record<string, any>,\n): boolean {\n if (!directives || !directives.length) {\n return true;\n }\n return getInclusionDirectives(\n directives\n ).every(({ directive, ifArgument }) => {\n let evaledValue: boolean = false;\n if (ifArgument.value.kind === 'Variable') {\n evaledValue = variables && variables[(ifArgument.value as VariableNode).name.value];\n invariant(\n evaledValue !== void 0,\n `Invalid variable referenced in @${directive.name.value} directive.`,\n );\n } else {\n evaledValue = (ifArgument.value as BooleanValueNode).value;\n }\n return directive.name.value === 'skip' ? !evaledValue : evaledValue;\n });\n}\n\nexport function getDirectiveNames(root: ASTNode) {\n const names: string[] = [];\n\n visit(root, {\n Directive(node: DirectiveNode) {\n names.push(node.name.value);\n },\n });\n\n return names;\n}\n\nexport function hasDirectives(names: string[], root: ASTNode) {\n return getDirectiveNames(root).some(\n (name: string) => names.indexOf(name) > -1,\n );\n}\n\nexport function hasClientExports(document: DocumentNode) {\n return (\n document &&\n hasDirectives(['client'], document) &&\n hasDirectives(['export'], document)\n );\n}\n\nexport type InclusionDirectives = Array<{\n directive: DirectiveNode;\n ifArgument: ArgumentNode;\n}>;\n\nfunction isInclusionDirective({ name: { value } }: DirectiveNode): boolean {\n return value === 'skip' || value === 'include';\n}\n\nexport function getInclusionDirectives(\n directives: ReadonlyArray<DirectiveNode>,\n): InclusionDirectives {\n const result: InclusionDirectives = [];\n\n if (directives && directives.length) {\n directives.forEach(directive => {\n if (!isInclusionDirective(directive)) return;\n\n const directiveArguments = directive.arguments;\n const directiveName = directive.name.value;\n\n invariant(\n directiveArguments && directiveArguments.length === 1,\n `Incorrect number of arguments for the @${directiveName} directive.`,\n );\n\n const ifArgument = directiveArguments![0];\n invariant(\n ifArgument.name && ifArgument.name.value === 'if',\n `Invalid argument for the @${directiveName} directive.`,\n );\n\n const ifValue: ValueNode = ifArgument.value;\n\n // means it has to be a variable value if this is a valid @skip or @include directive\n invariant(\n ifValue &&\n (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'),\n `Argument for the @${directiveName} directive must be a variable or a boolean value.`,\n );\n\n result.push({ directive, ifArgument });\n });\n }\n\n return result;\n}\n\n"]}
1
+ {"version":3,"file":"directives.js","sourceRoot":"","sources":["../../../src/utilities/graphql/directives.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAIvC,OAAO,EASL,KAAK,GACN,MAAM,SAAS,CAAC;AAMjB,MAAM,UAAU,aAAa,CAC3B,EAA6B,EAC7B,SAA+B;QAD7B,UAAU,gBAAA;IAGZ,IAAI,CAAC,UAAU,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE;QACrC,OAAO,IAAI,CAAC;KACb;IACD,OAAO,sBAAsB,CAC3B,UAAU,CACX,CAAC,KAAK,CAAC,UAAC,EAAyB;YAAvB,SAAS,eAAA,EAAE,UAAU,gBAAA;QAC9B,IAAI,WAAW,GAAY,KAAK,CAAC;QACjC,IAAI,UAAU,CAAC,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE;YACxC,WAAW,GAAG,SAAS,IAAI,SAAS,CAAE,UAAU,CAAC,KAAsB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YACpF,SAAS,CACP,WAAW,KAAK,KAAK,CAAC,EACtB,0CAAmC,SAAS,CAAC,IAAI,CAAC,KAAK,gBAAa,CACrE,CAAC;SACH;aAAM;YACL,WAAW,GAAI,UAAU,CAAC,KAA0B,CAAC,KAAK,CAAC;SAC5D;QACD,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,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,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;YAE3C,SAAS,CACP,kBAAkB,IAAI,kBAAkB,CAAC,MAAM,KAAK,CAAC,EACrD,iDAA0C,aAAa,gBAAa,CACrE,CAAC;YAEF,IAAM,UAAU,GAAG,kBAAmB,CAAC,CAAC,CAAC,CAAC;YAC1C,SAAS,CACP,UAAU,CAAC,IAAI,IAAI,UAAU,CAAC,IAAI,CAAC,KAAK,KAAK,IAAI,EACjD,oCAA6B,aAAa,gBAAa,CACxD,CAAC;YAEF,IAAM,OAAO,GAAc,UAAU,CAAC,KAAK,CAAC;YAG5C,SAAS,CACP,OAAO;gBACL,CAAC,OAAO,CAAC,IAAI,KAAK,UAAU,IAAI,OAAO,CAAC,IAAI,KAAK,cAAc,CAAC,EAClE,4BAAqB,aAAa,sDAAmD,CACtF,CAAC;YAEF,MAAM,CAAC,IAAI,CAAC,EAAE,SAAS,WAAA,EAAE,UAAU,YAAA,EAAE,CAAC,CAAC;QACzC,CAAC,CAAC,CAAC;KACJ;IAED,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { invariant } from '../globals';\n\n// Provides the methods that allow QueryManager to handle the `skip` and\n// `include` directives within GraphQL.\nimport {\n SelectionNode,\n VariableNode,\n BooleanValueNode,\n DirectiveNode,\n DocumentNode,\n ArgumentNode,\n ValueNode,\n ASTNode,\n visit,\n} from 'graphql';\n\nexport type DirectiveInfo = {\n [fieldName: string]: { [argName: string]: any };\n};\n\nexport function shouldInclude(\n { directives }: SelectionNode,\n variables?: Record<string, any>,\n): boolean {\n if (!directives || !directives.length) {\n return true;\n }\n return getInclusionDirectives(\n directives\n ).every(({ directive, ifArgument }) => {\n let evaledValue: boolean = false;\n if (ifArgument.value.kind === 'Variable') {\n evaledValue = variables && variables[(ifArgument.value as VariableNode).name.value];\n invariant(\n evaledValue !== void 0,\n `Invalid variable referenced in @${directive.name.value} directive.`,\n );\n } else {\n evaledValue = (ifArgument.value as BooleanValueNode).value;\n }\n return directive.name.value === 'skip' ? !evaledValue : evaledValue;\n });\n}\n\nexport function getDirectiveNames(root: ASTNode) {\n const names: string[] = [];\n\n visit(root, {\n Directive(node: DirectiveNode) {\n names.push(node.name.value);\n },\n });\n\n return names;\n}\n\nexport function hasDirectives(names: string[], root: ASTNode) {\n return getDirectiveNames(root).some(\n (name: string) => names.indexOf(name) > -1,\n );\n}\n\nexport function hasClientExports(document: DocumentNode) {\n return (\n document &&\n hasDirectives(['client'], document) &&\n hasDirectives(['export'], document)\n );\n}\n\nexport type InclusionDirectives = Array<{\n directive: DirectiveNode;\n ifArgument: ArgumentNode;\n}>;\n\nfunction isInclusionDirective({ name: { value } }: DirectiveNode): boolean {\n return value === 'skip' || value === 'include';\n}\n\nexport function getInclusionDirectives(\n directives: ReadonlyArray<DirectiveNode>,\n): InclusionDirectives {\n const result: InclusionDirectives = [];\n\n if (directives && directives.length) {\n directives.forEach(directive => {\n if (!isInclusionDirective(directive)) return;\n\n const directiveArguments = directive.arguments;\n const directiveName = directive.name.value;\n\n invariant(\n directiveArguments && directiveArguments.length === 1,\n `Incorrect number of arguments for the @${directiveName} directive.`,\n );\n\n const ifArgument = directiveArguments![0];\n invariant(\n ifArgument.name && ifArgument.name.value === 'if',\n `Invalid argument for the @${directiveName} directive.`,\n );\n\n const ifValue: ValueNode = ifArgument.value;\n\n // means it has to be a variable value if this is a valid @skip or @include directive\n invariant(\n ifValue &&\n (ifValue.kind === 'Variable' || ifValue.kind === 'BooleanValue'),\n `Argument for the @${directiveName} directive must be a variable or a boolean value.`,\n );\n\n result.push({ directive, ifArgument });\n });\n }\n\n return result;\n}\n\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"fragments.d.ts","sourceRoot":"","sources":["../../../src/utilities/graphql/fragments.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,kBAAkB,EAClB,aAAa,EACd,MAAM,SAAS,CAAC;AAwBjB,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,YAAY,EACtB,YAAY,CAAC,EAAE,MAAM,GACpB,YAAY,CA+Dd;AAKD,MAAM,WAAW,WAAW;IAC1B,CAAC,YAAY,EAAE,MAAM,GAAG,sBAAsB,CAAC;CAChD;AAID,wBAAgB,iBAAiB,CAC/B,SAAS,GAAE,sBAAsB,EAAO,GACvC,WAAW,CAMb;AAED,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,aAAa,EACxB,WAAW,CAAC,EAAE,WAAW,GACxB,kBAAkB,GAAG,sBAAsB,GAAG,IAAI,CAYpD"}
1
+ {"version":3,"file":"fragments.d.ts","sourceRoot":"","sources":["../../../src/utilities/graphql/fragments.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,YAAY,EACZ,sBAAsB,EACtB,kBAAkB,EAClB,aAAa,EACd,MAAM,SAAS,CAAC;AA2BjB,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,YAAY,EACtB,YAAY,CAAC,EAAE,MAAM,GACpB,YAAY,CAgEd;AAKD,MAAM,WAAW,WAAW;IAC1B,CAAC,YAAY,EAAE,MAAM,GAAG,sBAAsB,CAAC;CAChD;AAID,wBAAgB,iBAAiB,CAC/B,SAAS,GAAE,sBAAsB,EAAO,GACvC,WAAW,CAMb;AAED,wBAAgB,wBAAwB,CACtC,SAAS,EAAE,aAAa,EACxB,WAAW,CAAC,EAAE,WAAW,GACxB,kBAAkB,GAAG,sBAAsB,GAAG,IAAI,CAYpD"}
@@ -5,15 +5,15 @@ export function getFragmentQueryDocument(document, fragmentName) {
5
5
  var fragments = [];
6
6
  document.definitions.forEach(function (definition) {
7
7
  if (definition.kind === 'OperationDefinition') {
8
- throw __DEV__ ? new InvariantError("Found a " + definition.operation + " operation" + (definition.name ? " named '" + definition.name.value + "'" : '') + ". " +
9
- 'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new InvariantError(43);
8
+ throw __DEV__ ? new InvariantError("Found a ".concat(definition.operation, " operation").concat(definition.name ? " named '".concat(definition.name.value, "'") : '', ". ") +
9
+ 'No operations are allowed when using a fragment as a query. Only fragments are allowed.') : new InvariantError(41);
10
10
  }
11
11
  if (definition.kind === 'FragmentDefinition') {
12
12
  fragments.push(definition);
13
13
  }
14
14
  });
15
15
  if (typeof actualFragmentName === 'undefined') {
16
- __DEV__ ? invariant(fragments.length === 1, "Found " + fragments.length + " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.") : invariant(fragments.length === 1, 44);
16
+ __DEV__ ? invariant(fragments.length === 1, "Found ".concat(fragments.length, " fragments. `fragmentName` must be provided when there is not exactly 1 fragment.")) : invariant(fragments.length === 1, 42);
17
17
  actualFragmentName = fragments[0].name.value;
18
18
  }
19
19
  var query = __assign(__assign({}, document), { definitions: __spreadArray([
@@ -50,7 +50,7 @@ export function getFragmentFromSelection(selection, fragmentMap) {
50
50
  return selection;
51
51
  case 'FragmentSpread': {
52
52
  var fragment = fragmentMap && fragmentMap[selection.name.value];
53
- __DEV__ ? invariant(fragment, "No fragment named " + selection.name.value + ".") : invariant(fragment, 45);
53
+ __DEV__ ? invariant(fragment, "No fragment named ".concat(selection.name.value, ".")) : invariant(fragment, 43);
54
54
  return fragment;
55
55
  }
56
56
  default:
@@ -1 +1 @@
1
- {"version":3,"file":"fragments.js","sourceRoot":"","sources":["../../../src/utilities/graphql/fragments.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AA+BvD,MAAM,UAAU,wBAAwB,CACtC,QAAsB,EACtB,YAAqB;IAErB,IAAI,kBAAkB,GAAG,YAAY,CAAC;IAKtC,IAAM,SAAS,GAAkC,EAAE,CAAC;IACpD,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,UAAA,UAAU;QAGrC,IAAI,UAAU,CAAC,IAAI,KAAK,qBAAqB,EAAE;YAC7C,MAAM,IAAI,cAAc,CACtB,aAAW,UAAU,CAAC,SAAS,mBAC7B,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,aAAW,UAAU,CAAC,I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nB,KAAK,gBAAgB,CAAC,CAAC;YACrB,IAAM,QAAQ,GAAG,WAAW,IAAI,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAClE,SAAS,CAAC,QAAQ,EAAE,uBAAqB,SAAS,CAAC,IAAI,CAAC,KAAK,MAAG,CAAC,CAAC;YAClE,OAAO,QAAS,CAAC;SAClB;QACD;YACE,OAAO,IAAI,CAAC;KACf;AACH,CAAC","sourcesContent":["import { invariant, InvariantError } from '../globals';\n\nimport {\n DocumentNode,\n FragmentDefinitionNode,\n InlineFragmentNode,\n SelectionNode\n} from 'graphql';\n\n/**\n * Returns a query document which adds a single query operation that only\n * spreads the target fragment inside of it.\n *\n * So for example a document of:\n *\n * ```graphql\n * fragment foo on Foo { a b c }\n * ```\n *\n * Turns into:\n *\n * ```graphql\n * { ...foo }\n *\n * fragment foo on Foo { a b c }\n * ```\n *\n * The target fragment will either be the only fragment in the document, or a\n * fragment specified by the provided `fragmentName`. If there is more than one\n * fragment, but a `fragmentName` was not defined then an error will be thrown.\n */\nexport function getFragmentQueryDocument(\n document: DocumentNode,\n fragmentName?: string,\n): DocumentNode {\n let actualFragmentName = fragmentName;\n\n // Build an array of all our fragment definitions that will be used for\n // validations. We also do some validations on the other definitions in the\n // document while building this list.\n const fragments: Array<FragmentDefinitionNode> = [];\n document.definitions.forEach(definition => {\n // Throw an error if we encounter an operation definition because we will\n // define our own operation definition later on.\n if (definition.kind === 'OperationDefinition') {\n throw new InvariantError(\n `Found a ${definition.operation} operation${\n definition.name ? ` named '${definition.name.value}'` : ''\n }. ` +\n 'No operations are allowed when using a fragment as a query. Only fragments are allowed.',\n );\n }\n // Add our definition to the fragments array if it is a fragment\n // definition.\n if (definition.kind === 'FragmentDefinition') {\n fragments.push(definition);\n }\n });\n\n // If the user did not give us a fragment name then let us try to get a\n // name from a single fragment in the definition.\n if (typeof actualFragmentName === 'undefined') {\n invariant(\n fragments.length === 1,\n `Found ${\n fragments.length\n } fragments. \\`fragmentName\\` must be provided when there is not exactly 1 fragment.`,\n );\n actualFragmentName = fragments[0].name.value;\n }\n\n // Generate a query document with an operation that simply spreads the\n // fragment inside of it.\n const query: DocumentNode = {\n ...document,\n definitions: [\n {\n kind: 'OperationDefinition',\n operation: 'query',\n selectionSet: {\n kind: 'SelectionSet',\n selections: [\n {\n kind: 'FragmentSpread',\n name: {\n kind: 'Name',\n value: actualFragmentName,\n },\n },\n ],\n },\n },\n ...document.definitions,\n ],\n };\n\n return query;\n}\n\n/**\n * This is an interface that describes a map from fragment names to fragment definitions.\n */\nexport interface FragmentMap {\n [fragmentName: string]: FragmentDefinitionNode;\n}\n\n// Utility function that takes a list of fragment definitions and makes a hash out of them\n// that maps the name of the fragment to the fragment definition.\nexport function createFragmentMap(\n fragments: FragmentDefinitionNode[] = [],\n): FragmentMap {\n const symTable: FragmentMap = {};\n fragments.forEach(fragment => {\n symTable[fragment.name.value] = fragment;\n });\n return symTable;\n}\n\nexport function getFragmentFromSelection(\n selection: SelectionNode,\n fragmentMap?: FragmentMap,\n): InlineFragmentNode | FragmentDefinitionNode | null {\n switch (selection.kind) {\n case 'InlineFragment':\n return selection;\n case 'FragmentSpread': {\n const fragment = fragmentMap && fragmentMap[selection.name.value];\n invariant(fragment, `No fragment named ${selection.name.value}.`);\n return fragment!;\n }\n default:\n return null;\n }\n}\n"]}
1
+ {"version":3,"file":"fragments.js","sourceRoot":"","sources":["../../../src/utilities/graphql/fragments.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAkCvD,MAAM,UAAU,wBAAwB,CACtC,QAAsB,EACtB,YAAqB;IAErB,IAAI,kBAAkB,GAAG,YAAY,CAAC;IAKtC,IAAM,SAAS,GAAkC,EAAE,CAAC;IACpD,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC,UAAA,UAAU;QAGrC,IAAI,UAAU,CAAC,IAAI,KAAK,qBAAqB,EAAE;YAC7C,MAAM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wB,CACtC,SAAwB,EACxB,WAAyB;IAEzB,QAAQ,SAAS,CAAC,IAAI,EAAE;QACtB,KAAK,gBAAgB;YACnB,OAAO,SAAS,CAAC;QACnB,KAAK,gBAAgB,CAAC,CAAC;YACrB,IAAM,QAAQ,GAAG,WAAW,IAAI,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;YAClE,SAAS,CAAC,QAAQ,EAAE,4BAAqB,SAAS,CAAC,IAAI,CAAC,KAAK,MAAG,CAAC,CAAC;YAClE,OAAO,QAAS,CAAC;SAClB;QACD;YACE,OAAO,IAAI,CAAC;KACf;AACH,CAAC","sourcesContent":["import { invariant, InvariantError } from '../globals';\n\nimport {\n DocumentNode,\n FragmentDefinitionNode,\n InlineFragmentNode,\n SelectionNode,\n} from 'graphql';\n\n// TODO(brian): A hack until this issue is resolved (https://github.com/graphql/graphql-js/issues/3356)\ntype Kind = any;\ntype OperationTypeNode = any;\n/**\n * Returns a query document which adds a single query operation that only\n * spreads the target fragment inside of it.\n *\n * So for example a document of:\n *\n * ```graphql\n * fragment foo on Foo { a b c }\n * ```\n *\n * Turns into:\n *\n * ```graphql\n * { ...foo }\n *\n * fragment foo on Foo { a b c }\n * ```\n *\n * The target fragment will either be the only fragment in the document, or a\n * fragment specified by the provided `fragmentName`. If there is more than one\n * fragment, but a `fragmentName` was not defined then an error will be thrown.\n */\nexport function getFragmentQueryDocument(\n document: DocumentNode,\n fragmentName?: string,\n): DocumentNode {\n let actualFragmentName = fragmentName;\n\n // Build an array of all our fragment definitions that will be used for\n // validations. We also do some validations on the other definitions in the\n // document while building this list.\n const fragments: Array<FragmentDefinitionNode> = [];\n document.definitions.forEach(definition => {\n // Throw an error if we encounter an operation definition because we will\n // define our own operation definition later on.\n if (definition.kind === 'OperationDefinition') {\n throw new InvariantError(\n `Found a ${definition.operation} operation${\n definition.name ? ` named '${definition.name.value}'` : ''\n }. ` +\n 'No operations are allowed when using a fragment as a query. Only fragments are allowed.',\n );\n }\n // Add our definition to the fragments array if it is a fragment\n // definition.\n if (definition.kind === 'FragmentDefinition') {\n fragments.push(definition);\n }\n });\n\n // If the user did not give us a fragment name then let us try to get a\n // name from a single fragment in the definition.\n if (typeof actualFragmentName === 'undefined') {\n invariant(\n fragments.length === 1,\n `Found ${\n fragments.length\n } fragments. \\`fragmentName\\` must be provided when there is not exactly 1 fragment.`,\n );\n actualFragmentName = fragments[0].name.value;\n }\n\n // Generate a query document with an operation that simply spreads the\n // fragment inside of it.\n const query: DocumentNode = {\n ...document,\n definitions: [\n {\n kind: 'OperationDefinition' as Kind,\n // OperationTypeNode is an enum\n operation: 'query' as OperationTypeNode,\n selectionSet: {\n kind: 'SelectionSet' as Kind,\n selections: [\n {\n kind: 'FragmentSpread' as Kind,\n name: {\n kind: 'Name' as Kind,\n value: actualFragmentName,\n },\n },\n ],\n },\n },\n ...document.definitions,\n ],\n };\n\n return query;\n}\n\n/**\n * This is an interface that describes a map from fragment names to fragment definitions.\n */\nexport interface FragmentMap {\n [fragmentName: string]: FragmentDefinitionNode;\n}\n\n// Utility function that takes a list of fragment definitions and makes a hash out of them\n// that maps the name of the fragment to the fragment definition.\nexport function createFragmentMap(\n fragments: FragmentDefinitionNode[] = [],\n): FragmentMap {\n const symTable: FragmentMap = {};\n fragments.forEach(fragment => {\n symTable[fragment.name.value] = fragment;\n });\n return symTable;\n}\n\nexport function getFragmentFromSelection(\n selection: SelectionNode,\n fragmentMap?: FragmentMap,\n): InlineFragmentNode | FragmentDefinitionNode | null {\n switch (selection.kind) {\n case 'InlineFragment':\n return selection;\n case 'FragmentSpread': {\n const fragment = fragmentMap && fragmentMap[selection.name.value];\n invariant(fragment, `No fragment named ${selection.name.value}.`);\n return fragment!;\n }\n default:\n return null;\n }\n}\n"]}