@apollo/client 4.3.0-alpha.0 → 4.3.0-alpha.10

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 (392) hide show
  1. package/CHANGELOG.md +490 -0
  2. package/README.md +3 -7
  3. package/__cjs/cache/core/Scalar.cjs +36 -0
  4. package/__cjs/cache/core/Scalar.cjs.map +1 -0
  5. package/__cjs/cache/core/Scalar.d.cts +20 -0
  6. package/__cjs/cache/core/cache.cjs +32 -1
  7. package/__cjs/cache/core/cache.cjs.map +1 -1
  8. package/__cjs/cache/core/cache.d.cts +89 -6
  9. package/__cjs/cache/core/types/Cache.d.cts +25 -0
  10. package/__cjs/cache/index.cjs +3 -1
  11. package/__cjs/cache/index.cjs.map +1 -1
  12. package/__cjs/cache/index.d.cts +3 -2
  13. package/__cjs/cache/inmemory/entityStore.cjs +48 -5
  14. package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
  15. package/__cjs/cache/inmemory/entityStore.d.cts +3 -0
  16. package/__cjs/cache/inmemory/helpers.d.cts +9 -1
  17. package/__cjs/cache/inmemory/inMemoryCache.cjs +83 -4
  18. package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
  19. package/__cjs/cache/inmemory/inMemoryCache.d.cts +44 -5
  20. package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
  21. package/__cjs/cache/inmemory/policies.cjs +35 -6
  22. package/__cjs/cache/inmemory/policies.cjs.map +1 -1
  23. package/__cjs/cache/inmemory/policies.d.cts +4 -1
  24. package/__cjs/cache/inmemory/readFromStore.cjs +490 -49
  25. package/__cjs/cache/inmemory/readFromStore.cjs.map +1 -1
  26. package/__cjs/cache/inmemory/readFromStore.d.cts +11 -2
  27. package/__cjs/cache/inmemory/types.d.cts +29 -4
  28. package/__cjs/cache/inmemory/writeToStore.cjs +6 -6
  29. package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
  30. package/__cjs/core/ApolloClient.cjs +37 -38
  31. package/__cjs/core/ApolloClient.cjs.map +1 -1
  32. package/__cjs/core/ApolloClient.d.cts +44 -10
  33. package/__cjs/core/ObservableQuery.cjs +228 -76
  34. package/__cjs/core/ObservableQuery.cjs.map +1 -1
  35. package/__cjs/core/ObservableQuery.d.cts +16 -8
  36. package/__cjs/core/QueryInfo.cjs +178 -190
  37. package/__cjs/core/QueryInfo.cjs.map +1 -1
  38. package/__cjs/core/QueryInfo.d.cts +17 -22
  39. package/__cjs/core/QueryManager.cjs +88 -59
  40. package/__cjs/core/QueryManager.cjs.map +1 -1
  41. package/__cjs/core/QueryManager.d.cts +1 -3
  42. package/__cjs/core/RefetchEventManager.cjs +3 -3
  43. package/__cjs/core/dataStateErrorCache.cjs +12 -0
  44. package/__cjs/core/dataStateErrorCache.cjs.map +1 -0
  45. package/__cjs/core/dataStateErrorCache.d.cts +3 -0
  46. package/__cjs/core/index.cjs +2 -1
  47. package/__cjs/core/index.cjs.map +1 -1
  48. package/__cjs/core/index.d.cts +4 -3
  49. package/__cjs/core/types.d.cts +12 -6
  50. package/__cjs/incremental/GraphQLCodegenIncremental.cjs +3 -0
  51. package/__cjs/incremental/GraphQLCodegenIncremental.cjs.map +1 -0
  52. package/__cjs/incremental/GraphQLCodegenIncremental.d.cts +55 -0
  53. package/__cjs/incremental/handlers/defer20220824.cjs.map +1 -1
  54. package/__cjs/incremental/handlers/defer20220824.d.cts +2 -4
  55. package/__cjs/incremental/handlers/graphql17Alpha9.cjs +47 -16
  56. package/__cjs/incremental/handlers/graphql17Alpha9.cjs.map +1 -1
  57. package/__cjs/incremental/handlers/graphql17Alpha9.d.cts +29 -6
  58. package/__cjs/incremental/handlers/notImplemented.cjs +1 -1
  59. package/__cjs/incremental/index.cjs.map +1 -1
  60. package/__cjs/incremental/index.d.cts +1 -0
  61. package/__cjs/incremental/internal/types.cjs +3 -0
  62. package/__cjs/incremental/internal/types.cjs.map +1 -0
  63. package/__cjs/incremental/internal/types.d.cts +17 -0
  64. package/__cjs/incremental/types.d.cts +55 -4
  65. package/__cjs/invariantErrorCodes.cjs +167 -112
  66. package/__cjs/link/core/ApolloLink.cjs +3 -3
  67. package/__cjs/link/http/checkFetcher.cjs +1 -1
  68. package/__cjs/link/http/parseAndCheckHttpResponse.cjs +2 -2
  69. package/__cjs/link/http/parseAndCheckHttpResponse.cjs.map +1 -1
  70. package/__cjs/link/persisted-queries/index.cjs +2 -2
  71. package/__cjs/link/ws/index.cjs +1 -1
  72. package/__cjs/local-state/LocalState.cjs +11 -11
  73. package/__cjs/masking/internal/types.d.cts +1 -2
  74. package/__cjs/masking/maskDefinition.cjs +2 -2
  75. package/__cjs/masking/maskFragment.cjs +2 -2
  76. package/__cjs/masking/maskOperation.cjs +1 -1
  77. package/__cjs/masking/utils.cjs +3 -3
  78. package/__cjs/react/context/ApolloContext.cjs +1 -1
  79. package/__cjs/react/context/ApolloProvider.cjs +1 -1
  80. package/__cjs/react/hooks/internal/validateSuspenseHookOptions.cjs +2 -2
  81. package/__cjs/react/hooks/useApolloClient.cjs +1 -1
  82. package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
  83. package/__cjs/react/hooks/useBackgroundQuery.d.cts +100 -47
  84. package/__cjs/react/hooks/useLazyQuery.cjs +2 -2
  85. package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
  86. package/__cjs/react/hooks/useLazyQuery.d.cts +39 -33
  87. package/__cjs/react/hooks/useLoadableQuery.cjs +2 -2
  88. package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
  89. package/__cjs/react/hooks/useLoadableQuery.d.cts +23 -15
  90. package/__cjs/react/hooks/useMutation.cjs.map +1 -1
  91. package/__cjs/react/hooks/useMutation.d.cts +10 -7
  92. package/__cjs/react/hooks/useQuery.cjs.map +1 -1
  93. package/__cjs/react/hooks/useQuery.d.cts +74 -32
  94. package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
  95. package/__cjs/react/hooks/useSubscription.cjs +1 -1
  96. package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
  97. package/__cjs/react/hooks/useSuspenseQuery.d.cts +83 -34
  98. package/__cjs/react/hooks/useSyncExternalStore.cjs +1 -1
  99. package/__cjs/react/internal/cache/QueryReference.cjs +1 -1
  100. package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
  101. package/__cjs/react/internal/types.d.cts +14 -3
  102. package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
  103. package/__cjs/react/query-preloader/createQueryPreloader.d.cts +20 -5
  104. package/__cjs/react/ssr/prerenderStatic.cjs +2 -2
  105. package/__cjs/react/types/deprecated.d.cts +5 -4
  106. package/__cjs/testing/core/mocking/mockLink.cjs +25 -5
  107. package/__cjs/testing/core/mocking/mockLink.cjs.map +1 -1
  108. package/__cjs/testing/core/mocking/mockLink.d.cts +1 -2
  109. package/__cjs/utilities/caching/sizes.cjs.map +1 -1
  110. package/__cjs/utilities/caching/sizes.d.cts +39 -1
  111. package/__cjs/utilities/graphql/DocumentTransform.cjs +1 -1
  112. package/__cjs/utilities/index.cjs.map +1 -1
  113. package/__cjs/utilities/index.d.cts +1 -0
  114. package/__cjs/utilities/internal/StreamArrayState.cjs +27 -0
  115. package/__cjs/utilities/internal/StreamArrayState.cjs.map +1 -0
  116. package/__cjs/utilities/internal/StreamArrayState.d.cts +12 -0
  117. package/__cjs/utilities/internal/addDeferFragmentLabels.cjs +33 -0
  118. package/__cjs/utilities/internal/addDeferFragmentLabels.cjs.map +1 -0
  119. package/__cjs/utilities/internal/addDeferFragmentLabels.d.cts +3 -0
  120. package/__cjs/utilities/internal/capitalize.cjs +12 -0
  121. package/__cjs/utilities/internal/capitalize.cjs.map +1 -0
  122. package/__cjs/utilities/internal/capitalize.d.cts +7 -0
  123. package/__cjs/utilities/internal/coerceScalarFieldsToParsed.cjs +69 -0
  124. package/__cjs/utilities/internal/coerceScalarFieldsToParsed.cjs.map +1 -0
  125. package/__cjs/utilities/internal/coerceScalarFieldsToParsed.d.cts +9 -0
  126. package/__cjs/utilities/internal/constants.cjs +20 -1
  127. package/__cjs/utilities/internal/constants.cjs.map +1 -1
  128. package/__cjs/utilities/internal/constants.d.cts +19 -0
  129. package/__cjs/utilities/internal/getDirectiveArgValue.cjs +19 -0
  130. package/__cjs/utilities/internal/getDirectiveArgValue.cjs.map +1 -0
  131. package/__cjs/utilities/internal/getDirectiveArgValue.d.cts +9 -0
  132. package/__cjs/utilities/internal/getFragmentDefinition.cjs +3 -3
  133. package/__cjs/utilities/internal/getFragmentFromSelection.cjs +2 -2
  134. package/__cjs/utilities/internal/getFragmentFromSelection.cjs.map +1 -1
  135. package/__cjs/utilities/internal/getFragmentQueryDocument.cjs +2 -2
  136. package/__cjs/utilities/internal/getMainDefinition.cjs +1 -1
  137. package/__cjs/utilities/internal/getMemoryInternals.cjs +6 -0
  138. package/__cjs/utilities/internal/getMemoryInternals.cjs.map +1 -1
  139. package/__cjs/utilities/internal/getMemoryInternals.d.cts +4 -0
  140. package/__cjs/utilities/internal/getQueryDefinition.cjs +1 -1
  141. package/__cjs/utilities/internal/getUnwrappedType.cjs +20 -0
  142. package/__cjs/utilities/internal/getUnwrappedType.cjs.map +1 -0
  143. package/__cjs/utilities/internal/getUnwrappedType.d.cts +8 -0
  144. package/__cjs/utilities/internal/index.cjs +25 -2
  145. package/__cjs/utilities/internal/index.cjs.map +1 -1
  146. package/__cjs/utilities/internal/index.d.cts +16 -1
  147. package/__cjs/utilities/internal/isDeferredFragment.cjs +38 -0
  148. package/__cjs/utilities/internal/isDeferredFragment.cjs.map +1 -0
  149. package/__cjs/utilities/internal/isDeferredFragment.d.cts +9 -0
  150. package/__cjs/utilities/internal/isStreamField.cjs +37 -0
  151. package/__cjs/utilities/internal/isStreamField.cjs.map +1 -0
  152. package/__cjs/utilities/internal/isStreamField.d.cts +9 -0
  153. package/__cjs/utilities/internal/isTypenameField.cjs +7 -0
  154. package/__cjs/utilities/internal/isTypenameField.cjs.map +1 -0
  155. package/__cjs/utilities/internal/isTypenameField.d.cts +3 -0
  156. package/__cjs/utilities/internal/makeStreamInfoTrie.cjs +17 -0
  157. package/__cjs/utilities/internal/makeStreamInfoTrie.cjs.map +1 -0
  158. package/__cjs/utilities/internal/makeStreamInfoTrie.d.cts +8 -0
  159. package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs +1 -1
  160. package/__cjs/utilities/internal/shouldInclude.cjs +4 -4
  161. package/__cjs/utilities/internal/toDiffWithDataState.cjs +20 -0
  162. package/__cjs/utilities/internal/toDiffWithDataState.cjs.map +1 -0
  163. package/__cjs/utilities/internal/toDiffWithDataState.d.cts +8 -0
  164. package/__cjs/utilities/internal/types/DeferInfo.cjs +3 -0
  165. package/__cjs/utilities/internal/types/DeferInfo.cjs.map +1 -0
  166. package/__cjs/utilities/internal/types/DeferInfo.d.cts +10 -0
  167. package/__cjs/utilities/internal/types/Exact.cjs +3 -0
  168. package/__cjs/utilities/internal/types/Exact.cjs.map +1 -0
  169. package/__cjs/utilities/internal/types/Exact.d.cts +2 -0
  170. package/__cjs/utilities/internal/types/IsLooselyEqual.cjs +3 -0
  171. package/__cjs/utilities/internal/types/IsLooselyEqual.cjs.map +1 -0
  172. package/__cjs/utilities/internal/types/IsLooselyEqual.d.cts +10 -0
  173. package/__cjs/utilities/internal/types/IsNeverish.cjs +3 -0
  174. package/__cjs/utilities/internal/types/IsNeverish.cjs.map +1 -0
  175. package/__cjs/utilities/internal/types/IsNeverish.d.cts +4 -0
  176. package/__cjs/utilities/internal/types/StreamInfoTrie.d.cts +2 -0
  177. package/__cjs/utilities/internal/valueToObjectRepresentation.cjs +1 -1
  178. package/__cjs/utilities/policies/pagination.cjs.map +1 -1
  179. package/__cjs/utilities/policies/pagination.d.cts +1 -1
  180. package/__cjs/utilities/subscriptions/relay/index.cjs +1 -0
  181. package/__cjs/utilities/subscriptions/relay/index.cjs.map +1 -1
  182. package/__cjs/version.cjs +1 -1
  183. package/__cjs/version.cjs.map +1 -1
  184. package/cache/core/Scalar.d.ts +20 -0
  185. package/cache/core/Scalar.js +32 -0
  186. package/cache/core/Scalar.js.map +1 -0
  187. package/cache/core/cache.d.ts +89 -6
  188. package/cache/core/cache.js +33 -2
  189. package/cache/core/cache.js.map +1 -1
  190. package/cache/core/types/Cache.d.ts +25 -0
  191. package/cache/core/types/Cache.js.map +1 -1
  192. package/cache/index.d.ts +3 -2
  193. package/cache/index.js +1 -0
  194. package/cache/index.js.map +1 -1
  195. package/cache/inmemory/entityStore.d.ts +3 -0
  196. package/cache/inmemory/entityStore.js +49 -6
  197. package/cache/inmemory/entityStore.js.map +1 -1
  198. package/cache/inmemory/helpers.d.ts +9 -1
  199. package/cache/inmemory/inMemoryCache.d.ts +44 -5
  200. package/cache/inmemory/inMemoryCache.js +84 -5
  201. package/cache/inmemory/inMemoryCache.js.map +1 -1
  202. package/cache/inmemory/key-extractor.js +1 -1
  203. package/cache/inmemory/policies.d.ts +4 -1
  204. package/cache/inmemory/policies.js +35 -6
  205. package/cache/inmemory/policies.js.map +1 -1
  206. package/cache/inmemory/readFromStore.d.ts +11 -2
  207. package/cache/inmemory/readFromStore.js +486 -49
  208. package/cache/inmemory/readFromStore.js.map +1 -1
  209. package/cache/inmemory/types.d.ts +30 -5
  210. package/cache/inmemory/types.js.map +1 -1
  211. package/cache/inmemory/writeToStore.js +7 -7
  212. package/cache/inmemory/writeToStore.js.map +1 -1
  213. package/core/ApolloClient.d.ts +44 -10
  214. package/core/ApolloClient.js +37 -38
  215. package/core/ApolloClient.js.map +1 -1
  216. package/core/ObservableQuery.d.ts +16 -8
  217. package/core/ObservableQuery.js +225 -77
  218. package/core/ObservableQuery.js.map +1 -1
  219. package/core/QueryInfo.d.ts +18 -23
  220. package/core/QueryInfo.js +174 -190
  221. package/core/QueryInfo.js.map +1 -1
  222. package/core/QueryManager.d.ts +1 -3
  223. package/core/QueryManager.js +89 -60
  224. package/core/QueryManager.js.map +1 -1
  225. package/core/RefetchEventManager.js +3 -3
  226. package/core/dataStateErrorCache.d.ts +3 -0
  227. package/core/dataStateErrorCache.js +9 -0
  228. package/core/dataStateErrorCache.js.map +1 -0
  229. package/core/index.d.ts +4 -3
  230. package/core/index.js +1 -1
  231. package/core/index.js.map +1 -1
  232. package/core/types.d.ts +12 -6
  233. package/core/types.js.map +1 -1
  234. package/incremental/GraphQLCodegenIncremental.d.ts +55 -0
  235. package/incremental/GraphQLCodegenIncremental.js +2 -0
  236. package/incremental/GraphQLCodegenIncremental.js.map +1 -0
  237. package/incremental/handlers/defer20220824.d.ts +2 -4
  238. package/incremental/handlers/defer20220824.js.map +1 -1
  239. package/incremental/handlers/graphql17Alpha9.d.ts +29 -6
  240. package/incremental/handlers/graphql17Alpha9.js +48 -17
  241. package/incremental/handlers/graphql17Alpha9.js.map +1 -1
  242. package/incremental/handlers/notImplemented.js +1 -1
  243. package/incremental/index.d.ts +1 -0
  244. package/incremental/index.js.map +1 -1
  245. package/incremental/internal/types.d.ts +17 -0
  246. package/incremental/internal/types.js +2 -0
  247. package/incremental/internal/types.js.map +1 -0
  248. package/incremental/types.d.ts +55 -4
  249. package/incremental/types.js.map +1 -1
  250. package/invariantErrorCodes.js +167 -112
  251. package/link/core/ApolloLink.js +3 -3
  252. package/link/http/checkFetcher.js +1 -1
  253. package/link/http/parseAndCheckHttpResponse.js +2 -2
  254. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  255. package/link/persisted-queries/index.js +2 -2
  256. package/link/ws/index.js +1 -1
  257. package/local-state/LocalState.js +11 -11
  258. package/masking/internal/types.d.ts +1 -2
  259. package/masking/internal/types.js.map +1 -1
  260. package/masking/maskDefinition.js +2 -2
  261. package/masking/maskFragment.js +2 -2
  262. package/masking/maskOperation.js +1 -1
  263. package/masking/utils.js +3 -3
  264. package/package.json +1 -1
  265. package/react/context/ApolloContext.js +1 -1
  266. package/react/context/ApolloProvider.js +1 -1
  267. package/react/hooks/internal/validateSuspenseHookOptions.js +2 -2
  268. package/react/hooks/useApolloClient.js +1 -1
  269. package/react/hooks/useBackgroundQuery.d.ts +100 -47
  270. package/react/hooks/useBackgroundQuery.js.map +1 -1
  271. package/react/hooks/useLazyQuery.d.ts +39 -33
  272. package/react/hooks/useLazyQuery.js +2 -2
  273. package/react/hooks/useLazyQuery.js.map +1 -1
  274. package/react/hooks/useLoadableQuery.d.ts +23 -15
  275. package/react/hooks/useLoadableQuery.js +2 -2
  276. package/react/hooks/useLoadableQuery.js.map +1 -1
  277. package/react/hooks/useMutation.d.ts +10 -7
  278. package/react/hooks/useMutation.js.map +1 -1
  279. package/react/hooks/useQuery.d.ts +74 -32
  280. package/react/hooks/useQuery.js.map +1 -1
  281. package/react/hooks/useQueryRefHandlers.js.map +1 -1
  282. package/react/hooks/useSubscription.js +1 -1
  283. package/react/hooks/useSuspenseQuery.d.ts +83 -34
  284. package/react/hooks/useSuspenseQuery.js.map +1 -1
  285. package/react/hooks/useSyncExternalStore.js +1 -1
  286. package/react/hooks-compiled/internal/validateSuspenseHookOptions.js +2 -2
  287. package/react/hooks-compiled/useApolloClient.js +1 -1
  288. package/react/hooks-compiled/useBackgroundQuery.d.ts +100 -47
  289. package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
  290. package/react/hooks-compiled/useLazyQuery.d.ts +39 -33
  291. package/react/hooks-compiled/useLazyQuery.js +2 -2
  292. package/react/hooks-compiled/useLazyQuery.js.map +1 -1
  293. package/react/hooks-compiled/useLoadableQuery.d.ts +23 -15
  294. package/react/hooks-compiled/useLoadableQuery.js +2 -2
  295. package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
  296. package/react/hooks-compiled/useMutation.d.ts +10 -7
  297. package/react/hooks-compiled/useMutation.js.map +1 -1
  298. package/react/hooks-compiled/useQuery.d.ts +74 -32
  299. package/react/hooks-compiled/useQuery.js.map +1 -1
  300. package/react/hooks-compiled/useQueryRefHandlers.js.map +1 -1
  301. package/react/hooks-compiled/useSubscription.js +1 -1
  302. package/react/hooks-compiled/useSuspenseQuery.d.ts +83 -34
  303. package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
  304. package/react/hooks-compiled/useSyncExternalStore.js +1 -1
  305. package/react/internal/cache/QueryReference.js +1 -1
  306. package/react/internal/cache/QueryReference.js.map +1 -1
  307. package/react/internal/types.d.ts +15 -4
  308. package/react/internal/types.js.map +1 -1
  309. package/react/query-preloader/createQueryPreloader.d.ts +20 -5
  310. package/react/query-preloader/createQueryPreloader.js.map +1 -1
  311. package/react/ssr/prerenderStatic.js +2 -2
  312. package/react/types/deprecated.d.ts +5 -4
  313. package/react/types/deprecated.js.map +1 -1
  314. package/testing/core/mocking/mockLink.d.ts +1 -2
  315. package/testing/core/mocking/mockLink.js +25 -5
  316. package/testing/core/mocking/mockLink.js.map +1 -1
  317. package/utilities/caching/sizes.d.ts +39 -1
  318. package/utilities/caching/sizes.js.map +1 -1
  319. package/utilities/graphql/DocumentTransform.js +1 -1
  320. package/utilities/index.d.ts +1 -0
  321. package/utilities/index.js.map +1 -1
  322. package/utilities/internal/StreamArrayState.d.ts +12 -0
  323. package/utilities/internal/StreamArrayState.js +23 -0
  324. package/utilities/internal/StreamArrayState.js.map +1 -0
  325. package/utilities/internal/addDeferFragmentLabels.d.ts +3 -0
  326. package/utilities/internal/addDeferFragmentLabels.js +30 -0
  327. package/utilities/internal/addDeferFragmentLabels.js.map +1 -0
  328. package/utilities/internal/capitalize.d.ts +7 -0
  329. package/utilities/internal/capitalize.js +9 -0
  330. package/utilities/internal/capitalize.js.map +1 -0
  331. package/utilities/internal/coerceScalarFieldsToParsed.d.ts +9 -0
  332. package/utilities/internal/coerceScalarFieldsToParsed.js +66 -0
  333. package/utilities/internal/coerceScalarFieldsToParsed.js.map +1 -0
  334. package/utilities/internal/constants.d.ts +19 -0
  335. package/utilities/internal/constants.js +19 -0
  336. package/utilities/internal/constants.js.map +1 -1
  337. package/utilities/internal/getDirectiveArgValue.d.ts +9 -0
  338. package/utilities/internal/getDirectiveArgValue.js +16 -0
  339. package/utilities/internal/getDirectiveArgValue.js.map +1 -0
  340. package/utilities/internal/getFragmentDefinition.js +3 -3
  341. package/utilities/internal/getFragmentFromSelection.js +2 -2
  342. package/utilities/internal/getFragmentFromSelection.js.map +1 -1
  343. package/utilities/internal/getFragmentQueryDocument.js +2 -2
  344. package/utilities/internal/getMainDefinition.js +1 -1
  345. package/utilities/internal/getMemoryInternals.d.ts +4 -0
  346. package/utilities/internal/getMemoryInternals.js +6 -0
  347. package/utilities/internal/getMemoryInternals.js.map +1 -1
  348. package/utilities/internal/getQueryDefinition.js +1 -1
  349. package/utilities/internal/getUnwrappedType.d.ts +8 -0
  350. package/utilities/internal/getUnwrappedType.js +17 -0
  351. package/utilities/internal/getUnwrappedType.js.map +1 -0
  352. package/utilities/internal/index.d.ts +16 -1
  353. package/utilities/internal/index.js +12 -1
  354. package/utilities/internal/index.js.map +1 -1
  355. package/utilities/internal/isDeferredFragment.d.ts +9 -0
  356. package/utilities/internal/isDeferredFragment.js +35 -0
  357. package/utilities/internal/isDeferredFragment.js.map +1 -0
  358. package/utilities/internal/isStreamField.d.ts +9 -0
  359. package/utilities/internal/isStreamField.js +34 -0
  360. package/utilities/internal/isStreamField.js.map +1 -0
  361. package/utilities/internal/isTypenameField.d.ts +3 -0
  362. package/utilities/internal/isTypenameField.js +4 -0
  363. package/utilities/internal/isTypenameField.js.map +1 -0
  364. package/utilities/internal/makeStreamInfoTrie.d.ts +8 -0
  365. package/utilities/internal/makeStreamInfoTrie.js +14 -0
  366. package/utilities/internal/makeStreamInfoTrie.js.map +1 -0
  367. package/utilities/internal/removeDirectivesFromDocument.js +1 -1
  368. package/utilities/internal/shouldInclude.js +4 -4
  369. package/utilities/internal/toDiffWithDataState.d.ts +8 -0
  370. package/utilities/internal/toDiffWithDataState.js +17 -0
  371. package/utilities/internal/toDiffWithDataState.js.map +1 -0
  372. package/utilities/internal/types/DeferInfo.d.ts +10 -0
  373. package/utilities/internal/types/DeferInfo.js +2 -0
  374. package/utilities/internal/types/DeferInfo.js.map +1 -0
  375. package/utilities/internal/types/Exact.d.ts +2 -0
  376. package/utilities/internal/types/Exact.js +2 -0
  377. package/utilities/internal/types/Exact.js.map +1 -0
  378. package/utilities/internal/types/IsLooselyEqual.d.ts +10 -0
  379. package/utilities/internal/types/IsLooselyEqual.js +2 -0
  380. package/utilities/internal/types/IsLooselyEqual.js.map +1 -0
  381. package/utilities/internal/types/IsNeverish.d.ts +4 -0
  382. package/utilities/internal/types/IsNeverish.js +2 -0
  383. package/utilities/internal/types/IsNeverish.js.map +1 -0
  384. package/utilities/internal/types/StreamInfoTrie.d.ts +2 -0
  385. package/utilities/internal/types/StreamInfoTrie.js.map +1 -1
  386. package/utilities/internal/valueToObjectRepresentation.js +1 -1
  387. package/utilities/policies/pagination.d.ts +1 -1
  388. package/utilities/policies/pagination.js.map +1 -1
  389. package/utilities/subscriptions/relay/index.js +1 -0
  390. package/utilities/subscriptions/relay/index.js.map +1 -1
  391. package/version.js +1 -1
  392. package/version.js.map +1 -1
@@ -27,7 +27,7 @@ export class RefetchEventManager {
27
27
  }
28
28
  if (this.client) {
29
29
  if (__DEV__) {
30
- __DEV__ && invariant.warn(101);
30
+ __DEV__ && invariant.warn(104);
31
31
  }
32
32
  this.disconnect();
33
33
  }
@@ -96,13 +96,13 @@ export class RefetchEventManager {
96
96
  const [payload] = args;
97
97
  if (!this.client) {
98
98
  if (__DEV__) {
99
- __DEV__ && invariant.warn(102, source);
99
+ __DEV__ && invariant.warn(105, source);
100
100
  }
101
101
  return;
102
102
  }
103
103
  if (!this.hasSource(source)) {
104
104
  if (__DEV__) {
105
- __DEV__ && invariant.warn(103, source);
105
+ __DEV__ && invariant.warn(106, source);
106
106
  }
107
107
  return;
108
108
  }
@@ -0,0 +1,3 @@
1
+ import type { CombinedGraphQLErrors } from "@apollo/client/errors";
2
+ export declare const dataStateErrorCache: WeakMap<CombinedGraphQLErrors, "complete" | "streaming" | "partial" | "empty">;
3
+ //# sourceMappingURL=dataStateErrorCache.d.ts.map
@@ -0,0 +1,9 @@
1
+ // When working with an incremental result, errors in `@defer` fragments might
2
+ // bubble to the fragment boundary which leaves a hole in the data. When the
3
+ // `errorPolicy` is `"none"` we `throw` the constructed error so that it moves
4
+ // through the observable error flow. Because of this, we need a way to
5
+ // communicate the known dataState returned by QueryInfo to ObservableQuery.
6
+ // This ensures a "streaming" dataState can still be reported for errorPolicy:
7
+ // "none" queries.
8
+ export const dataStateErrorCache = new WeakMap();
9
+ //# sourceMappingURL=dataStateErrorCache.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dataStateErrorCache.js","sourceRoot":"","sources":["../../src/core/dataStateErrorCache.ts"],"names":[],"mappings":"AAIA,8EAA8E;AAC9E,4EAA4E;AAC5E,8EAA8E;AAC9E,uEAAuE;AACvE,4EAA4E;AAC5E,8EAA8E;AAC9E,kBAAkB;AAClB,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,OAAO,EAG3C,CAAC","sourcesContent":["import type { CombinedGraphQLErrors } from \"@apollo/client/errors\";\n\nimport type { DataState } from \"./types.js\";\n\n// When working with an incremental result, errors in `@defer` fragments might\n// bubble to the fragment boundary which leaves a hole in the data. When the\n// `errorPolicy` is `\"none\"` we `throw` the constructed error so that it moves\n// through the observable error flow. Because of this, we need a way to\n// communicate the known dataState returned by QueryInfo to ObservableQuery.\n// This ensures a \"streaming\" dataState can still be reported for errorPolicy:\n// \"none\" queries.\nexport const dataStateErrorCache = new WeakMap<\n CombinedGraphQLErrors,\n DataState<any>[\"dataState\"]\n>();\n"]}
package/core/index.d.ts CHANGED
@@ -8,8 +8,8 @@ export type { ErrorPolicy, FetchPolicy, MutationFetchPolicy, RefetchWritePolicy,
8
8
  export { NetworkStatus } from "./networkStatus.js";
9
9
  export type { DataState, DataValue, DefaultContext, ErrorLike, GetDataState, InternalRefetchQueriesInclude, InternalRefetchQueriesMap, InternalRefetchQueriesOptions, InternalRefetchQueriesResult, InternalRefetchQueryDescriptor, MutationQueryReducer, MutationQueryReducersMap, MutationUpdaterFunction, NormalizedExecutionResult, OnQueryUpdated, OperationVariables, RefetchEvents, RefetchOn, RefetchQueriesInclude, RefetchQueriesPromiseResults, RefetchQueryDescriptor, SubscriptionObservable, TypedDocumentNode, TypeOverrides, } from "./types.js";
10
10
  export { CombinedGraphQLErrors, CombinedProtocolErrors, LinkError, LocalStateError, ServerError, ServerParseError, UnconventionalError, } from "@apollo/client/errors";
11
- export type { ApolloReducerConfig, Cache, DiffQueryAgainstStoreOptions, FieldFunctionOptions, FieldMergeFunction, FieldPolicy, FieldReadFunction, IdGetter, IdGetterObj, InMemoryCacheConfig, MergeInfo, MergeTree, NormalizedCache, NormalizedCacheObject, OptimisticStoreItem, PossibleTypesMap, ReactiveVar, ReadMergeModifyContext, ReadQueryOptions, StoreValue, Transaction, TypePolicies, TypePolicy, WatchFragmentOptions, WatchFragmentResult, } from "@apollo/client/cache";
12
- export { ApolloCache, defaultDataIdFromObject, InMemoryCache, makeVar, MissingFieldError, } from "@apollo/client/cache";
11
+ export type { ApolloReducerConfig, Cache, DiffQueryAgainstStoreOptions, FieldFunctionOptions, FieldMergeFunction, FieldPolicy, FieldReadFunction, IdGetter, IdGetterObj, InMemoryCacheConfig, InputObjectConfig, InputObjectsOption, MergeInfo, MergeTree, NormalizedCache, NormalizedCacheObject, OptimisticStoreItem, PossibleTypesMap, ReactiveVar, ReadMergeModifyContext, ReadQueryOptions, StoreValue, Transaction, TypePolicies, TypePolicy, WatchFragmentOptions, WatchFragmentResult, } from "@apollo/client/cache";
12
+ export { ApolloCache, defaultDataIdFromObject, InMemoryCache, makeVar, MissingFieldError, Scalar, } from "@apollo/client/cache";
13
13
  export { ApolloLink, concat, empty, execute, from, split, } from "@apollo/client/link";
14
14
  export type { ApolloPayloadResult, DocumentNode, FetchResult, GraphQLRequest, Operation, RequestHandler, } from "@apollo/client/link";
15
15
  export { checkFetcher, createHttpLink, createSignalIfSupported, defaultPrinter, fallbackHttpConfig, HttpLink, parseAndCheckHttpResponse, rewriteURIForGET, selectHttpOptionsAndBody, selectHttpOptionsAndBodyInternal, selectURI, } from "@apollo/client/link/http";
@@ -23,6 +23,7 @@ export { disableExperimentalFragmentVariables, disableFragmentWarnings, enableEx
23
23
  export { build, version } from "../version.js";
24
24
  import type { DefaultOptionsParentObject, PossibleDefaultOptions } from "./defaultOptions.js";
25
25
  import type { QueryManager } from "./QueryManager.js";
26
+ import type { OverridableTypes } from "./types.js";
26
27
  import type { NextFetchPolicyContext } from "./watchQueryOptions.js";
27
28
  /**
28
29
  * @internal
@@ -30,6 +31,6 @@ import type { NextFetchPolicyContext } from "./watchQueryOptions.js";
30
31
  * @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
31
32
  */
32
33
  export declare namespace InternalTypes {
33
- export type { DefaultOptionsParentObject, NextFetchPolicyContext, PossibleDefaultOptions, QueryManager, };
34
+ export type { DefaultOptionsParentObject, NextFetchPolicyContext, OverridableTypes, PossibleDefaultOptions, QueryManager, };
34
35
  }
35
36
  //# sourceMappingURL=index.d.ts.map
package/core/index.js CHANGED
@@ -6,7 +6,7 @@ export { onlineSource } from "./refetchSources/onlineSource.js";
6
6
  export { windowFocusSource } from "./refetchSources/windowFocusSource.js";
7
7
  export { NetworkStatus } from "./networkStatus.js";
8
8
  export { CombinedGraphQLErrors, CombinedProtocolErrors, LinkError, LocalStateError, ServerError, ServerParseError, UnconventionalError, } from "@apollo/client/errors";
9
- export { ApolloCache, defaultDataIdFromObject, InMemoryCache, makeVar, MissingFieldError, } from "@apollo/client/cache";
9
+ export { ApolloCache, defaultDataIdFromObject, InMemoryCache, makeVar, MissingFieldError, Scalar, } from "@apollo/client/cache";
10
10
  /* Link */
11
11
  export { ApolloLink, concat, empty, execute, from, split, } from "@apollo/client/link";
12
12
  export { checkFetcher, createHttpLink, createSignalIfSupported, defaultPrinter, fallbackHttpConfig, HttpLink, parseAndCheckHttpResponse, rewriteURIForGET, selectHttpOptionsAndBody,
package/core/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mapp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;AACtE,qEAAqE;AACrE,4EAA4E;AAC5E,6BAA6B;AAC7B,OAAO,EACL,oCAAoC,EACpC,uBAAuB,EACvB,mCAAmC,EACnC,GAAG,EACH,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC","sourcesContent":["/* Core */\n\nexport type {\n ApolloClientOptions,\n ApolloQueryResult,\n DefaultOptions,\n DevtoolsOptions,\n MutateResult,\n MutationOptions,\n QueryOptions,\n RefetchQueriesOptions,\n RefetchQueriesResult,\n SubscribeToMoreOptions,\n SubscriptionOptions,\n WatchQueryOptions,\n} from \"./deprecated.js\";\nexport { ApolloClient } from \"./ApolloClient.js\";\nexport { ObservableQuery } from \"./ObservableQuery.js\";\nexport { RefetchEventManager } from \"./RefetchEventManager.js\";\nexport { onlineSource } from \"./refetchSources/onlineSource.js\";\nexport { windowFocusSource } from \"./refetchSources/windowFocusSource.js\";\nexport type {\n ErrorPolicy,\n FetchPolicy,\n MutationFetchPolicy,\n RefetchWritePolicy,\n SubscribeToMoreFunction,\n SubscribeToMoreUpdateQueryFn,\n UpdateQueryMapFn,\n UpdateQueryOptions,\n WatchQueryFetchPolicy,\n} from \"./watchQueryOptions.js\";\nexport { NetworkStatus } from \"./networkStatus.js\";\nexport type {\n DataState,\n DataValue,\n DefaultContext,\n ErrorLike,\n GetDataState,\n InternalRefetchQueriesInclude,\n InternalRefetchQueriesMap,\n InternalRefetchQueriesOptions,\n InternalRefetchQueriesResult,\n InternalRefetchQueryDescriptor,\n MutationQueryReducer,\n MutationQueryReducersMap,\n MutationUpdaterFunction,\n NormalizedExecutionResult,\n OnQueryUpdated,\n OperationVariables,\n RefetchEvents,\n RefetchOn,\n RefetchQueriesInclude,\n RefetchQueriesPromiseResults,\n RefetchQueryDescriptor,\n SubscriptionObservable,\n TypedDocumentNode,\n TypeOverrides,\n} from \"./types.js\";\nexport {\n CombinedGraphQLErrors,\n CombinedProtocolErrors,\n LinkError,\n LocalStateError,\n ServerError,\n ServerParseError,\n UnconventionalError,\n} from \"@apollo/client/errors\";\n/* Cache */\n\nexport type {\n ApolloReducerConfig,\n Cache,\n DiffQueryAgainstStoreOptions,\n FieldFunctionOptions,\n FieldMergeFunction,\n FieldPolicy,\n FieldReadFunction,\n IdGetter,\n IdGetterObj,\n InMemoryCacheConfig,\n MergeInfo,\n MergeTree,\n NormalizedCache,\n NormalizedCacheObject,\n OptimisticStoreItem,\n PossibleTypesMap,\n ReactiveVar,\n ReadMergeModifyContext,\n ReadQueryOptions,\n StoreValue,\n // All the exports (types) from ../cache, minus cacheSlot,\n // which we want to keep semi-private.\n Transaction,\n TypePolicies,\n TypePolicy,\n WatchFragmentOptions,\n WatchFragmentResult,\n} from \"@apollo/client/cache\";\n\nexport {\n ApolloCache,\n defaultDataIdFromObject,\n InMemoryCache,\n makeVar,\n MissingFieldError,\n} from \"@apollo/client/cache\";\n\n/* Link */\n\nexport {\n ApolloLink,\n concat,\n empty,\n execute,\n from,\n split,\n} from \"@apollo/client/link\";\nexport type {\n ApolloPayloadResult,\n DocumentNode,\n FetchResult,\n GraphQLRequest,\n Operation,\n RequestHandler,\n} from \"@apollo/client/link\";\n\nexport {\n checkFetcher,\n createHttpLink,\n createSignalIfSupported,\n defaultPrinter,\n fallbackHttpConfig,\n HttpLink,\n parseAndCheckHttpResponse,\n rewriteURIForGET,\n selectHttpOptionsAndBody,\n // TODO remove: needed by @apollo/client/link/batch-http but not public\n selectHttpOptionsAndBodyInternal,\n selectURI,\n} from \"@apollo/client/link/http\";\n\n/* Masking */\nexport type {\n FragmentType,\n MaybeMasked,\n Unmasked,\n} from \"@apollo/client/masking\";\n\n/* Utilities */\n\nexport type {\n DocumentTransformCacheKey,\n Reference,\n StoreObject,\n} from \"@apollo/client/utilities\";\nexport {\n DocumentTransform,\n /** @deprecated Please import `isNetworkRequestSettled` from `@apollo/client/utilities`. */\n isNetworkRequestSettled,\n isReference,\n Observable,\n} from \"@apollo/client/utilities\";\n\n/* Supporting */\n\n// The verbosity of invariant.{log,warn,error} can be controlled globally\n// by passing \"log\", \"warn\", \"error\", or \"silent\" to setVerbosity (\"log\" is the default).\n// Note that all invariant.* logging is hidden in production.\nexport { setVerbosity as setLogVerbosity } from \"@apollo/client/utilities/invariant\";\n\n// Note that importing `gql` by itself, then destructuring\n// additional properties separately before exporting, is intentional.\n// Due to the way the `graphql-tag` library is setup, certain bundlers\n// can't find the properties added to the exported `gql` function without\n// additional guidance (e.g. Rollup - see\n// https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module).\n// Instead of having people that are using bundlers with `@apollo/client` add\n// extra bundler config to help `graphql-tag` exports be found (which would be\n// awkward since they aren't importing `graphql-tag` themselves), this\n// workaround of pulling the extra properties off the `gql` function,\n// then re-exporting them separately, helps keeps bundlers happy without any\n// additional config changes.\nexport {\n disableExperimentalFragmentVariables,\n disableFragmentWarnings,\n enableExperimentalFragmentVariables,\n gql,\n resetCaches,\n} from \"graphql-tag\";\nexport { build, version } from \"../version.js\";\n\n// internal types\nimport type {\n DefaultOptionsParentObject,\n PossibleDefaultOptions,\n} from \"./defaultOptions.js\";\nimport type { QueryManager } from \"./QueryManager.js\";\nimport type { NextFetchPolicyContext } from \"./watchQueryOptions.js\";\n/** @internal */\nexport declare namespace InternalTypes {\n export type {\n DefaultOptionsParentObject,\n NextFetchPolicyContext,\n PossibleDefaultOptions,\n QueryManager,\n };\n}\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,UAAU;AAgBV,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAChE,OAAO,EAAE,iBAAiB,EAAE,MAAM,uCAAuC,CAAC;AAY1E,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AA2BnD,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,SAAS,EACT,eAAe,EACf,WAAW,EACX,gBAAgB,EAChB,mBAAmB,GACpB,MAAM,uBAAuB,CAAC;AAmC/B,OAAO,EACL,WAAW,EACX,uBAAuB,EACvB,aAAa,EACb,OAAO,EACP,iBAAiB,EACjB,MAAM,GACP,MAAM,sBAAsB,CAAC;AAE9B,UAAU;AAEV,OAAO,EACL,UAAU,EACV,MAAM,EACN,KAAK,EACL,OAAO,EACP,IAAI,EACJ,KAAK,GACN,MAAM,qBAAqB,CAAC;AAU7B,OAAO,EACL,YAAY,EACZ,cAAc,EACd,uBAAuB,EACvB,cAAc,EACd,kBAAkB,EAClB,QAAQ,EACR,yBAAyB,EACzB,gBAAgB,EAChB,wBAAwB;AACxB,uEAAuE;AACvE,gCAAgC,EAChC,SAAS,GACV,MAAM,0BAA0B,CAAC;AAgBlC,OAAO,EACL,iBAAiB;AACjB,2FAA2F;AAC3F,uBAAuB,EACvB,WAAW,EACX,UAAU,GACX,MAAM,0BAA0B,CAAC;AAElC,gBAAgB;AAEhB,yEAAyE;AACzE,yFAAyF;AACzF,6DAA6D;AAC7D,OAAO,EAAE,YAAY,IAAI,eAAe,EAAE,MAAM,oCAAoC,CAAC;AAErF,0DAA0D;AAC1D,qEAAqE;AACrE,sEAAsE;AACtE,yEAAyE;AACzE,yCAAyC;AACzC,wEAAwE;AACxE,6EAA6E;AAC7E,8EAA8E;AAC9E,sEAAsE;AACtE,qEAAqE;AACrE,4EAA4E;AAC5E,6BAA6B;AAC7B,OAAO,EACL,oCAAoC,EACpC,uBAAuB,EACvB,mCAAmC,EACnC,GAAG,EACH,WAAW,GACZ,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC","sourcesContent":["/* Core */\n\nexport type {\n ApolloClientOptions,\n ApolloQueryResult,\n DefaultOptions,\n DevtoolsOptions,\n MutateResult,\n MutationOptions,\n QueryOptions,\n RefetchQueriesOptions,\n RefetchQueriesResult,\n SubscribeToMoreOptions,\n SubscriptionOptions,\n WatchQueryOptions,\n} from \"./deprecated.js\";\nexport { ApolloClient } from \"./ApolloClient.js\";\nexport { ObservableQuery } from \"./ObservableQuery.js\";\nexport { RefetchEventManager } from \"./RefetchEventManager.js\";\nexport { onlineSource } from \"./refetchSources/onlineSource.js\";\nexport { windowFocusSource } from \"./refetchSources/windowFocusSource.js\";\nexport type {\n ErrorPolicy,\n FetchPolicy,\n MutationFetchPolicy,\n RefetchWritePolicy,\n SubscribeToMoreFunction,\n SubscribeToMoreUpdateQueryFn,\n UpdateQueryMapFn,\n UpdateQueryOptions,\n WatchQueryFetchPolicy,\n} from \"./watchQueryOptions.js\";\nexport { NetworkStatus } from \"./networkStatus.js\";\nexport type {\n DataState,\n DataValue,\n DefaultContext,\n ErrorLike,\n GetDataState,\n InternalRefetchQueriesInclude,\n InternalRefetchQueriesMap,\n InternalRefetchQueriesOptions,\n InternalRefetchQueriesResult,\n InternalRefetchQueryDescriptor,\n MutationQueryReducer,\n MutationQueryReducersMap,\n MutationUpdaterFunction,\n NormalizedExecutionResult,\n OnQueryUpdated,\n OperationVariables,\n RefetchEvents,\n RefetchOn,\n RefetchQueriesInclude,\n RefetchQueriesPromiseResults,\n RefetchQueryDescriptor,\n SubscriptionObservable,\n TypedDocumentNode,\n TypeOverrides,\n} from \"./types.js\";\nexport {\n CombinedGraphQLErrors,\n CombinedProtocolErrors,\n LinkError,\n LocalStateError,\n ServerError,\n ServerParseError,\n UnconventionalError,\n} from \"@apollo/client/errors\";\n/* Cache */\n\nexport type {\n ApolloReducerConfig,\n Cache,\n DiffQueryAgainstStoreOptions,\n FieldFunctionOptions,\n FieldMergeFunction,\n FieldPolicy,\n FieldReadFunction,\n IdGetter,\n IdGetterObj,\n InMemoryCacheConfig,\n InputObjectConfig,\n InputObjectsOption,\n MergeInfo,\n MergeTree,\n NormalizedCache,\n NormalizedCacheObject,\n OptimisticStoreItem,\n PossibleTypesMap,\n ReactiveVar,\n ReadMergeModifyContext,\n ReadQueryOptions,\n StoreValue,\n // All the exports (types) from ../cache, minus cacheSlot,\n // which we want to keep semi-private.\n Transaction,\n TypePolicies,\n TypePolicy,\n WatchFragmentOptions,\n WatchFragmentResult,\n} from \"@apollo/client/cache\";\n\nexport {\n ApolloCache,\n defaultDataIdFromObject,\n InMemoryCache,\n makeVar,\n MissingFieldError,\n Scalar,\n} from \"@apollo/client/cache\";\n\n/* Link */\n\nexport {\n ApolloLink,\n concat,\n empty,\n execute,\n from,\n split,\n} from \"@apollo/client/link\";\nexport type {\n ApolloPayloadResult,\n DocumentNode,\n FetchResult,\n GraphQLRequest,\n Operation,\n RequestHandler,\n} from \"@apollo/client/link\";\n\nexport {\n checkFetcher,\n createHttpLink,\n createSignalIfSupported,\n defaultPrinter,\n fallbackHttpConfig,\n HttpLink,\n parseAndCheckHttpResponse,\n rewriteURIForGET,\n selectHttpOptionsAndBody,\n // TODO remove: needed by @apollo/client/link/batch-http but not public\n selectHttpOptionsAndBodyInternal,\n selectURI,\n} from \"@apollo/client/link/http\";\n\n/* Masking */\nexport type {\n FragmentType,\n MaybeMasked,\n Unmasked,\n} from \"@apollo/client/masking\";\n\n/* Utilities */\n\nexport type {\n DocumentTransformCacheKey,\n Reference,\n StoreObject,\n} from \"@apollo/client/utilities\";\nexport {\n DocumentTransform,\n /** @deprecated Please import `isNetworkRequestSettled` from `@apollo/client/utilities`. */\n isNetworkRequestSettled,\n isReference,\n Observable,\n} from \"@apollo/client/utilities\";\n\n/* Supporting */\n\n// The verbosity of invariant.{log,warn,error} can be controlled globally\n// by passing \"log\", \"warn\", \"error\", or \"silent\" to setVerbosity (\"log\" is the default).\n// Note that all invariant.* logging is hidden in production.\nexport { setVerbosity as setLogVerbosity } from \"@apollo/client/utilities/invariant\";\n\n// Note that importing `gql` by itself, then destructuring\n// additional properties separately before exporting, is intentional.\n// Due to the way the `graphql-tag` library is setup, certain bundlers\n// can't find the properties added to the exported `gql` function without\n// additional guidance (e.g. Rollup - see\n// https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module).\n// Instead of having people that are using bundlers with `@apollo/client` add\n// extra bundler config to help `graphql-tag` exports be found (which would be\n// awkward since they aren't importing `graphql-tag` themselves), this\n// workaround of pulling the extra properties off the `gql` function,\n// then re-exporting them separately, helps keeps bundlers happy without any\n// additional config changes.\nexport {\n disableExperimentalFragmentVariables,\n disableFragmentWarnings,\n enableExperimentalFragmentVariables,\n gql,\n resetCaches,\n} from \"graphql-tag\";\nexport { build, version } from \"../version.js\";\n\n// internal types\nimport type {\n DefaultOptionsParentObject,\n PossibleDefaultOptions,\n} from \"./defaultOptions.js\";\nimport type { QueryManager } from \"./QueryManager.js\";\nimport type { OverridableTypes } from \"./types.js\";\nimport type { NextFetchPolicyContext } from \"./watchQueryOptions.js\";\n/** @internal */\nexport declare namespace InternalTypes {\n export type {\n DefaultOptionsParentObject,\n NextFetchPolicyContext,\n OverridableTypes,\n PossibleDefaultOptions,\n QueryManager,\n };\n}\n"]}
package/core/types.d.ts CHANGED
@@ -1,21 +1,21 @@
1
1
  import type { DocumentNode, FormattedExecutionResult } from "graphql";
2
2
  import type { NextNotification, Observable, ObservableNotification } from "rxjs";
3
- import type { ApolloCache } from "@apollo/client/cache";
4
3
  import type { Cache } from "@apollo/client/cache";
5
4
  import type { ClientAwarenessLink } from "@apollo/client/link/client-awareness";
6
- import type { Unmasked } from "@apollo/client/masking";
7
- import type { DeepPartial, HKT } from "@apollo/client/utilities";
8
- import type { ApplyHKTImplementationWithDefault, IsAny } from "@apollo/client/utilities/internal";
5
+ import type { FragmentType, Unmasked } from "@apollo/client/masking";
6
+ import type { DeepPartial, HKT, Reference, StoreObject } from "@apollo/client/utilities";
7
+ import type { ApplyHKTImplementationWithDefault, IsAny, NoInfer } from "@apollo/client/utilities/internal";
9
8
  import type { ApolloClient } from "./ApolloClient.js";
10
9
  import type { ObservableQuery } from "./ObservableQuery.js";
11
10
  export type { TypedDocumentNode } from "@graphql-typed-document-node/core";
12
11
  export interface TypeOverrides {
13
12
  }
14
- declare namespace OverridableTypes {
13
+ export declare namespace OverridableTypes {
15
14
  interface Defaults {
16
15
  Complete: Complete;
17
16
  Streaming: Streaming;
18
17
  Partial: Partial;
18
+ FromOptionValue: FromOptionValue;
19
19
  }
20
20
  interface Complete extends HKT {
21
21
  arg1: unknown;
@@ -29,6 +29,10 @@ declare namespace OverridableTypes {
29
29
  arg1: unknown;
30
30
  return: DeepPartial<this["arg1"]>;
31
31
  }
32
+ interface FromOptionValue extends HKT {
33
+ arg1: unknown;
34
+ return: StoreObject | Reference | FragmentType<NoInfer<this["arg1"]>> | string;
35
+ }
32
36
  }
33
37
  export declare namespace DataValue {
34
38
  /**
@@ -180,7 +184,7 @@ type RefetchQueriesIncludeShorthand = "all" | "active";
180
184
  export type RefetchQueriesInclude = RefetchQueryDescriptor[] | RefetchQueriesIncludeShorthand;
181
185
  export type InternalRefetchQueriesInclude = InternalRefetchQueryDescriptor[] | RefetchQueriesIncludeShorthand;
182
186
  export type RefetchQueriesPromiseResults<TResult> = IsAny<TResult> extends true ? any[] : TResult extends boolean ? ApolloClient.QueryResult<any>[] : TResult extends PromiseLike<infer U> ? U[] : TResult[];
183
- export interface InternalRefetchQueriesOptions<TCache extends ApolloCache, TResult> extends Omit<ApolloClient.RefetchQueriesOptions<TCache, TResult>, "include"> {
187
+ export interface InternalRefetchQueriesOptions<TCache extends Cache.Implementation, TResult> extends Omit<ApolloClient.RefetchQueriesOptions<TCache, TResult>, "include"> {
184
188
  include?: InternalRefetchQueriesInclude;
185
189
  removeOptimistic?: string;
186
190
  }
@@ -317,9 +321,11 @@ export declare namespace QueryNotification {
317
321
  source: "setResult";
318
322
  };
319
323
  type FromNetwork<TData> = ObservableNotification<ObservableQuery.Result<TData>> & {
324
+ resolvedVariables?: OperationVariables;
320
325
  source: "network";
321
326
  };
322
327
  type FromCache<TData> = NextNotification<ObservableQuery.Result<TData>> & {
328
+ resolvedVariables?: OperationVariables;
323
329
  source: "cache";
324
330
  };
325
331
  type Value<TData> = FromCache<TData> | FromNetwork<TData> | NewNetworkStatus | SetResult<TData>;
package/core/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { DocumentNode, FormattedExecutionResult } from \"graphql\";\nimport type {\n NextNotification,\n Observable,\n ObservableNotification,\n} from \"rxjs\";\n\nimport type { ApolloCache } from \"@apollo/client/cache\";\nimport type { Cache } from \"@apollo/client/cache\";\nimport type { ClientAwarenessLink } from \"@apollo/client/link/client-awareness\";\nimport type { Unmasked } from \"@apollo/client/masking\";\nimport type { DeepPartial, HKT } from \"@apollo/client/utilities\";\nimport type {\n ApplyHKTImplementationWithDefault,\n IsAny,\n} from \"@apollo/client/utilities/internal\";\n\nimport type { ApolloClient } from \"./ApolloClient.js\";\nimport type { ObservableQuery } from \"./ObservableQuery.js\";\n\nexport type { TypedDocumentNode } from \"@graphql-typed-document-node/core\";\n\nexport interface TypeOverrides {}\n\ndeclare namespace OverridableTypes {\n export interface Defaults {\n Complete: Complete;\n Streaming: Streaming;\n Partial: Partial;\n }\n\n interface Complete extends HKT {\n arg1: unknown; // TData\n return: this[\"arg1\"];\n }\n\n interface Streaming extends HKT {\n arg1: unknown; // TData\n return: this[\"arg1\"];\n }\n\n interface Partial extends HKT {\n arg1: unknown; // TData\n return: DeepPartial<this[\"arg1\"]>;\n }\n}\n\nexport declare namespace DataValue {\n /**\n * Returns a representation of `TData` in it's \"complete\" state.\n *\n * @defaultValue `TData` if no overrides are provided.\n *\n * @example\n * You can override this type globally - this example shows how to override it\n * with `DeepPartial<TData>`:\n *\n * ```ts\n * import { HKT, DeepPartial } from \"@apollo/client/utilities\";\n *\n * type CompleteOverride<TData> =\n * TData extends { _complete?: infer _Complete } ? _Complete : TData;\n *\n * interface CompleteOverrideHKT extends HKT {\n * return: CompleteOverride<this[\"arg1\"]>;\n * }\n *\n * declare module \"@apollo/client\" {\n * export interface TypeOverrides {\n * Complete: CompleteOverrideHKT;\n * }\n * }\n * ```\n */\n export type Complete<TData> = ApplyHKTImplementationWithDefault<\n TypeOverrides,\n \"Complete\",\n OverridableTypes.Defaults,\n TData\n >;\n\n /**\n * Returns a representation of `TData` while it is streaming.\n *\n * @defaultValue `TData` if no overrides are provided.\n *\n * @example\n * You can override this type globally - this example shows how to override it\n * with `DeepPartial<TData>`:\n *\n * ```ts\n * import { HKT, DeepPartial } from \"@apollo/client/utilities\";\n *\n * type StreamingOverride<TData> = DeepPartial<TData>;\n *\n * interface StreamingOverrideHKT extends HKT {\n * return: StreamingOverride<this[\"arg1\"]>;\n * }\n *\n * declare module \"@apollo/client\" {\n * export interface TypeOverrides {\n * Streaming: StreamingOverrideHKT;\n * }\n * }\n * ```\n */\n export type Streaming<TData> = ApplyHKTImplementationWithDefault<\n TypeOverrides,\n \"Streaming\",\n OverridableTypes.Defaults,\n TData\n >;\n\n /**\n * Returns a representation of `TData` while it is partial.\n *\n * @defaultValue `DeepPartial<TData>` if no overrides are provided.\n *\n * @example\n * You can override this type globally - this example shows how to override it\n * with `DeepPartial<TData>`:\n *\n * ```ts\n * import { HKT, DeepPartial } from \"@apollo/client/utilities\";\n *\n * type PartialOverride<TData> = DeepPartial<Complete<TData>>;\n *\n * interface PartialOverrideHKT extends HKT {\n * return: PartialOverride<this[\"arg1\"]>;\n * }\n *\n * declare module \"@apollo/client\" {\n * export interface TypeOverrides {\n * Partial: PartialOverrideHKT;\n * }\n * }\n * ```\n */\n export type Partial<TData> = ApplyHKTImplementationWithDefault<\n TypeOverrides,\n \"Partial\",\n OverridableTypes.Defaults,\n TData\n >;\n}\n\nexport interface DefaultContext extends Record<string, any> {\n /**\n * Indicates whether `queryDeduplication` was enabled for the request.\n */\n queryDeduplication?: boolean;\n clientAwareness?: ClientAwarenessLink.ClientAwarenessOptions;\n}\n\nexport interface RefetchEvents {\n windowFocus: Event;\n online: Event;\n}\n\nexport declare namespace RefetchOn {\n export type Context<\n TSource extends keyof RefetchEvents = keyof RefetchEvents,\n > =\n TSource extends keyof RefetchEvents ?\n {\n /**\n * The source name that triggered the refetch.\n */\n source: TSource;\n\n /**\n * Any data emitted by the source along with the event\n */\n payload: RefetchEvents[TSource];\n }\n : never;\n\n export type Callback<\n TSource extends keyof RefetchEvents = keyof RefetchEvents,\n > = (context: RefetchOn.Context<TSource>) => boolean;\n\n export type Option =\n | boolean\n | RefetchOn.Callback<keyof RefetchEvents>\n | {\n [Key in keyof RefetchEvents]?: boolean | RefetchOn.Callback<Key>;\n };\n}\n\n/**\n * Represents an `Error` type, but used throughout Apollo Client to represent\n * errors that may otherwise fail `instanceof` checks if they are cross-realm\n * Error instances (see the [`Error.isError` proposal](https://github.com/tc39/proposal-is-error) for more details).\n *\n * Apollo Client uses several types of errors throughout the client which can be\n * narrowed using `instanceof`:\n *\n * - `CombinedGraphQLErrors` - `errors` returned from a GraphQL result\n * - `CombinedProtocolErrors` - Transport-level errors from multipart subscriptions.\n * - `ServerParseError` - A JSON-parse error when parsing the server response.\n * - `ServerError` - A non-200 server response.\n *\n * @example\n *\n * ```ts\n * import { CombinedGraphQLErrors } from \"@apollo/client\";\n *\n * try {\n * await client.query({ query });\n * } catch (error) {\n * // Use `instanceof` to check for more specific types of errors.\n * if (error instanceof CombinedGraphQLErrors) {\n * error.errors.map((graphQLError) => console.log(graphQLError.message));\n * } else {\n * console.error(errors);\n * }\n * }\n * ```\n */\nexport interface ErrorLike {\n message: string;\n name: string;\n stack?: string;\n}\n\nexport type OnQueryUpdated<TResult> = (\n observableQuery: ObservableQuery<any>,\n diff: Cache.DiffResult<any>,\n lastDiff: Cache.DiffResult<any> | undefined\n) => boolean | TResult;\n\nexport type RefetchQueryDescriptor = string | DocumentNode;\nexport type InternalRefetchQueryDescriptor =\n | RefetchQueryDescriptor\n | ApolloClient.QueryOptions;\n\ntype RefetchQueriesIncludeShorthand = \"all\" | \"active\";\n\nexport type RefetchQueriesInclude =\n | RefetchQueryDescriptor[]\n | RefetchQueriesIncludeShorthand;\n\nexport type InternalRefetchQueriesInclude =\n | InternalRefetchQueryDescriptor[]\n | RefetchQueriesIncludeShorthand;\n\n// The client.refetchQueries method returns a thenable (PromiseLike) object\n// whose result is an array of Promise.resolve'd TResult values, where TResult\n// is whatever type the (optional) onQueryUpdated function returns. When no\n// onQueryUpdated function is given, TResult defaults to ApolloQueryResult<any>\n// (thanks to default type parameters for client.refetchQueries).\nexport type RefetchQueriesPromiseResults<TResult> =\n // If onQueryUpdated returns any, all bets are off, so the results array must\n // be a generic any[] array, which is much less confusing than the union type\n // we get if we don't check for any. I hoped `any extends TResult` would do\n // the trick here, instead of IsStrictlyAny, but you can see for yourself what\n // fails in the refetchQueries tests if you try making that simplification.\n IsAny<TResult> extends true ? any[]\n : // If the onQueryUpdated function passed to client.refetchQueries returns true\n // or false, that means either to refetch the query (true) or to skip the\n // query (false). Since refetching produces an ApolloQueryResult<any>, and\n // skipping produces nothing, the fully-resolved array of all results produced\n // will be an ApolloQueryResult<any>[], when TResult extends boolean.\n TResult extends boolean ? ApolloClient.QueryResult<any>[]\n : // If onQueryUpdated returns a PromiseLike<U>, that thenable will be passed as\n // an array element to Promise.all, so we infer/unwrap the array type U here.\n TResult extends PromiseLike<infer U> ? U[]\n : // All other onQueryUpdated results end up in the final Promise.all array as\n // themselves, with their original TResult type. Note that TResult will\n // default to ApolloQueryResult<any> if no onQueryUpdated function is passed\n // to client.refetchQueries.\n TResult[];\n\n// Used by QueryManager[\"refetchQueries\"]\nexport interface InternalRefetchQueriesOptions<\n TCache extends ApolloCache,\n TResult,\n> extends Omit<ApolloClient.RefetchQueriesOptions<TCache, TResult>, \"include\"> {\n // Just like the refetchQueries option for a mutation, an array of strings,\n // DocumentNode objects, and/or QueryOptions objects, or one of the shorthand\n // strings \"all\" or \"active\", to select every (active) query.\n include?: InternalRefetchQueriesInclude;\n // This part of the API is a (useful) implementation detail, but need not be\n // exposed in the public client.refetchQueries API (above).\n removeOptimistic?: string;\n}\n\nexport type InternalRefetchQueriesResult<TResult> =\n // If onQueryUpdated returns a boolean, that's equivalent to refetching the\n // query when the boolean is true and skipping the query when false, so the\n // internal type of refetched results is Promise<ApolloQueryResult<any>>.\n TResult extends boolean ? Promise<ApolloClient.QueryResult<any>>\n : // Otherwise, onQueryUpdated returns whatever it returns. If onQueryUpdated is\n // not provided, TResult defaults to Promise<ApolloQueryResult<any>> (see the\n // generic type parameters of client.refetchQueries).\n TResult;\n\nexport type InternalRefetchQueriesMap<TResult> = Map<\n ObservableQuery<any>,\n InternalRefetchQueriesResult<TResult>\n>;\n\nexport type OperationVariables = Record<string, any>;\n\nexport type DataState<TData> =\n | {\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#data:member} */\n data: DataValue.Complete<TData>;\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#dataState:member} */\n dataState: \"complete\";\n }\n | {\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#data:member} */\n data: DataValue.Streaming<TData>;\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#dataState:member} */\n dataState: \"streaming\";\n }\n | {\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#data:member} */\n data: DataValue.Partial<TData>;\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#dataState:member} */\n dataState: \"partial\";\n }\n | {\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#data:member} */\n data: undefined;\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#dataState:member} */\n dataState: \"empty\";\n };\n\nexport type GetDataState<\n TData,\n TState extends DataState<TData>[\"dataState\"],\n> = Extract<DataState<TData>, { dataState: TState }>;\n\n/**\n * Represents a result that might be complete or still streaming and\n * has been normalized into a plain GraphQL result. When the result is\n * still `streaming`, some fields might not yet be available.\n */\nexport type NormalizedExecutionResult<\n TData = Record<string, unknown>,\n TExtensions = Record<string, unknown>,\n> = Omit<FormattedExecutionResult<TData, TExtensions>, \"data\"> &\n GetDataState<TData, \"streaming\" | \"complete\">;\n\n// This is part of the public API, people write these functions in `updateQueries`.\nexport type MutationQueryReducer<T> = (\n previousResult: Record<string, any>,\n options: {\n mutationResult: NormalizedExecutionResult<Unmasked<T>>;\n queryName: string | undefined;\n queryVariables: Record<string, any>;\n }\n) => Record<string, any>;\n\nexport type MutationQueryReducersMap<T = { [key: string]: any }> = {\n [queryName: string]: MutationQueryReducer<T>;\n};\n\nexport type MutationUpdaterFunction<\n TData,\n TVariables extends OperationVariables,\n TCache extends Cache.Implementation,\n> = (\n cache: TCache,\n result: FormattedExecutionResult<Unmasked<TData>>,\n options: {\n context?: DefaultContext;\n variables?: TVariables;\n }\n) => void;\n\nexport declare namespace QueryNotification {\n type NewNetworkStatus = NextNotification<{\n resetError?: boolean;\n }> & {\n source: \"newNetworkStatus\";\n };\n\n type SetResult<TData> = NextNotification<ObservableQuery.Result<TData>> & {\n source: \"setResult\";\n };\n\n type FromNetwork<TData> = ObservableNotification<\n ObservableQuery.Result<TData>\n > & {\n source: \"network\";\n };\n\n type FromCache<TData> = NextNotification<ObservableQuery.Result<TData>> & {\n source: \"cache\";\n };\n\n type Value<TData> =\n | FromCache<TData>\n | FromNetwork<TData>\n | NewNetworkStatus\n | SetResult<TData>;\n}\n\n/** Observable created by initiating a subscription operation. */\nexport interface SubscriptionObservable<T> extends Observable<T> {\n /**\n * Used to restart the connection to the link chain. Calling this on a\n * deduplicated subscription will restart the connection for all observables\n * that share the request.\n *\n * @example\n *\n * ```ts\n * const observable = client.subscribe({ query: subscription });\n * observable.subscribe((value) => {\n * // ...\n * });\n *\n * observable.restart();\n * ```\n */\n restart: () => void;\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/core/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { DocumentNode, FormattedExecutionResult } from \"graphql\";\nimport type {\n NextNotification,\n Observable,\n ObservableNotification,\n} from \"rxjs\";\n\nimport type { Cache } from \"@apollo/client/cache\";\nimport type { ClientAwarenessLink } from \"@apollo/client/link/client-awareness\";\nimport type { FragmentType, Unmasked } from \"@apollo/client/masking\";\nimport type {\n DeepPartial,\n HKT,\n Reference,\n StoreObject,\n} from \"@apollo/client/utilities\";\nimport type {\n ApplyHKTImplementationWithDefault,\n IsAny,\n NoInfer,\n} from \"@apollo/client/utilities/internal\";\n\nimport type { ApolloClient } from \"./ApolloClient.js\";\nimport type { ObservableQuery } from \"./ObservableQuery.js\";\n\nexport type { TypedDocumentNode } from \"@graphql-typed-document-node/core\";\n\nexport interface TypeOverrides {}\n\nexport declare namespace OverridableTypes {\n export interface Defaults {\n Complete: Complete;\n Streaming: Streaming;\n Partial: Partial;\n FromOptionValue: FromOptionValue;\n }\n\n interface Complete extends HKT {\n arg1: unknown; // TData\n return: this[\"arg1\"];\n }\n\n interface Streaming extends HKT {\n arg1: unknown; // TData\n return: this[\"arg1\"];\n }\n\n interface Partial extends HKT {\n arg1: unknown; // TData\n return: DeepPartial<this[\"arg1\"]>;\n }\n\n interface FromOptionValue extends HKT {\n arg1: unknown; // TData\n return:\n | StoreObject\n | Reference\n | FragmentType<NoInfer<this[\"arg1\"]>>\n | string;\n }\n}\n\nexport declare namespace DataValue {\n /**\n * Returns a representation of `TData` in it's \"complete\" state.\n *\n * @defaultValue `TData` if no overrides are provided.\n *\n * @example\n * You can override this type globally - this example shows how to override it\n * with `DeepPartial<TData>`:\n *\n * ```ts\n * import { HKT, DeepPartial } from \"@apollo/client/utilities\";\n *\n * type CompleteOverride<TData> =\n * TData extends { _complete?: infer _Complete } ? _Complete : TData;\n *\n * interface CompleteOverrideHKT extends HKT {\n * return: CompleteOverride<this[\"arg1\"]>;\n * }\n *\n * declare module \"@apollo/client\" {\n * export interface TypeOverrides {\n * Complete: CompleteOverrideHKT;\n * }\n * }\n * ```\n */\n export type Complete<TData> = ApplyHKTImplementationWithDefault<\n TypeOverrides,\n \"Complete\",\n OverridableTypes.Defaults,\n TData\n >;\n\n /**\n * Returns a representation of `TData` while it is streaming.\n *\n * @defaultValue `TData` if no overrides are provided.\n *\n * @example\n * You can override this type globally - this example shows how to override it\n * with `DeepPartial<TData>`:\n *\n * ```ts\n * import { HKT, DeepPartial } from \"@apollo/client/utilities\";\n *\n * type StreamingOverride<TData> = DeepPartial<TData>;\n *\n * interface StreamingOverrideHKT extends HKT {\n * return: StreamingOverride<this[\"arg1\"]>;\n * }\n *\n * declare module \"@apollo/client\" {\n * export interface TypeOverrides {\n * Streaming: StreamingOverrideHKT;\n * }\n * }\n * ```\n */\n export type Streaming<TData> = ApplyHKTImplementationWithDefault<\n TypeOverrides,\n \"Streaming\",\n OverridableTypes.Defaults,\n TData\n >;\n\n /**\n * Returns a representation of `TData` while it is partial.\n *\n * @defaultValue `DeepPartial<TData>` if no overrides are provided.\n *\n * @example\n * You can override this type globally - this example shows how to override it\n * with `DeepPartial<TData>`:\n *\n * ```ts\n * import { HKT, DeepPartial } from \"@apollo/client/utilities\";\n *\n * type PartialOverride<TData> = DeepPartial<Complete<TData>>;\n *\n * interface PartialOverrideHKT extends HKT {\n * return: PartialOverride<this[\"arg1\"]>;\n * }\n *\n * declare module \"@apollo/client\" {\n * export interface TypeOverrides {\n * Partial: PartialOverrideHKT;\n * }\n * }\n * ```\n */\n export type Partial<TData> = ApplyHKTImplementationWithDefault<\n TypeOverrides,\n \"Partial\",\n OverridableTypes.Defaults,\n TData\n >;\n}\n\nexport interface DefaultContext extends Record<string, any> {\n /**\n * Indicates whether `queryDeduplication` was enabled for the request.\n */\n queryDeduplication?: boolean;\n clientAwareness?: ClientAwarenessLink.ClientAwarenessOptions;\n}\n\nexport interface RefetchEvents {\n windowFocus: Event;\n online: Event;\n}\n\nexport declare namespace RefetchOn {\n export type Context<\n TSource extends keyof RefetchEvents = keyof RefetchEvents,\n > =\n TSource extends keyof RefetchEvents ?\n {\n /**\n * The source name that triggered the refetch.\n */\n source: TSource;\n\n /**\n * Any data emitted by the source along with the event\n */\n payload: RefetchEvents[TSource];\n }\n : never;\n\n export type Callback<\n TSource extends keyof RefetchEvents = keyof RefetchEvents,\n > = (context: RefetchOn.Context<TSource>) => boolean;\n\n export type Option =\n | boolean\n | RefetchOn.Callback<keyof RefetchEvents>\n | {\n [Key in keyof RefetchEvents]?: boolean | RefetchOn.Callback<Key>;\n };\n}\n\n/**\n * Represents an `Error` type, but used throughout Apollo Client to represent\n * errors that may otherwise fail `instanceof` checks if they are cross-realm\n * Error instances (see the [`Error.isError` proposal](https://github.com/tc39/proposal-is-error) for more details).\n *\n * Apollo Client uses several types of errors throughout the client which can be\n * narrowed using `instanceof`:\n *\n * - `CombinedGraphQLErrors` - `errors` returned from a GraphQL result\n * - `CombinedProtocolErrors` - Transport-level errors from multipart subscriptions.\n * - `ServerParseError` - A JSON-parse error when parsing the server response.\n * - `ServerError` - A non-200 server response.\n *\n * @example\n *\n * ```ts\n * import { CombinedGraphQLErrors } from \"@apollo/client\";\n *\n * try {\n * await client.query({ query });\n * } catch (error) {\n * // Use `instanceof` to check for more specific types of errors.\n * if (error instanceof CombinedGraphQLErrors) {\n * error.errors.map((graphQLError) => console.log(graphQLError.message));\n * } else {\n * console.error(errors);\n * }\n * }\n * ```\n */\nexport interface ErrorLike {\n message: string;\n name: string;\n stack?: string;\n}\n\nexport type OnQueryUpdated<TResult> = (\n observableQuery: ObservableQuery<any>,\n diff: Cache.DiffResult<any>,\n lastDiff: Cache.DiffResult<any> | undefined\n) => boolean | TResult;\n\nexport type RefetchQueryDescriptor = string | DocumentNode;\nexport type InternalRefetchQueryDescriptor =\n | RefetchQueryDescriptor\n | ApolloClient.QueryOptions;\n\ntype RefetchQueriesIncludeShorthand = \"all\" | \"active\";\n\nexport type RefetchQueriesInclude =\n | RefetchQueryDescriptor[]\n | RefetchQueriesIncludeShorthand;\n\nexport type InternalRefetchQueriesInclude =\n | InternalRefetchQueryDescriptor[]\n | RefetchQueriesIncludeShorthand;\n\n// The client.refetchQueries method returns a thenable (PromiseLike) object\n// whose result is an array of Promise.resolve'd TResult values, where TResult\n// is whatever type the (optional) onQueryUpdated function returns. When no\n// onQueryUpdated function is given, TResult defaults to ApolloQueryResult<any>\n// (thanks to default type parameters for client.refetchQueries).\nexport type RefetchQueriesPromiseResults<TResult> =\n // If onQueryUpdated returns any, all bets are off, so the results array must\n // be a generic any[] array, which is much less confusing than the union type\n // we get if we don't check for any. I hoped `any extends TResult` would do\n // the trick here, instead of IsStrictlyAny, but you can see for yourself what\n // fails in the refetchQueries tests if you try making that simplification.\n IsAny<TResult> extends true ? any[]\n : // If the onQueryUpdated function passed to client.refetchQueries returns true\n // or false, that means either to refetch the query (true) or to skip the\n // query (false). Since refetching produces an ApolloQueryResult<any>, and\n // skipping produces nothing, the fully-resolved array of all results produced\n // will be an ApolloQueryResult<any>[], when TResult extends boolean.\n TResult extends boolean ? ApolloClient.QueryResult<any>[]\n : // If onQueryUpdated returns a PromiseLike<U>, that thenable will be passed as\n // an array element to Promise.all, so we infer/unwrap the array type U here.\n TResult extends PromiseLike<infer U> ? U[]\n : // All other onQueryUpdated results end up in the final Promise.all array as\n // themselves, with their original TResult type. Note that TResult will\n // default to ApolloQueryResult<any> if no onQueryUpdated function is passed\n // to client.refetchQueries.\n TResult[];\n\n// Used by QueryManager[\"refetchQueries\"]\nexport interface InternalRefetchQueriesOptions<\n TCache extends Cache.Implementation,\n TResult,\n> extends Omit<ApolloClient.RefetchQueriesOptions<TCache, TResult>, \"include\"> {\n // Just like the refetchQueries option for a mutation, an array of strings,\n // DocumentNode objects, and/or QueryOptions objects, or one of the shorthand\n // strings \"all\" or \"active\", to select every (active) query.\n include?: InternalRefetchQueriesInclude;\n // This part of the API is a (useful) implementation detail, but need not be\n // exposed in the public client.refetchQueries API (above).\n removeOptimistic?: string;\n}\n\nexport type InternalRefetchQueriesResult<TResult> =\n // If onQueryUpdated returns a boolean, that's equivalent to refetching the\n // query when the boolean is true and skipping the query when false, so the\n // internal type of refetched results is Promise<ApolloQueryResult<any>>.\n TResult extends boolean ? Promise<ApolloClient.QueryResult<any>>\n : // Otherwise, onQueryUpdated returns whatever it returns. If onQueryUpdated is\n // not provided, TResult defaults to Promise<ApolloQueryResult<any>> (see the\n // generic type parameters of client.refetchQueries).\n TResult;\n\nexport type InternalRefetchQueriesMap<TResult> = Map<\n ObservableQuery<any>,\n InternalRefetchQueriesResult<TResult>\n>;\n\nexport type OperationVariables = Record<string, any>;\n\nexport type DataState<TData> =\n | {\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#data:member} */\n data: DataValue.Complete<TData>;\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#dataState:member} */\n dataState: \"complete\";\n }\n | {\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#data:member} */\n data: DataValue.Streaming<TData>;\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#dataState:member} */\n dataState: \"streaming\";\n }\n | {\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#data:member} */\n data: DataValue.Partial<TData>;\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#dataState:member} */\n dataState: \"partial\";\n }\n | {\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#data:member} */\n data: undefined;\n /** {@inheritDoc @apollo/client!QueryResultDocumentation#dataState:member} */\n dataState: \"empty\";\n };\n\nexport type GetDataState<\n TData,\n TState extends DataState<TData>[\"dataState\"],\n> = Extract<DataState<TData>, { dataState: TState }>;\n\n/**\n * Represents a result that might be complete or still streaming and\n * has been normalized into a plain GraphQL result. When the result is\n * still `streaming`, some fields might not yet be available.\n */\nexport type NormalizedExecutionResult<\n TData = Record<string, unknown>,\n TExtensions = Record<string, unknown>,\n> = Omit<FormattedExecutionResult<TData, TExtensions>, \"data\"> &\n GetDataState<TData, \"streaming\" | \"complete\">;\n\n// This is part of the public API, people write these functions in `updateQueries`.\nexport type MutationQueryReducer<T> = (\n previousResult: Record<string, any>,\n options: {\n mutationResult: NormalizedExecutionResult<Unmasked<T>>;\n queryName: string | undefined;\n queryVariables: Record<string, any>;\n }\n) => Record<string, any>;\n\nexport type MutationQueryReducersMap<T = { [key: string]: any }> = {\n [queryName: string]: MutationQueryReducer<T>;\n};\n\nexport type MutationUpdaterFunction<\n TData,\n TVariables extends OperationVariables,\n TCache extends Cache.Implementation,\n> = (\n cache: TCache,\n result: FormattedExecutionResult<Unmasked<TData>>,\n options: {\n context?: DefaultContext;\n variables?: TVariables;\n }\n) => void;\n\nexport declare namespace QueryNotification {\n type NewNetworkStatus = NextNotification<{\n resetError?: boolean;\n }> & {\n source: \"newNetworkStatus\";\n };\n\n type SetResult<TData> = NextNotification<ObservableQuery.Result<TData>> & {\n source: \"setResult\";\n };\n\n type FromNetwork<TData> = ObservableNotification<\n ObservableQuery.Result<TData>\n > & {\n resolvedVariables?: OperationVariables;\n source: \"network\";\n };\n\n type FromCache<TData> = NextNotification<ObservableQuery.Result<TData>> & {\n resolvedVariables?: OperationVariables;\n source: \"cache\";\n };\n\n type Value<TData> =\n | FromCache<TData>\n | FromNetwork<TData>\n | NewNetworkStatus\n | SetResult<TData>;\n}\n\n/** Observable created by initiating a subscription operation. */\nexport interface SubscriptionObservable<T> extends Observable<T> {\n /**\n * Used to restart the connection to the link chain. Calling this on a\n * deduplicated subscription will restart the connection for all observables\n * that share the request.\n *\n * @example\n *\n * ```ts\n * const observable = client.subscribe({ query: subscription });\n * observable.subscribe((value) => {\n * // ...\n * });\n *\n * observable.restart();\n * ```\n */\n restart: () => void;\n}\n"]}
@@ -0,0 +1,55 @@
1
+ import type { DeepPartial, HKT } from "@apollo/client/utilities";
2
+ import type { IsAny } from "@apollo/client/utilities/internal";
3
+ import type { ContainsNeverishFields, RemoveNeverishFields } from "./internal/types.js";
4
+ export declare namespace GraphQLCodegenIncremental {
5
+ interface TypeOverrides {
6
+ Complete: HKTImplementation.Complete;
7
+ Streaming: HKTImplementation.Streaming;
8
+ Partial: HKTImplementation.Partial;
9
+ }
10
+ namespace HKTImplementation {
11
+ interface Complete extends HKT {
12
+ arg1: unknown;
13
+ return: GraphQLCodegenIncremental.Complete<this["arg1"]>;
14
+ }
15
+ interface Streaming extends HKT {
16
+ arg1: unknown;
17
+ return: GraphQLCodegenIncremental.Streaming<this["arg1"]>;
18
+ }
19
+ interface Partial extends HKT {
20
+ arg1: unknown;
21
+ return: GraphQLCodegenIncremental.Partial<this["arg1"]>;
22
+ }
23
+ }
24
+ /**
25
+ * Returns the complete representation of `TData` when `dataState` is
26
+ * `"complete"`.
27
+ *
28
+ * @remarks
29
+ * GraphQL Codegen types deferred fields as a union of the present value and
30
+ * `{ field?: never }`. `complete` `dataState` means every field in the
31
+ * selection set is reachable, so this type drops the `never` branches.
32
+ *
33
+ * Operations without `@defer` are returned unchanged.
34
+ */
35
+ type Complete<TData> = TData extends any ? true extends IsAny<TData> ? TData : TData extends object ? true extends ContainsNeverishFields<TData> ? RemoveNeverishFields<TData> : TData : TData : never;
36
+ /**
37
+ * Returns the streaming representation of `TData` when `dataState` is
38
+ * `"streaming"`.
39
+ *
40
+ * @remarks
41
+ * GraphQLCodegen assembles the type in the streaming format so this is an
42
+ * identity type.
43
+ */
44
+ type Streaming<TData> = TData;
45
+ /**
46
+ * Returns the partial representation of `TData` when `dataState` is
47
+ * `"partial"`.
48
+ *
49
+ * @remarks
50
+ * Applies `DeepPartial` to the assembled `Complete` type so
51
+ * `returnPartialData` does not preserve deferred `{ field?: never }` types.
52
+ */
53
+ type Partial<TData> = DeepPartial<Complete<TData>>;
54
+ }
55
+ //# sourceMappingURL=GraphQLCodegenIncremental.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=GraphQLCodegenIncremental.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphQLCodegenIncremental.js","sourceRoot":"","sources":["../../src/incremental/GraphQLCodegenIncremental.ts"],"names":[],"mappings":"","sourcesContent":["import type { DeepPartial, HKT } from \"@apollo/client/utilities\";\nimport type { IsAny } from \"@apollo/client/utilities/internal\";\n\nimport type {\n ContainsNeverishFields,\n RemoveNeverishFields,\n} from \"./internal/types.js\";\n\nexport declare namespace GraphQLCodegenIncremental {\n export interface TypeOverrides {\n Complete: HKTImplementation.Complete;\n Streaming: HKTImplementation.Streaming;\n Partial: HKTImplementation.Partial;\n }\n\n namespace HKTImplementation {\n export interface Complete extends HKT {\n arg1: unknown; // TData\n return: GraphQLCodegenIncremental.Complete<this[\"arg1\"]>;\n }\n\n export interface Streaming extends HKT {\n arg1: unknown; // TData\n return: GraphQLCodegenIncremental.Streaming<this[\"arg1\"]>;\n }\n\n export interface Partial extends HKT {\n arg1: unknown; // TData\n return: GraphQLCodegenIncremental.Partial<this[\"arg1\"]>;\n }\n }\n\n /**\n * Returns the complete representation of `TData` when `dataState` is\n * `\"complete\"`.\n *\n * @remarks\n * GraphQL Codegen types deferred fields as a union of the present value and\n * `{ field?: never }`. `complete` `dataState` means every field in the\n * selection set is reachable, so this type drops the `never` branches.\n *\n * Operations without `@defer` are returned unchanged.\n */\n export type Complete<TData> =\n TData extends any ?\n true extends IsAny<TData> ? TData\n : TData extends object ?\n true extends ContainsNeverishFields<TData> ?\n RemoveNeverishFields<TData>\n : TData\n : TData\n : never;\n /**\n * Returns the streaming representation of `TData` when `dataState` is\n * `\"streaming\"`.\n *\n * @remarks\n * GraphQLCodegen assembles the type in the streaming format so this is an\n * identity type.\n */\n export type Streaming<TData> = TData;\n\n /**\n * Returns the partial representation of `TData` when `dataState` is\n * `\"partial\"`.\n *\n * @remarks\n * Applies `DeepPartial` to the assembled `Complete` type so\n * `returnPartialData` does not preserve deferred `{ field?: never }` types.\n */\n export type Partial<TData> = DeepPartial<Complete<TData>>;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { DocumentNode, FormattedExecutionResult, GraphQLFormattedError } from "graphql";
1
+ import type { FormattedExecutionResult, GraphQLFormattedError } from "graphql";
2
2
  import type { ApolloLink } from "@apollo/client/link";
3
3
  import type { DeepPartial, HKT } from "@apollo/client/utilities";
4
4
  import type { Incremental } from "../types.js";
@@ -57,9 +57,7 @@ export declare class Defer20220824Handler implements Incremental.Handler<Defer20
57
57
  isIncrementalResult(result: Record<string, any>): result is Defer20220824Handler.SubsequentResult | Defer20220824Handler.InitialResult;
58
58
  extractErrors(result: ApolloLink.Result<any>): GraphQLFormattedError[] | undefined;
59
59
  prepareRequest(request: ApolloLink.Request): ApolloLink.Request;
60
- startRequest<TData extends Record<string, unknown>>(_: {
61
- query: DocumentNode;
62
- }): DeferRequest<TData>;
60
+ startRequest<TData extends Record<string, unknown>>(_: Incremental.StartRequestOptions): DeferRequest<TData>;
63
61
  }
64
62
  export declare function hasIncrementalChunks(result: Record<string, any>): result is Required<Defer20220824Handler.SubsequentResult>;
65
63
  export {};
@@ -1 +1 @@
1
- {"version":3,"file":"defer20220824.js","sourceRoot":"","sources":["../../../src/incremental/handlers/defer20220824.ts"],"names":[],"mappings":"AAQA,OAAO,EACL,UAAU,EACV,aAAa,EACb,eAAe,GAChB,MAAM,mCAAmC,CAAC;AAqD3C,MAAM,YAAY;IAIT,OAAO,GAAG,IAAI,CAAC;IAEd,MAAM,GAAiC,EAAE,CAAC;IAC1C,UAAU,GAAwB,EAAE,CAAC;IACrC,IAAI,GAAQ,EAAE,CAAC;IACvB,yEAAyE;IACzE,4EAA4E;IAC5E,wEAAwE;IACxE,2EAA2E;IACnE,4BAA4B,GAAG,IAAI,GAAG,EAAU,CAAC;IAEjD,KAAK,CACX,UAA2C,EAC3C,MAA0C;QAE1C,IAAI,UAAU,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAClC,IAAI,CAAC,IAAI,GAAG,IAAI,UAAU,CAAC,EAAE,UAAU,EAAE,UAAU,EAAE,CAAC,CAAC,KAAK,CAC1D,IAAI,CAAC,IAAI,EACT,UAAU,CAAC,IAAI,EACf,EAAE,MAAM,EAAE,CACX,CAAC;QACJ,CAAC;QACD,IAAI,UAAU,CAAC,MAAM,EAAE,CAAC;YACtB,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,UAAU,CAAC,MAAM,CAAC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O,eAAe,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import type {\n DocumentNode,\n FormattedExecutionResult,\n GraphQLFormattedError,\n} from \"graphql\";\n\nimport type { ApolloLink } from \"@apollo/client/link\";\nimport type { DeepPartial, HKT } from \"@apollo/client/utilities\";\nimport {\n DeepMerger,\n hasDirectives,\n isNonEmptyArray,\n} from \"@apollo/client/utilities/internal\";\n\nimport type { Incremental } from \"../types.js\";\n\nexport declare namespace Defer20220824Handler {\n interface Defer20220824Result extends HKT {\n arg1: unknown; // TData\n arg2: unknown; // TExtensions\n return: Defer20220824Handler.Chunk<Record<string, unknown>>;\n }\n export interface TypeOverrides {\n AdditionalApolloLinkResultTypes: Defer20220824Result;\n }\n\n export type InitialResult<TData = Record<string, unknown>> = {\n data?: TData | null | undefined;\n errors?: ReadonlyArray<GraphQLFormattedError>;\n extensions?: Record<string, unknown>;\n hasNext: boolean;\n incremental?: ReadonlyArray<IncrementalResult<TData>>;\n };\n\n export type SubsequentResult<TData = Record<string, unknown>> = {\n extensions?: Record<string, unknown>;\n hasNext: boolean;\n incremental?: Array<IncrementalResult<TData>>;\n };\n\n export type IncrementalDeferResult<TData = Record<string, unknown>> = {\n data?: TData | null;\n errors?: ReadonlyArray<GraphQLFormattedError>;\n extensions?: Record<string, unknown>;\n path?: Incremental.Path;\n label?: string;\n };\n\n export type IncrementalStreamResult<TData = Array<unknown>> = {\n errors?: ReadonlyArray<GraphQLFormattedError>;\n items?: TData;\n path?: Incremental.Path;\n label?: string;\n extensions?: Record<string, unknown>;\n };\n\n export type IncrementalResult<TData = Record<string, unknown>> =\n | IncrementalDeferResult<TData>\n | IncrementalStreamResult<TData>;\n\n export type Chunk<TData extends Record<string, unknown>> =\n | InitialResult<TData>\n | SubsequentResult<TData>;\n}\n\nclass DeferRequest<TData extends Record<string, unknown>>\n implements\n Incremental.IncrementalRequest<Defer20220824Handler.Chunk<TData>, TData>\n{\n public hasNext = true;\n\n private errors: Array<GraphQLFormattedError> = [];\n private extensions: Record<string, any> = {};\n private data: any = {};\n // This tracks paths for `@stream` arrays that returns items: null due to\n // errors thrown for non-null array items. We stop processing future updates\n // to these stream arrays to prevent creating sparse arrays or inserting\n // `null` for an expected non-null value which could cause runtime crashes.\n private ignoredImpossibleStreamPaths = new Set<string>();\n\n private merge(\n normalized: FormattedExecutionResult<TData>,\n atPath?: DeepMerger.MergeOptions[\"atPath\"]\n ) {\n if (normalized.data !== undefined) {\n this.data = new DeepMerger({ arrayMerge: \"truncate\" }).merge(\n this.data,\n normalized.data,\n { atPath }\n );\n }\n if (normalized.errors) {\n this.errors.push(...normalized.errors);\n }\n Object.assign(this.extensions, normalized.extensions);\n }\n\n handle(\n // we'll get `undefined` here in case of a `no-cache` fetch policy,\n // so we'll continue with the last value this request had accumulated\n cacheData: TData | DeepPartial<TData> | null | undefined = this.data,\n chunk: Defer20220824Handler.Chunk<TData>\n ): FormattedExecutionResult<TData> {\n this.hasNext = chunk.hasNext;\n this.data = cacheData;\n\n if (hasIncrementalChunks(chunk)) {\n for (const incremental of chunk.incremental) {\n const { path, errors, extensions } = incremental;\n\n if (\"items\" in incremental) {\n // Remove the array index from the end of the array since each future\n // chunk sends a different array index. This normalizes the path to\n // ensure we ignore updates to this field if `items` is `null`.\n const stringPath = path?.slice(0, -1).join(\".\") ?? \"\";\n\n if (incremental.items === null) {\n this.ignoredImpossibleStreamPaths.add(stringPath);\n }\n\n if (this.ignoredImpossibleStreamPaths.has(stringPath)) {\n this.merge({ errors, extensions });\n continue;\n }\n }\n\n let data: any =\n \"items\" in incremental ? incremental.items\n // Ensure `data: null` isn't merged for `@defer` responses by\n // falling back to `undefined`\n : \"data\" in incremental ? incremental.data ?? undefined\n : undefined;\n\n if (path && typeof path.at(-1) === \"number\" && Array.isArray(data)) {\n const startingIdx = path.at(-1) as number;\n data.forEach((item, idx) => {\n this.merge({ data: item }, [\n ...path!.slice(0, -1),\n startingIdx + idx,\n ]);\n });\n } else {\n this.merge({ data }, path);\n }\n\n this.merge({ errors, extensions });\n }\n } else {\n this.merge(chunk);\n }\n\n const result: FormattedExecutionResult<TData> = { data: this.data };\n\n if (isNonEmptyArray(this.errors)) {\n result.errors = this.errors;\n }\n\n if (Object.keys(this.extensions).length > 0) {\n result.extensions = this.extensions;\n }\n\n return result;\n }\n}\n\n/**\n * This handler implements the `@defer` directive as specified in this historical commit:\n * https://github.com/graphql/graphql-spec/tree/48cf7263a71a683fab03d45d309fd42d8d9a6659/spec\n */\nexport class Defer20220824Handler\n implements Incremental.Handler<Defer20220824Handler.Chunk<any>>\n{\n isIncrementalResult(\n result: Record<string, any>\n ): result is\n | Defer20220824Handler.SubsequentResult\n | Defer20220824Handler.InitialResult {\n return \"hasNext\" in result;\n }\n\n extractErrors(result: ApolloLink.Result<any>) {\n const acc: GraphQLFormattedError[] = [];\n const push = ({\n errors,\n }: {\n errors?: ReadonlyArray<GraphQLFormattedError>;\n }) => {\n if (errors) {\n acc.push(...errors);\n }\n };\n if (this.isIncrementalResult(result)) {\n if (\"errors\" in result) {\n push(result);\n }\n if (hasIncrementalChunks(result)) {\n result.incremental.forEach(push);\n }\n }\n if (acc.length) {\n return acc;\n }\n }\n\n prepareRequest(request: ApolloLink.Request): ApolloLink.Request {\n if (hasDirectives([\"defer\", \"stream\"], request.query)) {\n const context = request.context ?? {};\n const http = (context.http ??= {});\n http.accept = [\n \"multipart/mixed;deferSpec=20220824\",\n ...(http.accept || []),\n ];\n }\n\n return request;\n }\n startRequest<TData extends Record<string, unknown>>(_: {\n query: DocumentNode;\n }) {\n return new DeferRequest<TData>();\n }\n}\n\n// only exported for use in tests\nexport function hasIncrementalChunks(\n result: Record<string, any>\n): result is Required<Defer20220824Handler.SubsequentResult> {\n return isNonEmptyArray(result.incremental);\n}\n"]}
1
+ {"version":3,"file":"defer20220824.js","sourceRoot":"","sources":["../../../src/incremental/handlers/defer20220824.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,UAAU,EACV,aAAa,EACb,eA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,CAAC,CAAC;YACnC,CAAC;QACH,CAAC;QACD,IAAI,GAAG,CAAC,MAAM,EAAE,CAAC;YACf,OAAO,GAAG,CAAC;QACb,CAAC;IACH,CAAC;IAED,cAAc,CAAC,OAA2B;QACxC,IAAI,aAAa,CAAC,CAAC,OAAO,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;YACtD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,EAAE,CAAC;YACtC,MAAM,IAAI,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK,EAAE,CAAC,CAAC;YACnC,IAAI,CAAC,MAAM,GAAG;gBACZ,oCAAoC;gBACpC,GAAG,CAAC,IAAI,CAAC,MAAM,IAAI,EAAE,CAAC;aACvB,CAAC;QACJ,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IACD,YAAY,CACV,CAAkC;QAElC,OAAO,IAAI,YAAY,EAAS,CAAC;IACnC,CAAC;CACF;AAED,iCAAiC;AACjC,MAAM,UAAU,oBAAoB,CAClC,MAA2B;IAE3B,OAAO,eAAe,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAC7C,CAAC","sourcesContent":["import type { FormattedExecutionResult, GraphQLFormattedError } from \"graphql\";\n\nimport type { ApolloLink } from \"@apollo/client/link\";\nimport type { DeepPartial, HKT } from \"@apollo/client/utilities\";\nimport {\n DeepMerger,\n hasDirectives,\n isNonEmptyArray,\n} from \"@apollo/client/utilities/internal\";\n\nimport type { Incremental } from \"../types.js\";\n\nexport declare namespace Defer20220824Handler {\n interface Defer20220824Result extends HKT {\n arg1: unknown; // TData\n arg2: unknown; // TExtensions\n return: Defer20220824Handler.Chunk<Record<string, unknown>>;\n }\n export interface TypeOverrides {\n AdditionalApolloLinkResultTypes: Defer20220824Result;\n }\n\n export type InitialResult<TData = Record<string, unknown>> = {\n data?: TData | null | undefined;\n errors?: ReadonlyArray<GraphQLFormattedError>;\n extensions?: Record<string, unknown>;\n hasNext: boolean;\n incremental?: ReadonlyArray<IncrementalResult<TData>>;\n };\n\n export type SubsequentResult<TData = Record<string, unknown>> = {\n extensions?: Record<string, unknown>;\n hasNext: boolean;\n incremental?: Array<IncrementalResult<TData>>;\n };\n\n export type IncrementalDeferResult<TData = Record<string, unknown>> = {\n data?: TData | null;\n errors?: ReadonlyArray<GraphQLFormattedError>;\n extensions?: Record<string, unknown>;\n path?: Incremental.Path;\n label?: string;\n };\n\n export type IncrementalStreamResult<TData = Array<unknown>> = {\n errors?: ReadonlyArray<GraphQLFormattedError>;\n items?: TData;\n path?: Incremental.Path;\n label?: string;\n extensions?: Record<string, unknown>;\n };\n\n export type IncrementalResult<TData = Record<string, unknown>> =\n | IncrementalDeferResult<TData>\n | IncrementalStreamResult<TData>;\n\n export type Chunk<TData extends Record<string, unknown>> =\n | InitialResult<TData>\n | SubsequentResult<TData>;\n}\n\nclass DeferRequest<TData extends Record<string, unknown>>\n implements\n Incremental.IncrementalRequest<Defer20220824Handler.Chunk<TData>, TData>\n{\n public hasNext = true;\n\n private errors: Array<GraphQLFormattedError> = [];\n private extensions: Record<string, any> = {};\n private data: any = {};\n // This tracks paths for `@stream` arrays that returns items: null due to\n // errors thrown for non-null array items. We stop processing future updates\n // to these stream arrays to prevent creating sparse arrays or inserting\n // `null` for an expected non-null value which could cause runtime crashes.\n private ignoredImpossibleStreamPaths = new Set<string>();\n\n private merge(\n normalized: FormattedExecutionResult<TData>,\n atPath?: DeepMerger.MergeOptions[\"atPath\"]\n ) {\n if (normalized.data !== undefined) {\n this.data = new DeepMerger({ arrayMerge: \"truncate\" }).merge(\n this.data,\n normalized.data,\n { atPath }\n );\n }\n if (normalized.errors) {\n this.errors.push(...normalized.errors);\n }\n Object.assign(this.extensions, normalized.extensions);\n }\n\n handle(\n // we'll get `undefined` here in case of a `no-cache` fetch policy,\n // so we'll continue with the last value this request had accumulated\n cacheData: TData | DeepPartial<TData> | null | undefined = this.data,\n chunk: Defer20220824Handler.Chunk<TData>\n ): FormattedExecutionResult<TData> {\n this.hasNext = chunk.hasNext;\n this.data = cacheData;\n\n if (hasIncrementalChunks(chunk)) {\n for (const incremental of chunk.incremental) {\n const { path, errors, extensions } = incremental;\n\n if (\"items\" in incremental) {\n // Remove the array index from the end of the array since each future\n // chunk sends a different array index. This normalizes the path to\n // ensure we ignore updates to this field if `items` is `null`.\n const stringPath = path?.slice(0, -1).join(\".\") ?? \"\";\n\n if (incremental.items === null) {\n this.ignoredImpossibleStreamPaths.add(stringPath);\n }\n\n if (this.ignoredImpossibleStreamPaths.has(stringPath)) {\n this.merge({ errors, extensions });\n continue;\n }\n }\n\n let data: any =\n \"items\" in incremental ? incremental.items\n // Ensure `data: null` isn't merged for `@defer` responses by\n // falling back to `undefined`\n : \"data\" in incremental ? incremental.data ?? undefined\n : undefined;\n\n if (path && typeof path.at(-1) === \"number\" && Array.isArray(data)) {\n const startingIdx = path.at(-1) as number;\n data.forEach((item, idx) => {\n this.merge({ data: item }, [\n ...path!.slice(0, -1),\n startingIdx + idx,\n ]);\n });\n } else {\n this.merge({ data }, path);\n }\n\n this.merge({ errors, extensions });\n }\n } else {\n this.merge(chunk);\n }\n\n const result: FormattedExecutionResult<TData> = { data: this.data };\n\n if (isNonEmptyArray(this.errors)) {\n result.errors = this.errors;\n }\n\n if (Object.keys(this.extensions).length > 0) {\n result.extensions = this.extensions;\n }\n\n return result;\n }\n}\n\n/**\n * This handler implements the `@defer` directive as specified in this historical commit:\n * https://github.com/graphql/graphql-spec/tree/48cf7263a71a683fab03d45d309fd42d8d9a6659/spec\n */\nexport class Defer20220824Handler\n implements Incremental.Handler<Defer20220824Handler.Chunk<any>>\n{\n isIncrementalResult(\n result: Record<string, any>\n ): result is\n | Defer20220824Handler.SubsequentResult\n | Defer20220824Handler.InitialResult {\n return \"hasNext\" in result;\n }\n\n extractErrors(result: ApolloLink.Result<any>) {\n const acc: GraphQLFormattedError[] = [];\n const push = ({\n errors,\n }: {\n errors?: ReadonlyArray<GraphQLFormattedError>;\n }) => {\n if (errors) {\n acc.push(...errors);\n }\n };\n if (this.isIncrementalResult(result)) {\n if (\"errors\" in result) {\n push(result);\n }\n if (hasIncrementalChunks(result)) {\n result.incremental.forEach(push);\n }\n }\n if (acc.length) {\n return acc;\n }\n }\n\n prepareRequest(request: ApolloLink.Request): ApolloLink.Request {\n if (hasDirectives([\"defer\", \"stream\"], request.query)) {\n const context = request.context ?? {};\n const http = (context.http ??= {});\n http.accept = [\n \"multipart/mixed;deferSpec=20220824\",\n ...(http.accept || []),\n ];\n }\n\n return request;\n }\n startRequest<TData extends Record<string, unknown>>(\n _: Incremental.StartRequestOptions\n ) {\n return new DeferRequest<TData>();\n }\n}\n\n// only exported for use in tests\nexport function hasIncrementalChunks(\n result: Record<string, any>\n): result is Required<Defer20220824Handler.SubsequentResult> {\n return isNonEmptyArray(result.incremental);\n}\n"]}
@@ -1,6 +1,7 @@
1
- import type { DocumentNode, FormattedExecutionResult, GraphQLFormattedError } from "graphql";
1
+ import type { FormattedExecutionResult, GraphQLFormattedError } from "graphql";
2
2
  import type { ApolloLink } from "@apollo/client/link";
3
3
  import type { DeepPartial, HKT } from "@apollo/client/utilities";
4
+ import { DocumentTransform } from "@apollo/client/utilities";
4
5
  import type { Incremental } from "../types.js";
5
6
  export declare namespace GraphQL17Alpha9Handler {
6
7
  interface GraphQL17Alpha9Result extends HKT {
@@ -56,9 +57,32 @@ declare class IncrementalRequest<TData> implements Incremental.IncrementalReques
56
57
  private data;
57
58
  private errors;
58
59
  private extensions;
59
- private pending;
60
- private streamInfo;
60
+ private pendingMap;
61
+ private completedMap;
62
+ private _streamInfo;
61
63
  private streamPositions;
64
+ /**
65
+ * @internal
66
+ *
67
+ * @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
68
+ */
69
+ get streamInfo(): import("@apollo/client/utilities/internal").StreamInfoTrie | undefined;
70
+ /**
71
+ * @internal
72
+ *
73
+ * @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
74
+ */
75
+ getPendingWithInfo(): ({
76
+ type: "stream";
77
+ path: Incremental.Path;
78
+ delivered?: undefined;
79
+ label?: undefined;
80
+ } | {
81
+ type: "defer";
82
+ delivered: boolean;
83
+ path: Incremental.Path;
84
+ label: string | undefined;
85
+ })[];
62
86
  handle(cacheData: TData | DeepPartial<TData> | null | undefined, chunk: GraphQL17Alpha9Handler.Chunk<TData>): FormattedExecutionResult<TData>;
63
87
  private merge;
64
88
  }
@@ -67,6 +91,7 @@ declare class IncrementalRequest<TData> implements Incremental.IncrementalReques
67
91
  * graphql.js version `17.0.0-alpha.9`.
68
92
  */
69
93
  export declare class GraphQL17Alpha9Handler implements Incremental.Handler<GraphQL17Alpha9Handler.Chunk<any>> {
94
+ readonly documentTransform: DocumentTransform;
70
95
  /**
71
96
  * @internal
72
97
  *
@@ -90,9 +115,7 @@ export declare class GraphQL17Alpha9Handler implements Incremental.Handler<Graph
90
115
  *
91
116
  * @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
92
117
  */
93
- startRequest<TData>(_: {
94
- query: DocumentNode;
95
- }): IncrementalRequest<TData>;
118
+ startRequest<TData>(_: Incremental.StartRequestOptions): IncrementalRequest<TData>;
96
119
  }
97
120
  export {};
98
121
  //# sourceMappingURL=graphql17Alpha9.d.ts.map
@@ -1,5 +1,5 @@
1
- import { Trie } from "@wry/trie";
2
- import { DeepMerger, streamInfoSymbol, } from "@apollo/client/utilities/internal";
1
+ import { DocumentTransform } from "@apollo/client/utilities";
2
+ import { addDeferFragmentLabels, DeepMerger, makeStreamInfoTrie, streamInfoSymbol, } from "@apollo/client/utilities/internal";
3
3
  import { hasDirectives, isNonEmptyArray, } from "@apollo/client/utilities/internal";
4
4
  import { invariant } from "@apollo/client/utilities/invariant";
5
5
  class IncrementalRequest {
@@ -7,10 +7,9 @@ class IncrementalRequest {
7
7
  data = {};
8
8
  errors = [];
9
9
  extensions = {};
10
- pending = new Map();
11
- streamInfo = new Trie(false, () => ({
12
- current: { isFirstChunk: true, isLastChunk: false },
13
- }));
10
+ pendingMap = new Map();
11
+ completedMap = new Map();
12
+ _streamInfo = makeStreamInfoTrie();
14
13
  // `streamPositions` maps `pending.id` to the index that should be set by the
15
14
  // next `incremental` stream chunk to ensure the streamed array item is placed
16
15
  // at the correct point in the data array. `this.data` contains cached
@@ -19,28 +18,56 @@ class IncrementalRequest {
19
18
  // updated by the cache between a streamed chunk aren't overwritten by merges
20
19
  // of future stream items from already merged stream items.
21
20
  streamPositions = {};
21
+ /**
22
+ * @internal
23
+ *
24
+ * @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
25
+ */
26
+ get streamInfo() {
27
+ return this._streamInfo["strong"] ? this._streamInfo : undefined;
28
+ }
29
+ /**
30
+ * @internal
31
+ *
32
+ * @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
33
+ */
34
+ getPendingWithInfo() {
35
+ return Array.from(this.pendingMap.values()).map((pending) => {
36
+ if (pending.id in this.streamPositions) {
37
+ return { type: "stream", path: pending.path };
38
+ }
39
+ return {
40
+ type: "defer",
41
+ delivered: !!this.completedMap.get(pending.id),
42
+ path: pending.path,
43
+ label: pending.label,
44
+ };
45
+ });
46
+ }
22
47
  handle(cacheData = this.data, chunk) {
23
48
  this.hasNext = chunk.hasNext;
24
49
  this.data = cacheData;
25
50
  if (chunk.pending) {
26
51
  for (const pending of chunk.pending) {
27
- this.pending.set(pending.id, pending);
52
+ this.pendingMap.set(pending.id, pending);
28
53
  if ("data" in chunk) {
29
54
  const dataAtPath = pending.path.reduce((data, key) => data[key], chunk.data);
30
55
  if (Array.isArray(dataAtPath)) {
31
56
  this.streamPositions[pending.id] = dataAtPath.length;
32
- this.streamInfo.lookupArray(pending.path).current = {
57
+ const entry = this._streamInfo.lookupArray(pending.path);
58
+ entry.current = {
33
59
  isFirstChunk: true,
34
60
  isLastChunk: false,
35
61
  };
62
+ entry.state.streamPosition = dataAtPath.length;
36
63
  }
37
64
  }
38
65
  }
39
66
  }
40
67
  if (hasIncrementalChunks(chunk)) {
41
68
  for (const incremental of chunk.incremental) {
42
- const pending = this.pending.get(incremental.id);
43
- invariant(pending, 66);
69
+ const pending = this.pendingMap.get(incremental.id);
70
+ invariant(pending, 67);
44
71
  const path = pending.path.concat(incremental.subPath ?? []);
45
72
  let data;
46
73
  if ("items" in incremental) {
@@ -53,10 +80,12 @@ class IncrementalRequest {
53
80
  parent[i + this.streamPositions[pending.id]] = items[i];
54
81
  }
55
82
  this.streamPositions[pending.id] += items.length;
56
- this.streamInfo.lookupArray(path).current = {
83
+ const entry = this._streamInfo.lookupArray(path);
84
+ entry.current = {
57
85
  isFirstChunk: false,
58
86
  isLastChunk: false,
59
87
  };
88
+ entry.state.streamPosition = this.streamPositions[pending.id];
60
89
  data = parent;
61
90
  }
62
91
  else {
@@ -65,7 +94,7 @@ class IncrementalRequest {
65
94
  // that we can update streamPositions with the initial length of the
66
95
  // array to ensure future streamed items are inserted at the right
67
96
  // starting index.
68
- this.pending.forEach((pendingItem) => {
97
+ this.pendingMap.forEach((pendingItem) => {
69
98
  if (!(pendingItem.id in this.streamPositions)) {
70
99
  // Check if this incremental data contains array data for the pending path
71
100
  // The pending path is absolute, but incremental data is relative to the defer
@@ -92,8 +121,9 @@ class IncrementalRequest {
92
121
  }
93
122
  if ("completed" in chunk && chunk.completed) {
94
123
  for (const completed of chunk.completed) {
95
- const { path } = this.pending.get(completed.id);
124
+ const { path } = this.pendingMap.get(completed.id);
96
125
  const streamPosition = this.streamPositions[completed.id];
126
+ this.completedMap.set(completed.id, !completed.errors);
97
127
  // Truncate any stream arrays in case the chunk only contains `hasNext`
98
128
  // and `completed`.
99
129
  if (streamPosition !== undefined) {
@@ -101,14 +131,14 @@ class IncrementalRequest {
101
131
  this.merge({ data: dataAtPath.slice(0, streamPosition) }, path);
102
132
  }
103
133
  // peek instead of lookup to avoid creating an entry for non-array values
104
- const details = this.streamInfo.peekArray(path);
134
+ const details = this._streamInfo.peekArray(path);
105
135
  if (details) {
106
136
  details.current = {
107
137
  isFirstChunk: false,
108
138
  isLastChunk: true,
109
139
  };
140
+ details.state.streamPosition = streamPosition;
110
141
  }
111
- this.pending.delete(completed.id);
112
142
  if (completed.errors) {
113
143
  this.errors.push(...completed.errors);
114
144
  }
@@ -121,7 +151,7 @@ class IncrementalRequest {
121
151
  if (Object.keys(this.extensions).length > 0) {
122
152
  result.extensions = this.extensions;
123
153
  }
124
- if (this.streamInfo["strong"]) {
154
+ if (this._streamInfo["strong"]) {
125
155
  result.extensions = {
126
156
  ...result.extensions,
127
157
  // Create a new object so we can check for === in QueryInfo to trigger a
@@ -129,7 +159,7 @@ class IncrementalRequest {
129
159
  // We create a `WeakRef`, not a plain object to avoid retaining memory
130
160
  // in case the `result` or `extensions` stays around longer than the handler
131
161
  // itself.
132
- [streamInfoSymbol]: new WeakRef(this.streamInfo),
162
+ [streamInfoSymbol]: new WeakRef(this._streamInfo),
133
163
  };
134
164
  }
135
165
  return result;
@@ -149,6 +179,7 @@ class IncrementalRequest {
149
179
  * graphql.js version `17.0.0-alpha.9`.
150
180
  */
151
181
  export class GraphQL17Alpha9Handler {
182
+ documentTransform = new DocumentTransform(addDeferFragmentLabels);
152
183
  /**
153
184
  * @internal
154
185
  *