@apollo/client 4.0.0-alpha.21 → 4.0.0-alpha.23

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 (379) hide show
  1. package/CHANGELOG.md +341 -2
  2. package/__cjs/cache/core/cache.cjs +1 -1
  3. package/__cjs/cache/inmemory/entityStore.cjs +3 -3
  4. package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
  5. package/__cjs/cache/inmemory/key-extractor.cjs.map +1 -1
  6. package/__cjs/cache/inmemory/policies.cjs +4 -4
  7. package/__cjs/cache/inmemory/policies.cjs.map +1 -1
  8. package/__cjs/cache/inmemory/readFromStore.cjs +2 -2
  9. package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
  10. package/__cjs/core/ApolloClient.cjs +24 -19
  11. package/__cjs/core/ApolloClient.cjs.map +1 -1
  12. package/__cjs/core/ApolloClient.d.cts +15 -11
  13. package/__cjs/core/ObservableQuery.cjs +52 -48
  14. package/__cjs/core/ObservableQuery.cjs.map +1 -1
  15. package/__cjs/core/ObservableQuery.d.cts +48 -14
  16. package/__cjs/core/QueryInfo.cjs +146 -168
  17. package/__cjs/core/QueryInfo.cjs.map +1 -1
  18. package/__cjs/core/QueryInfo.d.cts +14 -11
  19. package/__cjs/core/QueryManager.cjs +138 -123
  20. package/__cjs/core/QueryManager.cjs.map +1 -1
  21. package/__cjs/core/QueryManager.d.cts +17 -6
  22. package/__cjs/core/index.cjs +2 -1
  23. package/__cjs/core/index.cjs.map +1 -1
  24. package/__cjs/core/index.d.cts +4 -4
  25. package/__cjs/core/types.d.cts +72 -18
  26. package/__cjs/core/watchQueryOptions.d.cts +2 -24
  27. package/__cjs/dev/setErrorMessageHandler.cjs.map +1 -1
  28. package/__cjs/errors/CombinedGraphQLErrors.cjs +6 -3
  29. package/__cjs/errors/CombinedGraphQLErrors.cjs.map +1 -1
  30. package/__cjs/errors/CombinedGraphQLErrors.d.cts +7 -2
  31. package/__cjs/errors/index.cjs +1 -1
  32. package/__cjs/errors/index.cjs.map +1 -1
  33. package/__cjs/errors/index.d.cts +1 -3
  34. package/__cjs/incremental/handlers/defer20220824.cjs +102 -0
  35. package/__cjs/incremental/handlers/defer20220824.cjs.map +1 -0
  36. package/__cjs/incremental/handlers/defer20220824.d.cts +55 -0
  37. package/__cjs/incremental/handlers/notImplemented.cjs +19 -0
  38. package/__cjs/incremental/handlers/notImplemented.cjs.map +1 -0
  39. package/__cjs/incremental/handlers/notImplemented.d.cts +9 -0
  40. package/__cjs/incremental/index.cjs +9 -0
  41. package/__cjs/incremental/index.cjs.map +1 -0
  42. package/__cjs/incremental/index.d.cts +4 -0
  43. package/__cjs/incremental/types.cjs +3 -0
  44. package/__cjs/incremental/types.cjs.map +1 -0
  45. package/__cjs/incremental/types.d.cts +24 -0
  46. package/__cjs/invariantErrorCodes.cjs +131 -114
  47. package/__cjs/link/batch-http/batchHttpLink.cjs +14 -14
  48. package/__cjs/link/batch-http/batchHttpLink.cjs.map +1 -1
  49. package/__cjs/link/batch-http/batchHttpLink.d.cts +4 -0
  50. package/__cjs/link/batch-http/index.cjs +2 -1
  51. package/__cjs/link/batch-http/index.cjs.map +1 -1
  52. package/__cjs/link/batch-http/index.d.cts +1 -1
  53. package/__cjs/link/client-awareness/ClientAwarenessLink.cjs +45 -0
  54. package/__cjs/link/client-awareness/ClientAwarenessLink.cjs.map +1 -0
  55. package/__cjs/link/client-awareness/ClientAwarenessLink.d.cts +62 -0
  56. package/__cjs/link/client-awareness/index.cjs +6 -0
  57. package/__cjs/link/client-awareness/index.cjs.map +1 -0
  58. package/__cjs/link/client-awareness/index.d.cts +2 -0
  59. package/__cjs/link/context/index.cjs +36 -25
  60. package/__cjs/link/context/index.cjs.map +1 -1
  61. package/__cjs/link/context/index.d.cts +8 -1
  62. package/__cjs/link/core/types.d.cts +5 -38
  63. package/__cjs/link/error/index.cjs +68 -65
  64. package/__cjs/link/error/index.cjs.map +1 -1
  65. package/__cjs/link/error/index.d.cts +15 -14
  66. package/__cjs/link/http/BaseHttpLink.cjs +111 -0
  67. package/__cjs/link/http/BaseHttpLink.cjs.map +1 -0
  68. package/__cjs/link/http/BaseHttpLink.d.cts +6 -0
  69. package/__cjs/link/http/HttpLink.cjs +12 -5
  70. package/__cjs/link/http/HttpLink.cjs.map +1 -1
  71. package/__cjs/link/http/HttpLink.d.cts +20 -4
  72. package/__cjs/link/http/checkFetcher.cjs +1 -1
  73. package/__cjs/link/http/index.cjs +4 -3
  74. package/__cjs/link/http/index.cjs.map +1 -1
  75. package/__cjs/link/http/index.d.cts +2 -2
  76. package/__cjs/link/http/parseAndCheckHttpResponse.cjs +45 -57
  77. package/__cjs/link/http/parseAndCheckHttpResponse.cjs.map +1 -1
  78. package/__cjs/link/http/selectHttpOptionsAndBody.cjs +6 -5
  79. package/__cjs/link/http/selectHttpOptionsAndBody.cjs.map +1 -1
  80. package/__cjs/link/index.cjs.map +1 -1
  81. package/__cjs/link/index.d.cts +1 -1
  82. package/__cjs/link/persisted-queries/index.cjs +159 -141
  83. package/__cjs/link/persisted-queries/index.cjs.map +1 -1
  84. package/__cjs/link/persisted-queries/index.d.cts +19 -19
  85. package/__cjs/link/remove-typename/index.cjs +2 -1
  86. package/__cjs/link/remove-typename/index.cjs.map +1 -1
  87. package/__cjs/link/remove-typename/index.d.cts +1 -1
  88. package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs +34 -23
  89. package/__cjs/link/remove-typename/removeTypenameFromVariables.cjs.map +1 -1
  90. package/__cjs/link/remove-typename/removeTypenameFromVariables.d.cts +8 -9
  91. package/__cjs/link/utils/validateOperation.cjs +1 -1
  92. package/__cjs/local-state/LocalState.cjs +10 -18
  93. package/__cjs/local-state/LocalState.cjs.map +1 -1
  94. package/__cjs/local-state/LocalState.d.cts +3 -4
  95. package/__cjs/masking/maskDefinition.cjs +2 -2
  96. package/__cjs/masking/maskFragment.cjs +2 -2
  97. package/__cjs/masking/maskOperation.cjs +1 -1
  98. package/__cjs/masking/types.d.cts +6 -5
  99. package/__cjs/masking/utils.cjs +3 -3
  100. package/__cjs/react/context/ApolloConsumer.cjs +1 -1
  101. package/__cjs/react/context/ApolloContext.cjs +1 -1
  102. package/__cjs/react/context/ApolloProvider.cjs +1 -1
  103. package/__cjs/react/hooks/internal/validateSuspenseHookOptions.cjs +2 -2
  104. package/__cjs/react/hooks/useApolloClient.cjs +1 -1
  105. package/__cjs/react/hooks/useBackgroundQuery.cjs +1 -0
  106. package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
  107. package/__cjs/react/hooks/useFragment.cjs +1 -0
  108. package/__cjs/react/hooks/useFragment.cjs.map +1 -1
  109. package/__cjs/react/hooks/useLazyQuery.cjs +4 -4
  110. package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
  111. package/__cjs/react/hooks/useLazyQuery.d.cts +2 -7
  112. package/__cjs/react/hooks/useLoadableQuery.cjs +2 -2
  113. package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
  114. package/__cjs/react/hooks/useMutation.cjs.map +1 -1
  115. package/__cjs/react/hooks/useMutation.d.cts +2 -2
  116. package/__cjs/react/hooks/useQuery.cjs +23 -21
  117. package/__cjs/react/hooks/useQuery.cjs.map +1 -1
  118. package/__cjs/react/hooks/useQuery.d.cts +3 -8
  119. package/__cjs/react/hooks/useQueryRefHandlers.cjs +1 -0
  120. package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
  121. package/__cjs/react/hooks/useReadQuery.cjs +1 -0
  122. package/__cjs/react/hooks/useReadQuery.cjs.map +1 -1
  123. package/__cjs/react/hooks/useSubscription.cjs +1 -1
  124. package/__cjs/react/hooks/useSuspenseFragment.cjs +1 -0
  125. package/__cjs/react/hooks/useSuspenseFragment.cjs.map +1 -1
  126. package/__cjs/react/hooks/useSuspenseQuery.cjs +1 -0
  127. package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
  128. package/__cjs/react/hooks/useSyncExternalStore.cjs +1 -1
  129. package/__cjs/react/internal/cache/QueryReference.cjs +5 -5
  130. package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
  131. package/__cjs/react/internal/cache/QueryReference.d.cts +2 -3
  132. package/__cjs/react/internal/types.d.cts +2 -7
  133. package/__cjs/react/ssr/prerenderStatic.cjs +2 -2
  134. package/__cjs/testing/core/mocking/mockLink.cjs +4 -4
  135. package/__cjs/utilities/caching/sizes.cjs.map +1 -1
  136. package/__cjs/utilities/caching/sizes.d.cts +6 -0
  137. package/__cjs/utilities/graphql/DocumentTransform.cjs +1 -1
  138. package/__cjs/utilities/graphql/isFormattedExecutionResult.cjs +9 -0
  139. package/__cjs/utilities/graphql/isFormattedExecutionResult.cjs.map +1 -0
  140. package/__cjs/utilities/graphql/isFormattedExecutionResult.d.cts +3 -0
  141. package/__cjs/utilities/index.cjs +3 -1
  142. package/__cjs/utilities/index.cjs.map +1 -1
  143. package/__cjs/utilities/index.d.cts +1 -0
  144. package/__cjs/utilities/internal/checkDocument.cjs +47 -13
  145. package/__cjs/utilities/internal/checkDocument.cjs.map +1 -1
  146. package/__cjs/utilities/internal/checkDocument.d.cts +1 -1
  147. package/__cjs/utilities/internal/getFragmentDefinition.cjs +3 -3
  148. package/__cjs/utilities/internal/getFragmentFromSelection.cjs +1 -1
  149. package/__cjs/utilities/internal/getFragmentQueryDocument.cjs +2 -2
  150. package/__cjs/utilities/internal/getGraphQLErrorsFromResult.cjs +1 -12
  151. package/__cjs/utilities/internal/getGraphQLErrorsFromResult.cjs.map +1 -1
  152. package/__cjs/utilities/internal/getGraphQLErrorsFromResult.d.cts +4 -2
  153. package/__cjs/utilities/internal/getMainDefinition.cjs +1 -1
  154. package/__cjs/utilities/internal/getMemoryInternals.cjs +1 -0
  155. package/__cjs/utilities/internal/getMemoryInternals.cjs.map +1 -1
  156. package/__cjs/utilities/internal/getMemoryInternals.d.cts +0 -1
  157. package/__cjs/utilities/internal/getQueryDefinition.cjs +1 -1
  158. package/__cjs/utilities/internal/graphQLResultHasError.cjs +1 -4
  159. package/__cjs/utilities/internal/graphQLResultHasError.cjs.map +1 -1
  160. package/__cjs/utilities/internal/graphQLResultHasError.d.cts +2 -2
  161. package/__cjs/utilities/internal/index.cjs +2 -10
  162. package/__cjs/utilities/internal/index.cjs.map +1 -1
  163. package/__cjs/utilities/internal/index.d.cts +0 -4
  164. package/__cjs/utilities/internal/removeDirectivesFromDocument.cjs +1 -1
  165. package/__cjs/utilities/internal/shouldInclude.cjs +4 -4
  166. package/__cjs/utilities/internal/valueToObjectRepresentation.cjs +1 -1
  167. package/__cjs/version.cjs +3 -2
  168. package/__cjs/version.cjs.map +1 -1
  169. package/__cjs/version.d.cts +1 -0
  170. package/cache/core/cache.js +1 -1
  171. package/cache/inmemory/entityStore.js +3 -3
  172. package/cache/inmemory/key-extractor.js +1 -1
  173. package/cache/inmemory/key-extractor.js.map +1 -1
  174. package/cache/inmemory/policies.js +4 -4
  175. package/cache/inmemory/policies.js.map +1 -1
  176. package/cache/inmemory/readFromStore.js +2 -2
  177. package/cache/inmemory/writeToStore.js +4 -4
  178. package/core/ApolloClient.d.ts +15 -11
  179. package/core/ApolloClient.js +25 -20
  180. package/core/ApolloClient.js.map +1 -1
  181. package/core/ObservableQuery.d.ts +48 -14
  182. package/core/ObservableQuery.js +53 -49
  183. package/core/ObservableQuery.js.map +1 -1
  184. package/core/QueryInfo.d.ts +14 -11
  185. package/core/QueryInfo.js +147 -169
  186. package/core/QueryInfo.js.map +1 -1
  187. package/core/QueryManager.d.ts +17 -6
  188. package/core/QueryManager.js +140 -125
  189. package/core/QueryManager.js.map +1 -1
  190. package/core/index.d.ts +4 -4
  191. package/core/index.js +1 -1
  192. package/core/index.js.map +1 -1
  193. package/core/types.d.ts +72 -18
  194. package/core/watchQueryOptions.d.ts +2 -24
  195. package/dev/setErrorMessageHandler.js.map +1 -1
  196. package/errors/CombinedGraphQLErrors.d.ts +7 -2
  197. package/errors/CombinedGraphQLErrors.js +6 -3
  198. package/errors/CombinedGraphQLErrors.js.map +1 -1
  199. package/errors/index.d.ts +1 -3
  200. package/errors/index.js +1 -1
  201. package/errors/index.js.map +1 -1
  202. package/incremental/handlers/defer20220824.d.ts +55 -0
  203. package/incremental/handlers/defer20220824.js +97 -0
  204. package/incremental/handlers/defer20220824.js.map +1 -0
  205. package/incremental/handlers/notImplemented.d.ts +9 -0
  206. package/incremental/handlers/notImplemented.js +15 -0
  207. package/incremental/handlers/notImplemented.js.map +1 -0
  208. package/incremental/index.d.ts +4 -0
  209. package/incremental/index.js +3 -0
  210. package/incremental/index.js.map +1 -0
  211. package/incremental/types.d.ts +24 -0
  212. package/incremental/types.js +2 -0
  213. package/incremental/types.js.map +1 -0
  214. package/invariantErrorCodes.js +132 -118
  215. package/legacyEntryPoints/incremental/incremental.cjs +1 -0
  216. package/legacyEntryPoints/incremental/incremental.d.cts +1 -0
  217. package/legacyEntryPoints/incremental/index.d.ts +1 -0
  218. package/legacyEntryPoints/incremental/index.js +1 -0
  219. package/legacyEntryPoints/link/client-awareness/client-awareness.cjs +1 -0
  220. package/legacyEntryPoints/link/client-awareness/client-awareness.d.cts +1 -0
  221. package/legacyEntryPoints/link/client-awareness/index.d.ts +1 -0
  222. package/legacyEntryPoints/link/client-awareness/index.js +1 -0
  223. package/link/batch-http/batchHttpLink.d.ts +4 -0
  224. package/link/batch-http/batchHttpLink.js +11 -12
  225. package/link/batch-http/batchHttpLink.js.map +1 -1
  226. package/link/batch-http/index.d.ts +1 -1
  227. package/link/batch-http/index.js +1 -1
  228. package/link/batch-http/index.js.map +1 -1
  229. package/link/client-awareness/ClientAwarenessLink.d.ts +62 -0
  230. package/link/client-awareness/ClientAwarenessLink.js +41 -0
  231. package/link/client-awareness/ClientAwarenessLink.js.map +1 -0
  232. package/link/client-awareness/index.d.ts +2 -0
  233. package/link/client-awareness/index.js +2 -0
  234. package/link/client-awareness/index.js.map +1 -0
  235. package/link/context/index.d.ts +8 -1
  236. package/link/context/index.js +34 -25
  237. package/link/context/index.js.map +1 -1
  238. package/link/core/types.d.ts +5 -38
  239. package/link/error/index.d.ts +15 -14
  240. package/link/error/index.js +68 -65
  241. package/link/error/index.js.map +1 -1
  242. package/link/http/BaseHttpLink.d.ts +6 -0
  243. package/link/http/BaseHttpLink.js +107 -0
  244. package/link/http/BaseHttpLink.js.map +1 -0
  245. package/link/http/HttpLink.d.ts +20 -4
  246. package/link/http/HttpLink.js +10 -4
  247. package/link/http/HttpLink.js.map +1 -1
  248. package/link/http/checkFetcher.js +1 -1
  249. package/link/http/index.d.ts +2 -2
  250. package/link/http/index.js +2 -2
  251. package/link/http/index.js.map +1 -1
  252. package/link/http/parseAndCheckHttpResponse.js +45 -57
  253. package/link/http/parseAndCheckHttpResponse.js.map +1 -1
  254. package/link/http/selectHttpOptionsAndBody.js +6 -5
  255. package/link/http/selectHttpOptionsAndBody.js.map +1 -1
  256. package/link/index.d.ts +1 -1
  257. package/link/index.js.map +1 -1
  258. package/link/persisted-queries/index.d.ts +19 -19
  259. package/link/persisted-queries/index.js +157 -140
  260. package/link/persisted-queries/index.js.map +1 -1
  261. package/link/remove-typename/index.d.ts +1 -1
  262. package/link/remove-typename/index.js +1 -1
  263. package/link/remove-typename/index.js.map +1 -1
  264. package/link/remove-typename/removeTypenameFromVariables.d.ts +8 -9
  265. package/link/remove-typename/removeTypenameFromVariables.js +32 -22
  266. package/link/remove-typename/removeTypenameFromVariables.js.map +1 -1
  267. package/link/utils/validateOperation.js +1 -1
  268. package/local-state/LocalState.d.ts +3 -4
  269. package/local-state/LocalState.js +10 -18
  270. package/local-state/LocalState.js.map +1 -1
  271. package/masking/maskDefinition.js +2 -2
  272. package/masking/maskFragment.js +2 -2
  273. package/masking/maskOperation.js +1 -1
  274. package/masking/types.d.ts +6 -5
  275. package/masking/utils.js +3 -3
  276. package/package.json +15 -2
  277. package/react/context/ApolloConsumer.js +1 -1
  278. package/react/context/ApolloContext.js +1 -1
  279. package/react/context/ApolloProvider.js +1 -1
  280. package/react/hooks/internal/validateSuspenseHookOptions.js +2 -2
  281. package/react/hooks/useApolloClient.js +15 -2
  282. package/react/hooks/useApolloClient.js.map +1 -1
  283. package/react/hooks/useBackgroundQuery.js +7 -6
  284. package/react/hooks/useBackgroundQuery.js.map +1 -1
  285. package/react/hooks/useFragment.js +12 -11
  286. package/react/hooks/useFragment.js.map +1 -1
  287. package/react/hooks/useLazyQuery.d.ts +2 -7
  288. package/react/hooks/useLazyQuery.js +17 -17
  289. package/react/hooks/useLazyQuery.js.map +1 -1
  290. package/react/hooks/useLoadableQuery.js +229 -69
  291. package/react/hooks/useLoadableQuery.js.map +1 -1
  292. package/react/hooks/useMutation.d.ts +2 -2
  293. package/react/hooks/useMutation.js +191 -81
  294. package/react/hooks/useMutation.js.map +1 -1
  295. package/react/hooks/useQuery.d.ts +3 -8
  296. package/react/hooks/useQuery.js +243 -70
  297. package/react/hooks/useQuery.js.map +1 -1
  298. package/react/hooks/useQueryRefHandlers.js +64 -23
  299. package/react/hooks/useQueryRefHandlers.js.map +1 -1
  300. package/react/hooks/useReadQuery.js +3 -2
  301. package/react/hooks/useReadQuery.js.map +1 -1
  302. package/react/hooks/useSubscription.js +5 -5
  303. package/react/hooks/useSubscription.js.map +1 -1
  304. package/react/hooks/useSuspenseFragment.js +1 -0
  305. package/react/hooks/useSuspenseFragment.js.map +1 -1
  306. package/react/hooks/useSuspenseQuery.js +59 -33
  307. package/react/hooks/useSuspenseQuery.js.map +1 -1
  308. package/react/hooks/useSyncExternalStore.js +1 -1
  309. package/react/internal/cache/QueryReference.d.ts +2 -3
  310. package/react/internal/cache/QueryReference.js +5 -5
  311. package/react/internal/cache/QueryReference.js.map +1 -1
  312. package/react/internal/types.d.ts +2 -7
  313. package/react/ssr/prerenderStatic.js +2 -2
  314. package/testing/core/mocking/mockLink.js +4 -4
  315. package/utilities/caching/sizes.d.ts +6 -0
  316. package/utilities/caching/sizes.js.map +1 -1
  317. package/utilities/graphql/DocumentTransform.js +1 -1
  318. package/utilities/graphql/isFormattedExecutionResult.d.ts +3 -0
  319. package/utilities/graphql/isFormattedExecutionResult.js +6 -0
  320. package/utilities/graphql/isFormattedExecutionResult.js.map +1 -0
  321. package/utilities/index.d.ts +1 -0
  322. package/utilities/index.js +1 -0
  323. package/utilities/index.js.map +1 -1
  324. package/utilities/internal/checkDocument.d.ts +1 -1
  325. package/utilities/internal/checkDocument.js +46 -12
  326. package/utilities/internal/checkDocument.js.map +1 -1
  327. package/utilities/internal/getFragmentDefinition.js +3 -3
  328. package/utilities/internal/getFragmentFromSelection.js +1 -1
  329. package/utilities/internal/getFragmentQueryDocument.js +2 -2
  330. package/utilities/internal/getGraphQLErrorsFromResult.d.ts +4 -2
  331. package/utilities/internal/getGraphQLErrorsFromResult.js +1 -12
  332. package/utilities/internal/getGraphQLErrorsFromResult.js.map +1 -1
  333. package/utilities/internal/getMainDefinition.js +1 -1
  334. package/utilities/internal/getMemoryInternals.d.ts +0 -1
  335. package/utilities/internal/getMemoryInternals.js +1 -0
  336. package/utilities/internal/getMemoryInternals.js.map +1 -1
  337. package/utilities/internal/getQueryDefinition.js +1 -1
  338. package/utilities/internal/graphQLResultHasError.d.ts +2 -2
  339. package/utilities/internal/graphQLResultHasError.js +1 -4
  340. package/utilities/internal/graphQLResultHasError.js.map +1 -1
  341. package/utilities/internal/index.d.ts +0 -4
  342. package/utilities/internal/index.js +0 -4
  343. package/utilities/internal/index.js.map +1 -1
  344. package/utilities/internal/removeDirectivesFromDocument.js +1 -1
  345. package/utilities/internal/shouldInclude.js +4 -4
  346. package/utilities/internal/valueToObjectRepresentation.js +1 -1
  347. package/version.d.ts +1 -0
  348. package/version.js +2 -1
  349. package/version.js.map +1 -1
  350. package/__cjs/link/http/createHttpLink.cjs +0 -151
  351. package/__cjs/link/http/createHttpLink.cjs.map +0 -1
  352. package/__cjs/link/http/createHttpLink.d.cts +0 -4
  353. package/__cjs/utilities/internal/isExecutionPatchIncrementalResult.cjs +0 -12
  354. package/__cjs/utilities/internal/isExecutionPatchIncrementalResult.cjs.map +0 -1
  355. package/__cjs/utilities/internal/isExecutionPatchIncrementalResult.d.cts +0 -8
  356. package/__cjs/utilities/internal/isExecutionPatchIninitialResult.cjs +0 -12
  357. package/__cjs/utilities/internal/isExecutionPatchIninitialResult.cjs.map +0 -1
  358. package/__cjs/utilities/internal/isExecutionPatchIninitialResult.d.cts +0 -8
  359. package/__cjs/utilities/internal/isExecutionPatchResult.cjs +0 -15
  360. package/__cjs/utilities/internal/isExecutionPatchResult.cjs.map +0 -1
  361. package/__cjs/utilities/internal/isExecutionPatchResult.d.cts +0 -8
  362. package/__cjs/utilities/internal/mergeIncrementalData.cjs +0 -30
  363. package/__cjs/utilities/internal/mergeIncrementalData.cjs.map +0 -1
  364. package/__cjs/utilities/internal/mergeIncrementalData.d.cts +0 -8
  365. package/link/http/createHttpLink.d.ts +0 -4
  366. package/link/http/createHttpLink.js +0 -143
  367. package/link/http/createHttpLink.js.map +0 -1
  368. package/utilities/internal/isExecutionPatchIncrementalResult.d.ts +0 -8
  369. package/utilities/internal/isExecutionPatchIncrementalResult.js +0 -9
  370. package/utilities/internal/isExecutionPatchIncrementalResult.js.map +0 -1
  371. package/utilities/internal/isExecutionPatchIninitialResult.d.ts +0 -8
  372. package/utilities/internal/isExecutionPatchIninitialResult.js +0 -9
  373. package/utilities/internal/isExecutionPatchIninitialResult.js.map +0 -1
  374. package/utilities/internal/isExecutionPatchResult.d.ts +0 -8
  375. package/utilities/internal/isExecutionPatchResult.js +0 -12
  376. package/utilities/internal/isExecutionPatchResult.js.map +0 -1
  377. package/utilities/internal/mergeIncrementalData.d.ts +0 -8
  378. package/utilities/internal/mergeIncrementalData.js +0 -27
  379. package/utilities/internal/mergeIncrementalData.js.map +0 -1
@@ -6,13 +6,51 @@ import type { MissingTree } from "@apollo/client/cache";
6
6
  import type { MaybeMasked, Unmasked } from "@apollo/client/masking";
7
7
  import type { QueryManager } from "./QueryManager.js";
8
8
  import type { ApolloQueryResult, DefaultContext, OperationVariables, QueryResult, TypedDocumentNode } from "./types.js";
9
- import type { ErrorPolicy, FetchMoreQueryOptions, NextFetchPolicyContext, RefetchWritePolicy, SubscribeToMoreOptions, UpdateQueryMapFn, WatchQueryFetchPolicy, WatchQueryOptions } from "./watchQueryOptions.js";
10
- export interface FetchMoreOptions<TData = unknown, TVariables = OperationVariables> {
11
- updateQuery?: (previousQueryResult: TData, options: {
12
- fetchMoreResult?: TData;
13
- variables?: TVariables;
14
- }) => TData;
15
- }
9
+ import type { ErrorPolicy, NextFetchPolicyContext, RefetchWritePolicy, SubscribeToMoreOptions, UpdateQueryMapFn, WatchQueryFetchPolicy, WatchQueryOptions } from "./watchQueryOptions.js";
10
+ export type FetchMoreOptions<TData, TVariables extends OperationVariables, TFetchData = TData, TFetchVars extends OperationVariables = TVariables> = {
11
+ /**
12
+ * A GraphQL query string parsed into an AST with the gql template literal.
13
+ *
14
+ * @docGroup
15
+ *
16
+ * 1. Operation options
17
+ */
18
+ query?: DocumentNode | TypedDocumentNode<TFetchData, TFetchVars>;
19
+ /**
20
+ * An object containing all of the GraphQL variables your query requires to execute.
21
+ *
22
+ * Each key in the object corresponds to a variable name, and that key's value corresponds to the variable value.
23
+ *
24
+ * @docGroup
25
+ *
26
+ * 1. Operation options
27
+ */
28
+ variables?: Partial<NoInfer<TFetchVars>>;
29
+ /**
30
+ * Specifies how the query handles a response that returns both GraphQL errors and partial results.
31
+ *
32
+ * For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).
33
+ *
34
+ * The default value is `none`, meaning that the query result includes error details but not partial results.
35
+ *
36
+ * @docGroup
37
+ *
38
+ * 1. Operation options
39
+ */
40
+ errorPolicy?: ErrorPolicy;
41
+ /**
42
+ * If you're using [Apollo Link](https://www.apollographql.com/docs/react/api/link/introduction/), this object is the initial value of the `context` object that's passed along your link chain.
43
+ *
44
+ * @docGroup
45
+ *
46
+ * 2. Networking options
47
+ */
48
+ context?: DefaultContext;
49
+ updateQuery?: (previousQueryResult: Unmasked<TData>, options: {
50
+ fetchMoreResult: Unmasked<TFetchData>;
51
+ variables: TFetchVars;
52
+ }) => Unmasked<TData>;
53
+ };
16
54
  export declare namespace ObservableQuery {
17
55
  type Options<TData = unknown, TVariables extends OperationVariables = OperationVariables> = {
18
56
  /**
@@ -232,12 +270,7 @@ export declare class ObservableQuery<TData = unknown, TVariables extends Operati
232
270
  /**
233
271
  * 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/).
234
272
  */
235
- fetchMore<TFetchData = TData, TFetchVars extends OperationVariables = TVariables>(fetchMoreOptions: FetchMoreQueryOptions<TFetchVars, TFetchData> & {
236
- updateQuery?: (previousQueryResult: Unmasked<TData>, options: {
237
- fetchMoreResult: Unmasked<TFetchData>;
238
- variables: TFetchVars;
239
- }) => Unmasked<TData>;
240
- }): Promise<QueryResult<TFetchData>>;
273
+ fetchMore<TFetchData = TData, TFetchVars extends OperationVariables = TVariables>({ query, variables, context, errorPolicy, updateQuery, }: FetchMoreOptions<TData, TVariables, TFetchData, TFetchVars>): Promise<QueryResult<TFetchData>>;
241
274
  /**
242
275
  * 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.
243
276
  *
@@ -249,7 +282,7 @@ export declare class ObservableQuery<TData = unknown, TVariables extends Operati
249
282
  *
250
283
  * @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
251
284
  */
252
- silentSetOptions(newOptions: Partial<ObservableQuery.Options<TData, TVariables>>): void;
285
+ applyOptions(newOptions: Partial<ObservableQuery.Options<TData, TVariables>>): void;
253
286
  /**
254
287
  * Update the variables of this observable query, and fetch the new results
255
288
  * if they've changed. Most users should prefer `refetch` instead of
@@ -285,6 +318,7 @@ export declare class ObservableQuery<TData = unknown, TVariables extends Operati
285
318
  stopPolling(): void;
286
319
  private applyNextFetchPolicy;
287
320
  private fetch;
321
+ private didWarnCacheOnlyPolling;
288
322
  private updatePolling;
289
323
  private cancelPolling;
290
324
  /**
@@ -1,7 +1,7 @@
1
1
  import { equal } from "@wry/equality";
2
2
  import { BehaviorSubject, Observable, share, Subject, tap } from "rxjs";
3
3
  import { __DEV__ } from "@apollo/client/utilities/environment";
4
- import { compact, filterMap, getOperationDefinition, getQueryDefinition, preventUnhandledRejection, toQueryResult, } from "@apollo/client/utilities/internal";
4
+ import { compact, filterMap, getOperationDefinition, getOperationName, getQueryDefinition, preventUnhandledRejection, toQueryResult, } from "@apollo/client/utilities/internal";
5
5
  import { invariant } from "@apollo/client/utilities/invariant";
6
6
  import { equalByQuery } from "./equalByQuery.js";
7
7
  import { isNetworkRequestInFlight, NetworkStatus } from "./networkStatus.js";
@@ -183,13 +183,6 @@ export class ObservableQuery {
183
183
  const fetchPolicy = this.queryManager.prioritizeCacheValues ?
184
184
  "cache-first"
185
185
  : initialFetchPolicy || this.options.fetchPolicy;
186
- const defaultResult = {
187
- data: undefined,
188
- dataState: "empty",
189
- loading: true,
190
- networkStatus: NetworkStatus.loading,
191
- partial: true,
192
- };
193
186
  const cacheResult = () => {
194
187
  const diff = this.getCacheDiff();
195
188
  // TODO: queryInfo.getDiff should handle this since cache.diff returns a
@@ -208,7 +201,13 @@ export class ObservableQuery {
208
201
  });
209
202
  };
210
203
  switch (fetchPolicy) {
211
- case "cache-only":
204
+ case "cache-only": {
205
+ return {
206
+ ...cacheResult(),
207
+ loading: false,
208
+ networkStatus: NetworkStatus.ready,
209
+ };
210
+ }
212
211
  case "cache-first":
213
212
  return cacheResult();
214
213
  case "cache-and-network":
@@ -218,13 +217,9 @@ export class ObservableQuery {
218
217
  networkStatus: NetworkStatus.loading,
219
218
  };
220
219
  case "standby":
221
- return {
222
- ...defaultResult,
223
- loading: false,
224
- networkStatus: NetworkStatus.ready,
225
- };
220
+ return empty;
226
221
  default:
227
- return defaultResult;
222
+ return uninitialized;
228
223
  }
229
224
  }
230
225
  resubscribeCache() {
@@ -327,6 +322,7 @@ export class ObservableQuery {
327
322
  * the previous values of those variables will be used.
328
323
  */
329
324
  refetch(variables) {
325
+ const { fetchPolicy } = this.options;
330
326
  const reobserveOptions = {
331
327
  // Always disable polling for refetches.
332
328
  pollInterval: 0,
@@ -334,7 +330,6 @@ export class ObservableQuery {
334
330
  // Unless the provided fetchPolicy always consults the network
335
331
  // (no-cache, network-only, or cache-and-network), override it with
336
332
  // network-only to force the refetch for this fetchQuery call.
337
- const { fetchPolicy } = this.options;
338
333
  if (fetchPolicy === "no-cache") {
339
334
  reobserveOptions.fetchPolicy = "no-cache";
340
335
  }
@@ -345,7 +340,7 @@ export class ObservableQuery {
345
340
  const queryDef = getQueryDefinition(this.query);
346
341
  const vars = queryDef.variableDefinitions;
347
342
  if (!vars || !vars.some((v) => v.variable.name.value === "variables")) {
348
- __DEV__ && invariant.warn(76, variables, queryDef.name?.value || queryDef);
343
+ __DEV__ && invariant.warn(79, variables, queryDef.name?.value || queryDef);
349
344
  }
350
345
  }
351
346
  if (variables && !equal(this.variables, variables)) {
@@ -361,16 +356,21 @@ export class ObservableQuery {
361
356
  /**
362
357
  * 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/).
363
358
  */
364
- fetchMore(fetchMoreOptions) {
359
+ fetchMore({ query, variables, context, errorPolicy, updateQuery, }) {
360
+ invariant(
361
+ this.options.fetchPolicy !== "cache-only",
362
+ 80,
363
+ getOperationName(this.query, "(anonymous)")
364
+ );
365
365
  const combinedOptions = {
366
- ...(fetchMoreOptions.query ? fetchMoreOptions : ({
367
- ...this.options,
368
- query: this.options.query,
369
- ...fetchMoreOptions,
370
- variables: {
371
- ...this.variables,
372
- ...fetchMoreOptions.variables,
373
- },
366
+ ...compact(this.options, { errorPolicy: "none" }, {
367
+ query,
368
+ context,
369
+ errorPolicy,
370
+ }),
371
+ variables: (query ? variables : ({
372
+ ...this.variables,
373
+ ...variables,
374
374
  })),
375
375
  // The fetchMore request goes immediately to the network and does
376
376
  // not automatically write its result to the cache (hence no-cache
@@ -387,14 +387,13 @@ export class ObservableQuery {
387
387
  // as well as the document passed in `fetchMoreOptions` to ensure the cache
388
388
  // uses the most up-to-date document which may rely on runtime conditionals.
389
389
  this.lastQuery =
390
- fetchMoreOptions.query ?
390
+ query ?
391
391
  this.transformDocument(this.options.query)
392
392
  : combinedOptions.query;
393
393
  let wasUpdated = false;
394
- const updateQuery = fetchMoreOptions?.updateQuery;
395
394
  const isCached = this.options.fetchPolicy !== "no-cache";
396
395
  if (!isCached) {
397
- invariant(updateQuery, 77);
396
+ invariant(updateQuery, 81);
398
397
  }
399
398
  const { finalize, pushNotification } = this.pushOperation(NetworkStatus.fetchMore);
400
399
  pushNotification({
@@ -418,7 +417,6 @@ export class ObservableQuery {
418
417
  // fetchMore cache results back to this ObservableQuery.
419
418
  this.queryManager.cache.batch({
420
419
  update: (cache) => {
421
- const { updateQuery } = fetchMoreOptions;
422
420
  if (updateQuery) {
423
421
  cache.updateQuery({
424
422
  query: this.query,
@@ -527,7 +525,7 @@ export class ObservableQuery {
527
525
  onError(error);
528
526
  }
529
527
  else {
530
- __DEV__ && invariant.error(78, error);
528
+ __DEV__ && invariant.error(82, error);
531
529
  }
532
530
  return;
533
531
  }
@@ -551,9 +549,10 @@ export class ObservableQuery {
551
549
  *
552
550
  * @deprecated This is an internal API and should not be used directly. This can be removed or changed at any time.
553
551
  */
554
- silentSetOptions(newOptions) {
552
+ applyOptions(newOptions) {
555
553
  const mergedOptions = compact(this.options, newOptions || {});
556
554
  assign(this.options, mergedOptions);
555
+ this.updatePolling();
557
556
  }
558
557
  /**
559
558
  * Update the variables of this observable query, and fetch the new results
@@ -760,20 +759,28 @@ export class ObservableQuery {
760
759
  return { fromLink, subscription, observable };
761
760
  }
762
761
  // Turns polling on or off based on this.options.pollInterval.
762
+ didWarnCacheOnlyPolling = false;
763
763
  updatePolling() {
764
764
  // Avoid polling in SSR mode
765
765
  if (this.queryManager.ssrMode) {
766
766
  return;
767
767
  }
768
- const { pollingInfo, options: { pollInterval }, } = this;
769
- if (!pollInterval || !this.hasObservers()) {
768
+ const { pollingInfo, options: { fetchPolicy, pollInterval }, } = this;
769
+ if (!pollInterval || !this.hasObservers() || fetchPolicy === "cache-only") {
770
+ if (__DEV__) {
771
+ if (!this.didWarnCacheOnlyPolling &&
772
+ pollInterval &&
773
+ fetchPolicy === "cache-only") {
774
+ __DEV__ && invariant.warn(83, getOperationName(this.query, "(anonymous)"));
775
+ this.didWarnCacheOnlyPolling = true;
776
+ }
777
+ }
770
778
  this.cancelPolling();
771
779
  return;
772
780
  }
773
- if (pollingInfo && pollingInfo.interval === pollInterval) {
781
+ if (pollingInfo?.interval === pollInterval) {
774
782
  return;
775
783
  }
776
- invariant(pollInterval, 79);
777
784
  const info = pollingInfo || (this.pollingInfo = {});
778
785
  info.interval = pollInterval;
779
786
  const maybeFetch = () => {
@@ -973,17 +980,14 @@ export class ObservableQuery {
973
980
  return this.queryManager.transform(document);
974
981
  }
975
982
  maskResult(result) {
976
- return result && "data" in result ?
977
- {
978
- ...result,
979
- data: this.queryManager.maskOperation({
980
- document: this.query,
981
- data: result.data,
982
- fetchPolicy: this.options.fetchPolicy,
983
- cause: this,
984
- }),
985
- }
986
- : result;
983
+ const masked = this.queryManager.maskOperation({
984
+ document: this.query,
985
+ data: result.data,
986
+ fetchPolicy: this.options.fetchPolicy,
987
+ cause: this,
988
+ });
989
+ // Maintain object identity as much as possible
990
+ return masked === result.data ? result : { ...result, data: masked };
987
991
  }
988
992
  dirty = false;
989
993
  notifyTimeout;
@@ -1190,7 +1194,7 @@ export class ObservableQuery {
1190
1194
  loading: false,
1191
1195
  }
1192
1196
  : notification.value;
1193
- if (result.error && result.dataState === "streaming") {
1197
+ if (notification.kind === "E" && result.dataState === "streaming") {
1194
1198
  result.dataState = "complete";
1195
1199
  }
1196
1200
  if (result.error) {
@@ -1259,7 +1263,7 @@ export class ObservableQuery {
1259
1263
  }
1260
1264
  export function logMissingFieldErrors(missing) {
1261
1265
  if (__DEV__ && missing) {
1262
- __DEV__ && invariant.debug(80, missing);
1266
+ __DEV__ && invariant.debug(84, missing);
1263
1267
  }
1264
1268
  }
1265
1269
  function isEqualQuery(a, b) {