@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
@@ -278,12 +278,8 @@ export declare class ObservableQuery<TData = unknown, TVariables extends Operati
278
278
  readonly options: ObservableQuery.Options<TData, TVariables>;
279
279
  readonly queryName?: string;
280
280
  private variablesUnknown;
281
- /**
282
- * @internal will be read and written from `QueryInfo`
283
- *
284
- * @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
285
- */
286
- _lastWrite?: unknown;
281
+ private didWarnOnFeud;
282
+ private lastMissing?;
287
283
  get query(): TypedDocumentNode<TData, TVariables>;
288
284
  /**
289
285
  * An object containing the variables that were provided for the query.
@@ -349,7 +345,7 @@ export declare class ObservableQuery<TData = unknown, TVariables extends Operati
349
345
  */
350
346
  getCacheDiff({ optimistic }?: {
351
347
  optimistic?: boolean | undefined;
352
- }): Cache.DiffResult<TData>;
348
+ }): Cache.InternalDiffResultWithDataState<TData>;
353
349
  private getInitialResult;
354
350
  private resubscribeCache;
355
351
  private stableLastResult?;
@@ -372,7 +368,18 @@ export declare class ObservableQuery<TData = unknown, TVariables extends Operati
372
368
  /**
373
369
  * A function that helps you fetch the next set of results for a [paginated list field](https://www.apollographql.com/docs/react/pagination/core-api/).
374
370
  */
375
- fetchMore<TFetchData = TData, TFetchVars extends OperationVariables = TVariables>(options: ObservableQuery.FetchMoreOptions<TData, TVariables, TFetchData, TFetchVars>): Promise<ApolloClient.QueryResult<TFetchData>>;
371
+ fetchMore<TFetchData = TData, TFetchVars extends OperationVariables = TVariables, TErrorPolicy extends ErrorPolicy = "none">(options: ObservableQuery.FetchMoreOptions<TData, TVariables, TFetchData, TFetchVars> & {
372
+ /**
373
+ * Specifies how the query handles a response that returns both GraphQL errors and partial results.
374
+ *
375
+ * For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).
376
+ *
377
+ * The default value is `none`, meaning that the query result includes error details but not partial results.
378
+ *
379
+ * @docGroup 1. Operation options
380
+ */
381
+ errorPolicy?: TErrorPolicy;
382
+ }): Promise<ApolloClient.QueryResult<TFetchData, TErrorPolicy>>;
376
383
  /**
377
384
  * A function that enables you to execute a [subscription](https://www.apollographql.com/docs/react/data/subscriptions/), usually to subscribe to specific fields that were included in the query.
378
385
  *
@@ -458,6 +465,7 @@ export declare class ObservableQuery<TData = unknown, TVariables extends Operati
458
465
  * @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
459
466
  */
460
467
  notify(scheduled?: boolean): void;
468
+ private deliverCacheDiff;
461
469
  private activeOperations;
462
470
  private pushOperation;
463
471
  private calculateNetworkStatus;
@@ -1,27 +1,16 @@
1
- "use strict";
1
+ "use strict";;
2
+ const {
3
+ __DEV__
4
+ } = require("@apollo/client/utilities/environment");
5
+
2
6
  Object.defineProperty(exports, "__esModule", { value: true });
3
7
  exports.QueryInfo = void 0;
4
- const equality_1 = require("@wry/equality");
8
+ const trie_1 = require("@wry/trie");
9
+ const environment_1 = require("@apollo/client/utilities/environment");
5
10
  const internal_1 = require("@apollo/client/utilities/internal");
6
11
  const invariant_1 = require("@apollo/client/utilities/invariant");
12
+ const networkStatus_js_1 = require("./networkStatus.cjs");
7
13
  const IGNORE = {};
8
- const destructiveMethodCounts = new WeakMap();
9
- function wrapDestructiveCacheMethod(cache, methodName) {
10
- const original = cache[methodName];
11
- if (typeof original === "function") {
12
- // @ts-expect-error this is just too generic to be typed correctly
13
- cache[methodName] = function () {
14
- destructiveMethodCounts.set(cache,
15
- // The %1e15 allows the count to wrap around to 0 safely every
16
- // quadrillion evictions, so there's no risk of overflow. To be
17
- // clear, this is more of a pedantic principle than something
18
- // that matters in any conceivable practical scenario.
19
- (destructiveMethodCounts.get(cache) + 1) % 1e15);
20
- // @ts-expect-error this is just too generic to be typed correctly
21
- return original.apply(this, arguments);
22
- };
23
- }
24
- }
25
14
  const queryInfoIds = new WeakMap();
26
15
  // A QueryInfo object represents a single network request, either initiated
27
16
  // from the QueryManager or from an ObservableQuery.
@@ -29,182 +18,162 @@ const queryInfoIds = new WeakMap();
29
18
  // It is responsible for reporting results to the cache, merging and in a no-cache
30
19
  // scenario accumulating the response.
31
20
  class QueryInfo {
32
- // TODO remove soon - this should be able to be handled by cancelling old operations before starting new ones
33
- lastRequestId = 1;
34
21
  cache;
35
22
  queryManager;
36
23
  id;
37
24
  observableQuery;
38
25
  incremental;
39
26
  constructor(queryManager, observableQuery) {
40
- const cache = (this.cache = queryManager.cache);
27
+ this.cache = queryManager.cache;
41
28
  const id = (queryInfoIds.get(queryManager) || 0) + 1;
42
29
  queryInfoIds.set(queryManager, id);
43
30
  this.id = id + "";
44
31
  this.observableQuery = observableQuery;
45
32
  this.queryManager = queryManager;
46
- // Track how often cache.evict is called, since we want eviction to
47
- // override the feud-stopping logic in the markQueryResult method, by
48
- // causing shouldWrite to return true. Wrapping the cache.evict method
49
- // is a bit of a hack, but it saves us from having to make eviction
50
- // counting an official part of the ApolloCache API.
51
- if (!destructiveMethodCounts.has(cache)) {
52
- destructiveMethodCounts.set(cache, 0);
53
- wrapDestructiveCacheMethod(cache, "evict");
54
- wrapDestructiveCacheMethod(cache, "modify");
55
- wrapDestructiveCacheMethod(cache, "reset");
56
- }
57
- }
58
- /**
59
- * @internal
60
- * For feud-preventing behaviour, `lastWrite` should be shared by all `QueryInfo` instances of an `ObservableQuery`.
61
- * In the case of a standalone `QueryInfo`, we will keep a local version.
62
- *
63
- * @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
64
- */
65
- _lastWrite;
66
- get lastWrite() {
67
- return (this.observableQuery || this)._lastWrite;
68
- }
69
- set lastWrite(value) {
70
- (this.observableQuery || this)._lastWrite = value;
71
- }
72
- resetLastWrite() {
73
- this.lastWrite = void 0;
74
- }
75
- shouldWrite(result, variables) {
76
- const { lastWrite } = this;
77
- return !(lastWrite &&
78
- // If cache.evict has been called since the last time we wrote this
79
- // data into the cache, there's a chance writing this result into
80
- // the cache will repair what was evicted.
81
- lastWrite.dmCount === destructiveMethodCounts.get(this.cache) &&
82
- (0, equality_1.equal)(variables, lastWrite.variables) &&
83
- (0, equality_1.equal)(result.data, lastWrite.result.data) &&
84
- // We have to compare these values because its possible the final chunk
85
- // emitted in the incremental result is just `hasNext: false`. This
86
- // ensures we trigger a cache write when we get `isLastChunk: true`.
87
- result.extensions?.[internal_1.streamInfoSymbol] ===
88
- lastWrite.result.extensions?.[internal_1.streamInfoSymbol]);
89
33
  }
90
34
  get hasNext() {
91
35
  return this.incremental ? this.incremental.hasNext : false;
92
36
  }
37
+ get incrementalHandler() {
38
+ return this.queryManager.incrementalHandler;
39
+ }
93
40
  maybeHandleIncrementalResult(cacheData, incoming, query) {
94
- const { incrementalHandler } = this.queryManager;
95
- if (incrementalHandler.isIncrementalResult(incoming)) {
96
- this.incremental ||= incrementalHandler.startRequest({
41
+ if (this.incrementalHandler.isIncrementalResult(incoming)) {
42
+ this.incremental ||= this.incrementalHandler.startRequest({
97
43
  query,
98
44
  });
99
45
  return this.incremental.handle(cacheData, incoming);
100
46
  }
101
47
  return incoming;
102
48
  }
103
- markQueryResult(incoming, { document: query, variables, errorPolicy, cacheWriteBehavior, }) {
49
+ markQueryResult(incoming, { document: query, variables, errorPolicy, cacheWriteBehavior, returnPartialData, fetchPolicy, networkStatus, prunePendingDeferFragments: prune, }) {
104
50
  const diffOptions = {
105
51
  query,
106
52
  variables,
107
- returnPartialData: true,
108
53
  optimistic: true,
109
54
  };
110
55
  // Cancel the pending notify timeout (if it exists) to prevent extraneous network
111
56
  // requests. To allow future notify timeouts, diff and dirty are reset as well.
112
57
  this.observableQuery?.["resetNotifications"]();
113
58
  const skipCache = cacheWriteBehavior === 0 /* CacheWriteBehavior.FORBID */;
114
- const lastDiff = skipCache ? undefined : this.cache.diff(diffOptions);
115
- let result = this.maybeHandleIncrementalResult(lastDiff?.result, incoming, query);
116
- if (skipCache) {
117
- return result;
118
- }
119
- if (shouldWriteResult(result, errorPolicy)) {
120
- // Using a transaction here so we have a chance to read the result
121
- // back from the cache before the watch callback fires as a result
122
- // of writeQuery, so we can store the new diff quietly and ignore
123
- // it when we receive it redundantly from the watch callback.
124
- this.cache.batch({
125
- onWatchUpdated: (
126
- // all additional options on ObservableQuery.CacheWatchOptions are
127
- // optional so we can use the type here
128
- watch, diff) => {
129
- if (watch.watcher === this.observableQuery) {
130
- // see comment on `lastOwnDiff` for explanation
131
- watch.lastOwnDiff = diff;
132
- }
133
- },
134
- update: (cache) => {
135
- if (this.shouldWrite(result, variables)) {
136
- cache.writeQuery({
137
- query,
138
- data: result.data,
139
- variables,
140
- overwrite: cacheWriteBehavior === 1 /* CacheWriteBehavior.OVERWRITE */,
141
- extensions: result.extensions,
142
- });
143
- this.lastWrite = {
144
- result,
145
- variables,
146
- dmCount: destructiveMethodCounts.get(this.cache),
147
- };
148
- }
149
- else {
150
- // If result is the same as the last result we received from
151
- // the network (and the variables match too), avoid writing
152
- // result into the cache again. The wisdom of skipping this
153
- // cache write is far from obvious, since any cache write
154
- // could be the one that puts the cache back into a desired
155
- // state, fixing corruption or missing data. However, if we
156
- // always write every network result into the cache, we enable
157
- // feuds between queries competing to update the same data in
158
- // incompatible ways, which can lead to an endless cycle of
159
- // cache broadcasts and useless network requests. As with any
160
- // feud, eventually one side must step back from the brink,
161
- // letting the other side(s) have the last word(s). There may
162
- // be other points where we could break this cycle, such as
163
- // silencing the broadcast for cache.writeQuery (not a good
164
- // idea, since it just delays the feud a bit) or somehow
165
- // avoiding the network request that just happened (also bad,
166
- // because the server could return useful new data). All
167
- // options considered, skipping this cache write seems to be
168
- // the least damaging place to break the cycle, because it
169
- // reflects the intuition that we recently wrote this exact
170
- // result into the cache, so the cache *should* already/still
171
- // contain this data. If some other query has clobbered that
172
- // data in the meantime, that's too bad, but there will be no
173
- // winners if every query blindly reverts to its own version
174
- // of the data. This approach also gives the network a chance
175
- // to return new data, which will be written into the cache as
176
- // usual, notifying only those queries that are directly
177
- // affected by the cache updates, as usual. In the future, an
178
- // even more sophisticated cache could perhaps prevent or
179
- // mitigate the clobbering somehow, but that would make this
180
- // particular cache write even less important, and thus
181
- // skipping it would be even safer than it is today.
182
- if (lastDiff && lastDiff.complete) {
183
- // Reuse data from the last good (complete) diff that we
184
- // received, when possible.
185
- result = { ...result, data: lastDiff.result };
186
- return;
187
- }
188
- // If the previous this.diff was incomplete, fall through to
189
- // re-reading the latest data with cache.diff, below.
190
- }
191
- const diff = cache.diff(diffOptions);
192
- // If we're allowed to write to the cache, and we can read a
193
- // complete result from the cache, update result.data to be the
194
- // result from the cache, rather than the raw network result.
195
- // Set without setDiff to avoid triggering a notify call, since
196
- // we have other ways of notifying for this result.
197
- if (diff.complete) {
198
- result = { ...result, data: diff.result };
199
- }
200
- },
201
- });
59
+ const diff = skipCache ? undefined : (this.getDiff({
60
+ ...diffOptions,
61
+ // We usually request partial data to ensure the network incremental
62
+ // result is merged with all existing data (especially true to
63
+ // maintain @stream arrays with partial list items in the right order
64
+ // or when chunk might otherwise replace a partial non-normalized
65
+ // object), but if we are about to throw away the result anyways due
66
+ // to the error policy (which early returns below), prune any
67
+ // pending boundaries so that CombinedGraphQLErrors contains the
68
+ // right `data` value.
69
+ returnPartialData: errorPolicy !== "none" ||
70
+ !this.incrementalHandler.extractErrors(incoming)?.length,
71
+ }, this.getIncrementalInfo({ prune })));
72
+ const incrementalResult = this.maybeHandleIncrementalResult(diff?.result, incoming, query);
73
+ let result = {
74
+ ...incrementalResult,
75
+ dataState: incrementalResult.data == null ? "empty" : "complete",
76
+ };
77
+ const hasPendingDefer = this.incremental
78
+ ?.getPendingWithInfo?.()
79
+ .some((pending) => pending.type === "defer" && !pending.delivered);
80
+ if (hasPendingDefer ||
81
+ // The Defer20220824Handler cannot track pending/completed incremental
82
+ // chunks due to its data format so we naively set dataState to
83
+ // streaming if we are still processing chunks. The only case where
84
+ // streaming is incorrect and should actually be complete is when
85
+ // both a @defer and @stream boundary is present and the @defer chunk
86
+ // has completed before the `@stream` array.
87
+ //
88
+ // Assigning the naive "streaming" value avoids a much more expensive
89
+ // pass over `result.data` that would otherwise need to traverse the
90
+ // selection sets and evaluate the data object at each defer boundary
91
+ // to see if it fulfills the selection set. For such a narrow case where
92
+ // its incorrect on a format that is now outdated is not worth the
93
+ // fix so we are ok with reporting a `streaming` here.
94
+ (!this.incremental?.getPendingWithInfo &&
95
+ this.hasNext &&
96
+ (0, internal_1.hasDirectives)(["defer"], query))) {
97
+ result.dataState = "streaming";
202
98
  }
203
- else {
204
- this.lastWrite = void 0;
99
+ if (skipCache || !shouldWriteResult(result, errorPolicy)) {
100
+ return result;
205
101
  }
102
+ // Using a transaction here so we have a chance to read the result
103
+ // back from the cache before the watch callback fires as a result
104
+ // of writeQuery, so we can store the new diff quietly and ignore
105
+ // it when we receive it redundantly from the watch callback.
106
+ this.cache.batch({
107
+ onWatchUpdated: (
108
+ // all additional options on ObservableQuery.CacheWatchOptions are
109
+ // optional so we can use the type here
110
+ watch, diff) => {
111
+ if (watch.watcher === this.observableQuery) {
112
+ // see comment on `lastOwnDiff` for explanation
113
+ watch.lastOwnDiff = diff;
114
+ }
115
+ },
116
+ update: (cache) => {
117
+ cache.writeQuery({
118
+ query,
119
+ data: result.data,
120
+ variables,
121
+ overwrite: cacheWriteBehavior === 1 /* CacheWriteBehavior.OVERWRITE */,
122
+ extensions: result.extensions,
123
+ });
124
+ const { dataState, result: diffResult } = this.getDiff({
125
+ ...diffOptions,
126
+ returnPartialData: returnPartialData &&
127
+ // Never deliver partial data for network-only requests
128
+ (fetchPolicy !== "network-only" ||
129
+ networkStatus === networkStatus_js_1.NetworkStatus.refetch),
130
+ }, this.getIncrementalInfo({ prune }));
131
+ if (dataState === "complete" ||
132
+ dataState === "streaming" ||
133
+ (returnPartialData && dataState === "partial")) {
134
+ result = { ...result, data: diffResult, dataState };
135
+ }
136
+ else if (environment_1.__DEV__ &&
137
+ // A result that is still streaming is expected to read back
138
+ // incomplete until the remaining chunks arrive.
139
+ !this.hasNext) {
140
+ warnAboutPartialCacheResult(query, result.data,
141
+ // Always show the partial result for debugging, otherwise the user
142
+ // sees `null` when `returnPartialData` is false which isn't helpful
143
+ // for figuring out where the problem is.
144
+ cache.diff({ ...diffOptions, returnPartialData: true }));
145
+ }
146
+ },
147
+ });
206
148
  return result;
207
149
  }
150
+ getIncrementalInfo({ prune }) {
151
+ const pending = this.incremental?.getPendingWithInfo?.() ?? [];
152
+ const streamInfo = this.incremental?.streamInfo;
153
+ const incrementalInfo = { streamInfo };
154
+ // We don't want to deliver stream items or complete defer boundaries
155
+ // for a network-only request if they haven't yet streamed from the
156
+ // network. We record all the still-pending paths so that cache.diff
157
+ // can prune complete defer/stream boundaries at those paths.
158
+ if (prune) {
159
+ for (const item of pending) {
160
+ if (item.type === "defer" && !item.delivered) {
161
+ incrementalInfo.deferInfo ||= new trie_1.Trie(true, () => true);
162
+ incrementalInfo.deferInfo.lookupArray(item.path.concat(item.label || []));
163
+ }
164
+ else if (streamInfo && item.type === "stream") {
165
+ streamInfo.lookupArray(item.path).state.truncate = true;
166
+ }
167
+ }
168
+ }
169
+ return incrementalInfo;
170
+ }
171
+ getDiff(options, incrementalInfo) {
172
+ return (0, internal_1.toDiffWithDataState)(this.cache.diff({
173
+ ...options,
174
+ [internal_1.handleIncrementalSymbol]: incrementalInfo,
175
+ }));
176
+ }
208
177
  markMutationResult(incoming, mutation, cache = this.cache) {
209
178
  const cacheWrites = [];
210
179
  const skipCache = mutation.cacheWriteBehavior === 0 /* CacheWriteBehavior.FORBID */;
@@ -292,38 +261,34 @@ class QueryInfo {
292
261
  const { update } = mutation;
293
262
  // Determine whether result is a SingleExecutionResult,
294
263
  // or the final ExecutionPatchResult.
295
- if (update) {
296
- if (!skipCache) {
297
- // Re-read the ROOT_MUTATION data we just wrote into the cache
298
- // (the first cache.write call in the cacheWrites.forEach loop
299
- // above), so field read functions have a chance to run for
300
- // fields within mutation result objects.
301
- const diff = cache.diff({
302
- id: "ROOT_MUTATION",
303
- // The cache complains if passed a mutation where it expects a
304
- // query, so we transform mutations and subscriptions to queries
305
- // (only once, thanks to this.transformCache).
306
- query: this.queryManager.getDocumentInfo(mutation.document)
307
- .asQuery,
308
- variables: mutation.variables,
309
- optimistic: false,
310
- returnPartialData: true,
311
- });
312
- if (diff.complete) {
313
- result = {
314
- ...result,
315
- data: diff.result,
316
- };
317
- }
318
- }
319
- // If we've received the whole response, call the update function.
320
- if (!this.hasNext) {
321
- update(cache, result, {
322
- context: mutation.context,
323
- variables: mutation.variables,
324
- });
264
+ // Re-read from the cache after writing to it to update `result`
265
+ // with any parsed scalar values that might have been written.
266
+ if (!skipCache) {
267
+ const diff = cache.diff({
268
+ id: "ROOT_MUTATION",
269
+ // The cache complains if passed a mutation where it expects a
270
+ // query, so we transform mutations and subscriptions to queries
271
+ // (only once, thanks to this.transformCache).
272
+ query: this.queryManager.getDocumentInfo(mutation.document)
273
+ .asQuery,
274
+ variables: mutation.variables,
275
+ optimistic: false,
276
+ returnPartialData: true,
277
+ });
278
+ if (diff.complete) {
279
+ result = {
280
+ ...result,
281
+ data: diff.result,
282
+ };
325
283
  }
326
284
  }
285
+ // If we've received the whole response, call the update function.
286
+ if (update && !this.hasNext) {
287
+ update(cache, result, {
288
+ context: mutation.context,
289
+ variables: mutation.variables,
290
+ });
291
+ }
327
292
  // TODO Do this with cache.evict({ id: 'ROOT_MUTATION' }) but make it
328
293
  // shallow to allow rolling back optimistic evictions.
329
294
  if (!skipCache && !mutation.keepRootFields && !this.hasNext) {
@@ -384,12 +349,35 @@ class QueryInfo {
384
349
  variables: variables,
385
350
  extensions: result.extensions,
386
351
  });
352
+ // Re-read from the cache to get parsed scalar values
353
+ const diff = this.cache.diff({
354
+ // The cache complains if passed a mutation where it expects a
355
+ // query, so we transform mutations and subscriptions to queries
356
+ // (only once, thanks to this.transformCache).
357
+ query: this.queryManager.getDocumentInfo(document).asQuery,
358
+ id: "ROOT_SUBSCRIPTION",
359
+ variables,
360
+ optimistic: false,
361
+ returnPartialData: true,
362
+ });
363
+ if (diff.complete) {
364
+ result.data = diff.result;
365
+ }
387
366
  }
388
367
  this.queryManager.broadcastQueries();
389
368
  }
390
369
  }
391
370
  }
392
371
  exports.QueryInfo = QueryInfo;
372
+ function warnAboutPartialCacheResult(query, networkResult, diff) {
373
+ __DEV__ && invariant_1.invariant.warn(
374
+ 91,
375
+ (0, internal_1.getOperationName)(query, "(anonymous)"),
376
+ diff.missing?.missing,
377
+ networkResult,
378
+ diff.result
379
+ );
380
+ }
393
381
  function shouldWriteResult(result, errorPolicy = "none") {
394
382
  const ignoreErrors = errorPolicy === "ignore" || errorPolicy === "all";
395
383
  let writeWithErrors = !(0, internal_1.graphQLResultHasError)(result);