@apollo/client 4.0.0-alpha.5 → 4.0.0-alpha.7

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 (446) hide show
  1. package/.changeset/dirty-eagles-poke.md +5 -0
  2. package/.changeset/giant-bags-share.md +5 -0
  3. package/.changeset/nervous-fireants-bow.md +5 -0
  4. package/.changeset/nice-dots-matter.md +5 -0
  5. package/.changeset/pre.json +7 -0
  6. package/.changeset/purple-bears-flash.md +5 -0
  7. package/.changeset/tame-points-work.md +11 -0
  8. package/.changeset/tender-swans-flash.md +16 -0
  9. package/CHANGELOG.md +44 -0
  10. package/__cjs/cache/core/cache.cjs +1 -1
  11. package/__cjs/cache/index.cjs +4 -4
  12. package/__cjs/cache/index.cjs.map +1 -1
  13. package/__cjs/cache/index.d.cts +3 -3
  14. package/__cjs/cache/inmemory/entityStore.cjs +3 -3
  15. package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
  16. package/__cjs/cache/inmemory/policies.cjs +4 -4
  17. package/__cjs/cache/inmemory/readFromStore.cjs +2 -2
  18. package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
  19. package/__cjs/config/jest/areCombinedGraphQLErrorsEqual.cjs +3 -1
  20. package/__cjs/config/jest/areCombinedGraphQLErrorsEqual.cjs.map +1 -1
  21. package/__cjs/config/jest/setup.cjs +6 -0
  22. package/__cjs/config/jest/setup.cjs.map +1 -1
  23. package/__cjs/core/ApolloClient.cjs +9 -5
  24. package/__cjs/core/ApolloClient.cjs.map +1 -1
  25. package/__cjs/core/ApolloClient.d.cts +5 -7
  26. package/__cjs/core/LocalState.cjs +2 -2
  27. package/__cjs/core/ObservableQuery.cjs +15 -10
  28. package/__cjs/core/ObservableQuery.cjs.map +1 -1
  29. package/__cjs/core/ObservableQuery.d.cts +6 -6
  30. package/__cjs/core/QueryInfo.cjs +0 -7
  31. package/__cjs/core/QueryInfo.cjs.map +1 -1
  32. package/__cjs/core/QueryInfo.d.cts +0 -2
  33. package/__cjs/core/QueryManager.cjs +41 -30
  34. package/__cjs/core/QueryManager.cjs.map +1 -1
  35. package/__cjs/core/QueryManager.d.cts +4 -4
  36. package/__cjs/core/index.cjs +39 -21
  37. package/__cjs/core/index.cjs.map +1 -1
  38. package/__cjs/core/index.d.cts +12 -11
  39. package/__cjs/core/types.d.cts +24 -2
  40. package/__cjs/errors/CombinedGraphQLErrors.cjs +8 -1
  41. package/__cjs/errors/CombinedGraphQLErrors.cjs.map +1 -1
  42. package/__cjs/errors/CombinedGraphQLErrors.d.cts +7 -2
  43. package/__cjs/index.cjs +1 -0
  44. package/__cjs/index.cjs.map +1 -1
  45. package/__cjs/invariantErrorCodes.cjs +111 -125
  46. package/__cjs/link/batch/index.cjs +4 -2
  47. package/__cjs/link/batch/index.cjs.map +1 -1
  48. package/__cjs/link/batch/index.d.cts +2 -1
  49. package/__cjs/link/batch-http/index.cjs +3 -2
  50. package/__cjs/link/batch-http/index.cjs.map +1 -1
  51. package/__cjs/link/batch-http/index.d.cts +1 -1
  52. package/__cjs/link/core/ApolloLink.cjs +2 -2
  53. package/__cjs/link/core/index.cjs.map +1 -1
  54. package/__cjs/link/core/index.d.cts +1 -1
  55. package/__cjs/link/http/checkFetcher.cjs +1 -1
  56. package/__cjs/link/http/createHttpLink.cjs +1 -1
  57. package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
  58. package/__cjs/link/http/serializeFetchParameter.cjs +1 -1
  59. package/__cjs/link/persisted-queries/index.cjs +2 -2
  60. package/__cjs/link/retry/index.cjs +3 -2
  61. package/__cjs/link/retry/index.cjs.map +1 -1
  62. package/__cjs/link/retry/index.d.cts +1 -1
  63. package/__cjs/link/subscriptions/index.cjs +3 -1
  64. package/__cjs/link/subscriptions/index.cjs.map +1 -1
  65. package/__cjs/link/utils/validateOperation.cjs +1 -1
  66. package/__cjs/masking/maskDefinition.cjs +2 -2
  67. package/__cjs/masking/maskFragment.cjs +2 -2
  68. package/__cjs/masking/maskOperation.cjs +1 -1
  69. package/__cjs/masking/utils.cjs +1 -1
  70. package/__cjs/react/context/ApolloConsumer.cjs +1 -1
  71. package/__cjs/react/context/ApolloConsumer.cjs.map +1 -1
  72. package/__cjs/react/context/ApolloConsumer.d.cts +6 -3
  73. package/__cjs/react/context/ApolloContext.cjs +1 -1
  74. package/__cjs/react/context/ApolloProvider.cjs +1 -1
  75. package/__cjs/react/context/ApolloProvider.cjs.map +1 -1
  76. package/__cjs/react/context/ApolloProvider.d.cts +6 -4
  77. package/__cjs/react/hooks/internal/wrapHook.cjs.map +1 -1
  78. package/__cjs/react/hooks/internal/wrapHook.d.cts +1 -1
  79. package/__cjs/react/hooks/useApolloClient.cjs +3 -3
  80. package/__cjs/react/hooks/useApolloClient.cjs.map +1 -1
  81. package/__cjs/react/hooks/useLazyQuery.cjs +2 -2
  82. package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
  83. package/__cjs/react/hooks/useLazyQuery.d.cts +4 -4
  84. package/__cjs/react/hooks/useLoadableQuery.cjs +2 -2
  85. package/__cjs/react/hooks/useMutation.cjs +0 -2
  86. package/__cjs/react/hooks/useMutation.cjs.map +1 -1
  87. package/__cjs/react/hooks/useMutation.d.cts +1 -2
  88. package/__cjs/react/hooks/useQuery.cjs +0 -2
  89. package/__cjs/react/hooks/useQuery.cjs.map +1 -1
  90. package/__cjs/react/hooks/useQuery.d.cts +3 -3
  91. package/__cjs/react/hooks/useSubscription.cjs +1 -3
  92. package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
  93. package/__cjs/react/hooks/useSuspenseQuery.cjs +3 -5
  94. package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
  95. package/__cjs/react/hooks/useSyncExternalStore.cjs +1 -1
  96. package/__cjs/react/index.cjs +35 -11
  97. package/__cjs/react/index.cjs.map +1 -1
  98. package/__cjs/react/index.d.cts +21 -7
  99. package/__cjs/react/index.react-server.cjs +1 -5
  100. package/__cjs/react/index.react-server.cjs.map +1 -1
  101. package/__cjs/react/index.react-server.d.cts +0 -1
  102. package/__cjs/react/internal/cache/QueryReference.cjs +1 -1
  103. package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
  104. package/__cjs/react/internal/cache/QueryReference.d.cts +3 -3
  105. package/__cjs/react/internal/types.d.cts +2 -2
  106. package/__cjs/react/ssr/getDataFromTree.cjs +23 -60
  107. package/__cjs/react/ssr/getDataFromTree.cjs.map +1 -1
  108. package/__cjs/react/ssr/getDataFromTree.d.cts +12 -6
  109. package/__cjs/react/ssr/index.cjs +3 -1
  110. package/__cjs/react/ssr/index.cjs.map +1 -1
  111. package/__cjs/react/ssr/index.d.cts +1 -0
  112. package/__cjs/react/ssr/prerenderStatic.cjs +151 -0
  113. package/__cjs/react/ssr/prerenderStatic.cjs.map +1 -0
  114. package/__cjs/react/ssr/prerenderStatic.d.cts +122 -0
  115. package/__cjs/react/ssr/renderToStringWithData.cjs +11 -5
  116. package/__cjs/react/ssr/renderToStringWithData.cjs.map +1 -1
  117. package/__cjs/react/ssr/renderToStringWithData.d.cts +5 -0
  118. package/__cjs/react/ssr/useSSRQuery.cjs.map +1 -1
  119. package/__cjs/react/ssr/useSSRQuery.d.cts +2 -2
  120. package/__cjs/react/types/deprecated.d.cts +11 -1
  121. package/__cjs/testing/core/index.cjs +5 -3
  122. package/__cjs/testing/core/index.cjs.map +1 -1
  123. package/__cjs/testing/core/index.d.cts +1 -1
  124. package/__cjs/testing/core/mocking/mockLink.cjs +2 -2
  125. package/__cjs/testing/experimental/createSchemaFetch.cjs +2 -2
  126. package/__cjs/testing/experimental/createSchemaFetch.cjs.map +1 -1
  127. package/__cjs/testing/index.cjs +12 -2
  128. package/__cjs/testing/index.cjs.map +1 -1
  129. package/__cjs/testing/index.d.cts +2 -1
  130. package/__cjs/testing/internal/disposables/spyOnConsole.cjs +0 -1
  131. package/__cjs/testing/internal/disposables/spyOnConsole.cjs.map +1 -1
  132. package/__cjs/testing/internal/disposables/spyOnConsole.d.cts +0 -1
  133. package/__cjs/testing/internal/index.cjs +14 -8
  134. package/__cjs/testing/internal/index.cjs.map +1 -1
  135. package/__cjs/testing/internal/index.d.cts +4 -3
  136. package/__cjs/testing/internal/resetApolloContext.cjs +24 -0
  137. package/__cjs/testing/internal/resetApolloContext.cjs.map +1 -0
  138. package/__cjs/testing/internal/resetApolloContext.d.cts +10 -0
  139. package/__cjs/testing/matchers/index.cjs +4 -22
  140. package/__cjs/testing/matchers/index.cjs.map +1 -1
  141. package/__cjs/testing/matchers/toComplete.cjs.map +1 -1
  142. package/__cjs/testing/matchers/toEmitAnything.cjs.map +1 -1
  143. package/__cjs/testing/matchers/toEmitError.cjs.map +1 -1
  144. package/__cjs/testing/matchers/toEmitNext.cjs.map +1 -1
  145. package/__cjs/testing/matchers/{toEmitStrictTyped.cjs → toEmitTypedValue.cjs} +5 -5
  146. package/__cjs/testing/matchers/toEmitTypedValue.cjs.map +1 -0
  147. package/__cjs/testing/matchers/{toEmitValueStrict.d.cts → toEmitTypedValue.d.cts} +2 -2
  148. package/__cjs/testing/matchers/{toEqualStrictTyped.cjs → toStrictEqualTyped.cjs} +5 -5
  149. package/__cjs/testing/matchers/{toEqualStrictTyped.cjs.map → toStrictEqualTyped.cjs.map} +1 -1
  150. package/__cjs/testing/matchers/toStrictEqualTyped.d.cts +3 -0
  151. package/__cjs/testing/react/MockedProvider.cjs +2 -2
  152. package/__cjs/testing/react/MockedProvider.cjs.map +1 -1
  153. package/__cjs/utilities/caching/sizes.cjs +2 -2
  154. package/__cjs/utilities/caching/sizes.cjs.map +1 -1
  155. package/__cjs/utilities/caching/sizes.d.cts +2 -20
  156. package/__cjs/utilities/graphql/getFromAST.cjs +15 -6
  157. package/__cjs/utilities/graphql/getFromAST.cjs.map +1 -1
  158. package/__cjs/utilities/graphql/getFromAST.d.cts +2 -2
  159. package/__cjs/utilities/graphql/storeUtils.cjs +1 -1
  160. package/__cjs/utilities/graphql/transform.cjs +2 -2
  161. package/__cjs/utilities/index.cjs +39 -19
  162. package/__cjs/utilities/index.cjs.map +1 -1
  163. package/__cjs/utilities/index.d.cts +14 -13
  164. package/__cjs/utilities/internal/getMemoryInternals.cjs +0 -2
  165. package/__cjs/utilities/internal/getMemoryInternals.cjs.map +1 -1
  166. package/__cjs/utilities/internal/getMemoryInternals.d.cts +0 -1
  167. package/__cjs/utilities/internal/index.cjs +3 -1
  168. package/__cjs/utilities/internal/index.cjs.map +1 -1
  169. package/__cjs/utilities/internal/index.d.cts +1 -0
  170. package/__cjs/utilities/internal/index.production.cjs +1 -0
  171. package/__cjs/utilities/internal/index.production.cjs.map +1 -1
  172. package/__cjs/utilities/internal/toQueryResult.cjs +13 -0
  173. package/__cjs/utilities/internal/toQueryResult.cjs.map +1 -0
  174. package/__cjs/utilities/internal/toQueryResult.d.cts +3 -0
  175. package/__cjs/utilities/invariant/index.development.cjs +1 -0
  176. package/__cjs/utilities/invariant/index.development.cjs.map +1 -1
  177. package/__cjs/version.cjs +1 -1
  178. package/__cjs/version.d.cts +1 -1
  179. package/cache/core/cache.js +1 -1
  180. package/cache/index.d.ts +3 -3
  181. package/cache/index.js +1 -1
  182. package/cache/index.js.map +1 -1
  183. package/cache/inmemory/entityStore.js +3 -3
  184. package/cache/inmemory/key-extractor.js +1 -1
  185. package/cache/inmemory/policies.js +4 -4
  186. package/cache/inmemory/readFromStore.js +2 -2
  187. package/cache/inmemory/writeToStore.js +4 -4
  188. package/config/jest/areCombinedGraphQLErrorsEqual.js +3 -1
  189. package/config/jest/areCombinedGraphQLErrorsEqual.js.map +1 -1
  190. package/config/jest/setup.js +6 -0
  191. package/config/jest/setup.js.map +1 -1
  192. package/core/ApolloClient.d.ts +5 -7
  193. package/core/ApolloClient.js +9 -5
  194. package/core/ApolloClient.js.map +1 -1
  195. package/core/LocalState.js +2 -2
  196. package/core/ObservableQuery.d.ts +6 -6
  197. package/core/ObservableQuery.js +15 -10
  198. package/core/ObservableQuery.js.map +1 -1
  199. package/core/QueryInfo.d.ts +0 -2
  200. package/core/QueryInfo.js +0 -7
  201. package/core/QueryInfo.js.map +1 -1
  202. package/core/QueryManager.d.ts +4 -4
  203. package/core/QueryManager.js +43 -32
  204. package/core/QueryManager.js.map +1 -1
  205. package/core/index.d.ts +12 -11
  206. package/core/index.js +7 -5
  207. package/core/index.js.map +1 -1
  208. package/core/types.d.ts +24 -2
  209. package/errors/CombinedGraphQLErrors.d.ts +7 -2
  210. package/errors/CombinedGraphQLErrors.js +8 -1
  211. package/errors/CombinedGraphQLErrors.js.map +1 -1
  212. package/index.js +1 -0
  213. package/index.js.map +1 -1
  214. package/invariantErrorCodes.js +111 -125
  215. package/legacyEntryPoints/testing/internal/index.d.ts +1 -0
  216. package/legacyEntryPoints/testing/internal/index.js +1 -0
  217. package/legacyEntryPoints/testing/internal/internal.cjs +1 -0
  218. package/legacyEntryPoints/testing/internal/internal.d.cts +1 -0
  219. package/link/batch/index.d.ts +2 -1
  220. package/link/batch/index.js +1 -1
  221. package/link/batch/index.js.map +1 -1
  222. package/link/batch-http/index.d.ts +1 -1
  223. package/link/batch-http/index.js +1 -1
  224. package/link/batch-http/index.js.map +1 -1
  225. package/link/core/ApolloLink.js +2 -2
  226. package/link/core/index.d.ts +1 -1
  227. package/link/core/index.js.map +1 -1
  228. package/link/http/checkFetcher.js +1 -1
  229. package/link/http/createHttpLink.js +1 -1
  230. package/link/http/parseAndCheckHttpResponse.js +1 -1
  231. package/link/http/serializeFetchParameter.js +1 -1
  232. package/link/persisted-queries/index.js +2 -2
  233. package/link/retry/index.d.ts +1 -1
  234. package/link/retry/index.js +1 -1
  235. package/link/retry/index.js.map +1 -1
  236. package/link/subscriptions/index.js +3 -1
  237. package/link/subscriptions/index.js.map +1 -1
  238. package/link/utils/validateOperation.js +1 -1
  239. package/masking/maskDefinition.js +2 -2
  240. package/masking/maskFragment.js +2 -2
  241. package/masking/maskOperation.js +1 -1
  242. package/masking/utils.js +1 -1
  243. package/package.json +11 -31
  244. package/react/context/ApolloConsumer.d.ts +6 -3
  245. package/react/context/ApolloConsumer.js +1 -1
  246. package/react/context/ApolloConsumer.js.map +1 -1
  247. package/react/context/ApolloContext.js +1 -1
  248. package/react/context/ApolloProvider.d.ts +6 -4
  249. package/react/context/ApolloProvider.js +1 -1
  250. package/react/context/ApolloProvider.js.map +1 -1
  251. package/react/hooks/internal/wrapHook.d.ts +1 -1
  252. package/react/hooks/internal/wrapHook.js.map +1 -1
  253. package/react/hooks/useApolloClient.js +2 -2
  254. package/react/hooks/useApolloClient.js.map +1 -1
  255. package/react/hooks/useLazyQuery.d.ts +4 -4
  256. package/react/hooks/useLazyQuery.js +2 -2
  257. package/react/hooks/useLazyQuery.js.map +1 -1
  258. package/react/hooks/useLoadableQuery.js +2 -2
  259. package/react/hooks/useMutation.d.ts +1 -2
  260. package/react/hooks/useMutation.js +0 -2
  261. package/react/hooks/useMutation.js.map +1 -1
  262. package/react/hooks/useQuery.d.ts +3 -3
  263. package/react/hooks/useQuery.js +0 -2
  264. package/react/hooks/useQuery.js.map +1 -1
  265. package/react/hooks/useSubscription.js +1 -3
  266. package/react/hooks/useSubscription.js.map +1 -1
  267. package/react/hooks/useSuspenseQuery.js +3 -5
  268. package/react/hooks/useSuspenseQuery.js.map +1 -1
  269. package/react/hooks/useSyncExternalStore.js +1 -1
  270. package/react/index.d.ts +21 -7
  271. package/react/index.js +17 -3
  272. package/react/index.js.map +1 -1
  273. package/react/index.react-server.d.ts +0 -1
  274. package/react/index.react-server.js +0 -1
  275. package/react/index.react-server.js.map +1 -1
  276. package/react/internal/cache/QueryReference.d.ts +3 -3
  277. package/react/internal/cache/QueryReference.js +1 -1
  278. package/react/internal/cache/QueryReference.js.map +1 -1
  279. package/react/internal/types.d.ts +2 -2
  280. package/react/ssr/getDataFromTree.d.ts +12 -6
  281. package/react/ssr/getDataFromTree.js +23 -59
  282. package/react/ssr/getDataFromTree.js.map +1 -1
  283. package/react/ssr/index.d.ts +1 -0
  284. package/react/ssr/index.js +1 -0
  285. package/react/ssr/index.js.map +1 -1
  286. package/react/ssr/prerenderStatic.d.ts +122 -0
  287. package/react/ssr/prerenderStatic.js +147 -0
  288. package/react/ssr/prerenderStatic.js.map +1 -0
  289. package/react/ssr/renderToStringWithData.d.ts +5 -0
  290. package/react/ssr/renderToStringWithData.js +11 -5
  291. package/react/ssr/renderToStringWithData.js.map +1 -1
  292. package/react/ssr/useSSRQuery.d.ts +2 -2
  293. package/react/ssr/useSSRQuery.js.map +1 -1
  294. package/react/types/deprecated.d.ts +11 -1
  295. package/testing/core/index.d.ts +1 -1
  296. package/testing/core/index.js +1 -1
  297. package/testing/core/index.js.map +1 -1
  298. package/testing/core/mocking/mockLink.js +2 -2
  299. package/testing/experimental/createSchemaFetch.js +1 -1
  300. package/testing/experimental/createSchemaFetch.js.map +1 -1
  301. package/testing/index.d.ts +2 -1
  302. package/testing/index.js +1 -1
  303. package/testing/index.js.map +1 -1
  304. package/testing/internal/disposables/spyOnConsole.d.ts +0 -1
  305. package/testing/internal/disposables/spyOnConsole.js +0 -1
  306. package/testing/internal/disposables/spyOnConsole.js.map +1 -1
  307. package/testing/internal/index.d.ts +4 -3
  308. package/testing/internal/index.js +4 -3
  309. package/testing/internal/index.js.map +1 -1
  310. package/testing/internal/resetApolloContext.d.ts +10 -0
  311. package/testing/internal/resetApolloContext.js +20 -0
  312. package/testing/internal/resetApolloContext.js.map +1 -0
  313. package/testing/matchers/index.js +4 -22
  314. package/testing/matchers/index.js.map +1 -1
  315. package/testing/matchers/toComplete.js.map +1 -1
  316. package/testing/matchers/toEmitAnything.js.map +1 -1
  317. package/testing/matchers/toEmitError.js.map +1 -1
  318. package/testing/matchers/toEmitNext.js.map +1 -1
  319. package/testing/matchers/{toEmitValueStrict.d.ts → toEmitTypedValue.d.ts} +2 -2
  320. package/testing/matchers/{toEmitStrictTyped.js → toEmitTypedValue.js} +3 -3
  321. package/testing/matchers/toEmitTypedValue.js.map +1 -0
  322. package/testing/matchers/toStrictEqualTyped.d.ts +3 -0
  323. package/testing/matchers/{toEqualStrictTyped.js → toStrictEqualTyped.js} +3 -3
  324. package/testing/matchers/{toEqualStrictTyped.js.map → toStrictEqualTyped.js.map} +1 -1
  325. package/testing/react/MockedProvider.js +1 -1
  326. package/testing/react/MockedProvider.js.map +1 -1
  327. package/utilities/caching/sizes.d.ts +2 -20
  328. package/utilities/caching/sizes.js +2 -2
  329. package/utilities/caching/sizes.js.map +1 -1
  330. package/utilities/graphql/getFromAST.d.ts +2 -2
  331. package/utilities/graphql/getFromAST.js +15 -6
  332. package/utilities/graphql/getFromAST.js.map +1 -1
  333. package/utilities/graphql/storeUtils.js +1 -1
  334. package/utilities/graphql/transform.js +2 -2
  335. package/utilities/index.d.ts +14 -13
  336. package/utilities/index.js +12 -12
  337. package/utilities/index.js.map +1 -1
  338. package/utilities/internal/getMemoryInternals.d.ts +0 -1
  339. package/utilities/internal/getMemoryInternals.js +0 -2
  340. package/utilities/internal/getMemoryInternals.js.map +1 -1
  341. package/utilities/internal/index.d.ts +1 -0
  342. package/utilities/internal/index.js +2 -1
  343. package/utilities/internal/index.js.map +1 -1
  344. package/utilities/internal/index.production.js +1 -0
  345. package/utilities/internal/index.production.js.map +1 -1
  346. package/utilities/internal/toQueryResult.d.ts +3 -0
  347. package/utilities/internal/toQueryResult.js +10 -0
  348. package/utilities/internal/toQueryResult.js.map +1 -0
  349. package/utilities/invariant/index.development.js +1 -0
  350. package/utilities/invariant/index.development.js.map +1 -1
  351. package/version.d.ts +1 -1
  352. package/version.js +1 -1
  353. package/__cjs/react/context/index.cjs +0 -10
  354. package/__cjs/react/context/index.cjs.map +0 -1
  355. package/__cjs/react/context/index.d.cts +0 -7
  356. package/__cjs/react/hooks/index.cjs +0 -32
  357. package/__cjs/react/hooks/index.cjs.map +0 -1
  358. package/__cjs/react/hooks/index.d.cts +0 -16
  359. package/__cjs/react/parser/index.cjs +0 -115
  360. package/__cjs/react/parser/index.cjs.map +0 -1
  361. package/__cjs/react/parser/index.d.cts +0 -18
  362. package/__cjs/testing/matchers/toEmitApolloQueryResult.cjs +0 -40
  363. package/__cjs/testing/matchers/toEmitApolloQueryResult.cjs.map +0 -1
  364. package/__cjs/testing/matchers/toEmitApolloQueryResult.d.cts +0 -8
  365. package/__cjs/testing/matchers/toEmitFetchResult.cjs +0 -40
  366. package/__cjs/testing/matchers/toEmitFetchResult.cjs.map +0 -1
  367. package/__cjs/testing/matchers/toEmitFetchResult.d.cts +0 -8
  368. package/__cjs/testing/matchers/toEmitMatchedValue.cjs +0 -40
  369. package/__cjs/testing/matchers/toEmitMatchedValue.cjs.map +0 -1
  370. package/__cjs/testing/matchers/toEmitMatchedValue.d.cts +0 -7
  371. package/__cjs/testing/matchers/toEmitStrictTyped.cjs.map +0 -1
  372. package/__cjs/testing/matchers/toEmitStrictTyped.d.cts +0 -7
  373. package/__cjs/testing/matchers/toEmitValue.cjs +0 -41
  374. package/__cjs/testing/matchers/toEmitValue.cjs.map +0 -1
  375. package/__cjs/testing/matchers/toEmitValue.d.cts +0 -4
  376. package/__cjs/testing/matchers/toEmitValueStrict.cjs +0 -46
  377. package/__cjs/testing/matchers/toEmitValueStrict.cjs.map +0 -1
  378. package/__cjs/testing/matchers/toEqualApolloQueryResult.cjs +0 -24
  379. package/__cjs/testing/matchers/toEqualApolloQueryResult.cjs.map +0 -1
  380. package/__cjs/testing/matchers/toEqualApolloQueryResult.d.cts +0 -6
  381. package/__cjs/testing/matchers/toEqualFetchResult.cjs +0 -24
  382. package/__cjs/testing/matchers/toEqualFetchResult.cjs.map +0 -1
  383. package/__cjs/testing/matchers/toEqualFetchResult.d.cts +0 -4
  384. package/__cjs/testing/matchers/toEqualLazyQueryResult.cjs +0 -40
  385. package/__cjs/testing/matchers/toEqualLazyQueryResult.cjs.map +0 -1
  386. package/__cjs/testing/matchers/toEqualLazyQueryResult.d.cts +0 -10
  387. package/__cjs/testing/matchers/toEqualQueryResult.cjs +0 -39
  388. package/__cjs/testing/matchers/toEqualQueryResult.cjs.map +0 -1
  389. package/__cjs/testing/matchers/toEqualQueryResult.d.cts +0 -9
  390. package/__cjs/testing/matchers/toEqualStrictTyped.d.cts +0 -3
  391. package/__cjs/utilities/types/TODO.cjs +0 -3
  392. package/__cjs/utilities/types/TODO.cjs.map +0 -1
  393. package/__cjs/utilities/types/TODO.d.cts +0 -3
  394. package/legacyEntryPoints/react/context/context.cjs +0 -1
  395. package/legacyEntryPoints/react/context/context.d.cts +0 -1
  396. package/legacyEntryPoints/react/context/index.d.ts +0 -1
  397. package/legacyEntryPoints/react/context/index.js +0 -1
  398. package/legacyEntryPoints/react/hooks/hooks.cjs +0 -1
  399. package/legacyEntryPoints/react/hooks/hooks.d.cts +0 -1
  400. package/legacyEntryPoints/react/hooks/index.d.ts +0 -1
  401. package/legacyEntryPoints/react/hooks/index.js +0 -1
  402. package/legacyEntryPoints/react/parser/index.d.ts +0 -1
  403. package/legacyEntryPoints/react/parser/index.js +0 -1
  404. package/legacyEntryPoints/react/parser/parser.cjs +0 -1
  405. package/legacyEntryPoints/react/parser/parser.d.cts +0 -1
  406. package/react/context/index.d.ts +0 -7
  407. package/react/context/index.js +0 -4
  408. package/react/context/index.js.map +0 -1
  409. package/react/hooks/index.d.ts +0 -16
  410. package/react/hooks/index.js +0 -15
  411. package/react/hooks/index.js.map +0 -1
  412. package/react/parser/index.d.ts +0 -18
  413. package/react/parser/index.js +0 -109
  414. package/react/parser/index.js.map +0 -1
  415. package/testing/matchers/toEmitApolloQueryResult.d.ts +0 -8
  416. package/testing/matchers/toEmitApolloQueryResult.js +0 -36
  417. package/testing/matchers/toEmitApolloQueryResult.js.map +0 -1
  418. package/testing/matchers/toEmitFetchResult.d.ts +0 -8
  419. package/testing/matchers/toEmitFetchResult.js +0 -36
  420. package/testing/matchers/toEmitFetchResult.js.map +0 -1
  421. package/testing/matchers/toEmitMatchedValue.d.ts +0 -7
  422. package/testing/matchers/toEmitMatchedValue.js +0 -36
  423. package/testing/matchers/toEmitMatchedValue.js.map +0 -1
  424. package/testing/matchers/toEmitStrictTyped.d.ts +0 -7
  425. package/testing/matchers/toEmitStrictTyped.js.map +0 -1
  426. package/testing/matchers/toEmitValue.d.ts +0 -4
  427. package/testing/matchers/toEmitValue.js +0 -37
  428. package/testing/matchers/toEmitValue.js.map +0 -1
  429. package/testing/matchers/toEmitValueStrict.js +0 -42
  430. package/testing/matchers/toEmitValueStrict.js.map +0 -1
  431. package/testing/matchers/toEqualApolloQueryResult.d.ts +0 -6
  432. package/testing/matchers/toEqualApolloQueryResult.js +0 -20
  433. package/testing/matchers/toEqualApolloQueryResult.js.map +0 -1
  434. package/testing/matchers/toEqualFetchResult.d.ts +0 -4
  435. package/testing/matchers/toEqualFetchResult.js +0 -20
  436. package/testing/matchers/toEqualFetchResult.js.map +0 -1
  437. package/testing/matchers/toEqualLazyQueryResult.d.ts +0 -10
  438. package/testing/matchers/toEqualLazyQueryResult.js +0 -36
  439. package/testing/matchers/toEqualLazyQueryResult.js.map +0 -1
  440. package/testing/matchers/toEqualQueryResult.d.ts +0 -9
  441. package/testing/matchers/toEqualQueryResult.js +0 -35
  442. package/testing/matchers/toEqualQueryResult.js.map +0 -1
  443. package/testing/matchers/toEqualStrictTyped.d.ts +0 -3
  444. package/utilities/types/TODO.d.ts +0 -3
  445. package/utilities/types/TODO.js +0 -2
  446. package/utilities/types/TODO.js.map +0 -1
@@ -6,6 +6,7 @@ const {
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
7
  exports.QueryManager = void 0;
8
8
  const trie_1 = require("@wry/trie");
9
+ const graphql_1 = require("graphql");
9
10
  const rxjs_1 = require("rxjs");
10
11
  const cache_1 = require("@apollo/client/cache");
11
12
  const errors_1 = require("@apollo/client/errors");
@@ -95,15 +96,16 @@ class QueryManager {
95
96
  this.queries.forEach((_info, queryId) => {
96
97
  this.removeQuery(queryId);
97
98
  });
98
- this.cancelPendingFetches((0, invariant_1.newInvariantError)(68));
99
+ this.cancelPendingFetches((0, invariant_1.newInvariantError)(70));
99
100
  }
100
101
  cancelPendingFetches(error) {
101
102
  this.fetchCancelFns.forEach((cancel) => cancel(error));
102
103
  this.fetchCancelFns.clear();
103
104
  }
104
105
  async mutate({ mutation, variables, optimisticResponse, updateQueries, refetchQueries = [], awaitRefetchQueries = false, update: updateWithProxyFn, onQueryUpdated, fetchPolicy = this.defaultOptions.mutate?.fetchPolicy || "network-only", errorPolicy = this.defaultOptions.mutate?.errorPolicy || "none", keepRootFields, context, }) {
105
- (0, invariant_1.invariant)(mutation, 69);
106
- (0, invariant_1.invariant)(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 70);
106
+ (0, invariant_1.invariant)(mutation, 71);
107
+ (0, utilities_1.checkDocument)(mutation, graphql_1.OperationTypeNode.MUTATION);
108
+ (0, invariant_1.invariant)(fetchPolicy === "network-only" || fetchPolicy === "no-cache", 72);
107
109
  const mutationId = this.generateMutationId();
108
110
  mutation = this.cache.transformForLink(this.transform(mutation));
109
111
  const { hasClientExports } = this.getDocumentInfo(mutation);
@@ -136,10 +138,10 @@ class QueryManager {
136
138
  ...context,
137
139
  optimisticResponse: isOptimistic ? optimisticResponse : void 0,
138
140
  }, variables, {}, false)
139
- .pipe((0, rxjs_1.mergeMap)((result) => {
141
+ .pipe(validateDidEmitValue(), (0, rxjs_1.mergeMap)((result) => {
140
142
  const hasErrors = (0, utilities_4.graphQLResultHasError)(result);
141
143
  if (hasErrors && errorPolicy === "none") {
142
- throw new errors_1.CombinedGraphQLErrors((0, utilities_4.getGraphQLErrorsFromResult)(result));
144
+ throw new errors_1.CombinedGraphQLErrors(result);
143
145
  }
144
146
  if (mutationStoreValue) {
145
147
  mutationStoreValue.loading = false;
@@ -187,7 +189,7 @@ class QueryManager {
187
189
  }),
188
190
  };
189
191
  if ((0, utilities_4.graphQLResultHasError)(storeResult)) {
190
- result.error = new errors_1.CombinedGraphQLErrors((0, utilities_4.getGraphQLErrorsFromResult)(storeResult));
192
+ result.error = new errors_1.CombinedGraphQLErrors(storeResult);
191
193
  }
192
194
  if (storeResult.extensions) {
193
195
  result.extensions = storeResult.extensions;
@@ -401,7 +403,11 @@ class QueryManager {
401
403
  return true;
402
404
  }
403
405
  fetchQuery(queryId, options, networkStatus) {
404
- return (0, rxjs_1.lastValueFrom)(this.fetchObservableWithInfo(queryId, options, networkStatus).observable, { defaultValue: undefined });
406
+ return (0, rxjs_1.lastValueFrom)(this.fetchObservableWithInfo(queryId, options, networkStatus).observable.pipe((0, rxjs_1.map)(internal_1.toQueryResult)), {
407
+ // This default is needed when a `standby` fetch policy is used to avoid
408
+ // an EmptyError from rejecting this promise.
409
+ defaultValue: { data: undefined },
410
+ });
405
411
  }
406
412
  transform(document) {
407
413
  return this.documentTransform.transformDocument(document);
@@ -453,6 +459,7 @@ class QueryManager {
453
459
  };
454
460
  }
455
461
  watchQuery(options) {
462
+ (0, utilities_1.checkDocument)(options.query, graphql_1.OperationTypeNode.QUERY);
456
463
  const query = this.transform(options.query);
457
464
  // assign variable default values if supplied
458
465
  // NOTE: We don't modify options.query here with the transformed query to
@@ -474,31 +481,23 @@ class QueryManager {
474
481
  this.queries.set(observable.queryId, queryInfo);
475
482
  // We give queryInfo the transformed query to ensure the first cache diff
476
483
  // uses the transformed query instead of the raw query
477
- queryInfo.init({
478
- document: query,
479
- observableQuery: observable,
480
- variables: observable.variables,
481
- });
484
+ queryInfo.init({ document: query, variables: observable.variables });
485
+ queryInfo.setObservableQuery(observable);
482
486
  return observable;
483
487
  }
484
- // TODO: catch `EmptyError` and rethrow as network error if `complete`
485
- // notification is emitted without a value.
486
488
  query(options, queryId = this.generateQueryId()) {
487
- (0, invariant_1.invariant)(options.query, 71);
488
- (0, invariant_1.invariant)(options.query.kind === "Document", 72);
489
- (0, invariant_1.invariant)(!options.returnPartialData, 73);
490
- (0, invariant_1.invariant)(!options.pollInterval, 74);
489
+ (0, utilities_1.checkDocument)(options.query, graphql_1.OperationTypeNode.QUERY);
491
490
  const query = this.transform(options.query);
492
491
  return this.fetchQuery(queryId, { ...options, query })
493
- .then((result) => result && {
494
- ...result,
492
+ .then((value) => ({
493
+ ...value,
495
494
  data: this.maskOperation({
496
495
  document: query,
497
- data: result.data,
496
+ data: value?.data,
498
497
  fetchPolicy: options.fetchPolicy,
499
498
  id: queryId,
500
499
  }),
501
- })
500
+ }))
502
501
  .finally(() => this.stopQuery(queryId));
503
502
  }
504
503
  queryIdCounter = 1;
@@ -521,7 +520,7 @@ class QueryManager {
521
520
  // depend on values that previously existed in the data portion of the
522
521
  // store. So, we cancel the promises and observers that we have issued
523
522
  // so far and not yet resolved (in the case of queries).
524
- this.cancelPendingFetches((0, invariant_1.newInvariantError)(75));
523
+ this.cancelPendingFetches((0, invariant_1.newInvariantError)(73));
525
524
  this.queries.forEach((queryInfo) => {
526
525
  if (queryInfo.observableQuery) {
527
526
  // Set loading to true so listeners don't trigger unless they want
@@ -609,10 +608,10 @@ class QueryManager {
609
608
  if (!included) {
610
609
  const queryName = queryNames.get(nameOrQueryString);
611
610
  if (queryName) {
612
- __DEV__ && invariant_1.invariant.warn(76, queryName);
611
+ __DEV__ && invariant_1.invariant.warn(74, queryName);
613
612
  }
614
613
  else {
615
- __DEV__ && invariant_1.invariant.warn(77);
614
+ __DEV__ && invariant_1.invariant.warn(75);
616
615
  }
617
616
  }
618
617
  });
@@ -639,6 +638,7 @@ class QueryManager {
639
638
  startGraphQLSubscription(options) {
640
639
  let { query, variables } = options;
641
640
  const { fetchPolicy, errorPolicy = "none", context = {}, extensions = {}, } = options;
641
+ (0, utilities_1.checkDocument)(query, graphql_1.OperationTypeNode.SUBSCRIPTION);
642
642
  query = this.transform(query);
643
643
  variables = this.getVariables(query, variables);
644
644
  const makeObservable = (variables) => this.getObservableFromLink(query, context, variables, extensions).pipe((0, rxjs_1.map)((rawResult) => {
@@ -659,7 +659,7 @@ class QueryManager {
659
659
  data: rawResult.data ?? undefined,
660
660
  };
661
661
  if ((0, utilities_4.graphQLResultHasError)(rawResult)) {
662
- result.error = new errors_1.CombinedGraphQLErrors(rawResult.errors);
662
+ result.error = new errors_1.CombinedGraphQLErrors(rawResult);
663
663
  }
664
664
  else if ((0, errors_1.graphQLResultHasProtocolErrors)(rawResult)) {
665
665
  result.error = rawResult.extensions[errors_2.PROTOCOL_ERRORS_SYMBOL];
@@ -795,7 +795,7 @@ class QueryManager {
795
795
  queryInfo.resetLastWrite();
796
796
  queryInfo.reset();
797
797
  // Throwing here effectively calls observer.error.
798
- throw new errors_1.CombinedGraphQLErrors(graphQLErrors);
798
+ throw new errors_1.CombinedGraphQLErrors(result);
799
799
  }
800
800
  // Use linkDocument rather than queryInfo.document so the
801
801
  // operation/fragments used to write the result are the same as the
@@ -816,7 +816,7 @@ class QueryManager {
816
816
  aqr.data = void 0;
817
817
  }
818
818
  if (hasErrors && errorPolicy !== "ignore") {
819
- aqr.error = new errors_1.CombinedGraphQLErrors(graphQLErrors);
819
+ aqr.error = new errors_1.CombinedGraphQLErrors(result);
820
820
  aqr.networkStatus = networkStatus_js_1.NetworkStatus.error;
821
821
  }
822
822
  return aqr;
@@ -1053,7 +1053,7 @@ class QueryManager {
1053
1053
  !(0, utilities_3.isFullyUnmaskedOperation)(document) &&
1054
1054
  !this.noCacheWarningsByQueryId.has(operationId)) {
1055
1055
  this.noCacheWarningsByQueryId.add(operationId);
1056
- __DEV__ && invariant_1.invariant.warn(78, (0, utilities_4.getOperationName)(document) ??
1056
+ __DEV__ && invariant_1.invariant.warn(76, (0, utilities_4.getOperationName)(document) ??
1057
1057
  `Unnamed ${operationType ?? "operation"}`);
1058
1058
  }
1059
1059
  }
@@ -1143,7 +1143,7 @@ class QueryManager {
1143
1143
  context,
1144
1144
  fetchPolicy,
1145
1145
  errorPolicy,
1146
- });
1146
+ }).pipe(validateDidEmitValue());
1147
1147
  switch (fetchPolicy) {
1148
1148
  default:
1149
1149
  case "cache-first": {
@@ -1233,4 +1233,15 @@ function maybeWrapError(error) {
1233
1233
  }
1234
1234
  return new errors_1.UnconventionalError(error);
1235
1235
  }
1236
+ function validateDidEmitValue() {
1237
+ let didEmitValue = false;
1238
+ return (0, rxjs_1.tap)({
1239
+ next() {
1240
+ didEmitValue = true;
1241
+ },
1242
+ complete() {
1243
+ (0, invariant_1.invariant)(didEmitValue, 77);
1244
+ },
1245
+ });
1246
+ }
1236
1247
  //# sourceMappingURL=QueryManager.cjs.map