@apollo/client 4.0.0-rc.5 → 4.0.0-rc.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (512) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +40 -40
  3. package/__cjs/cache/core/cache.cjs +2 -6
  4. package/__cjs/cache/core/cache.cjs.map +1 -1
  5. package/__cjs/cache/core/cache.d.cts +65 -64
  6. package/__cjs/cache/core/types/Cache.cjs +0 -4
  7. package/__cjs/cache/core/types/Cache.cjs.map +1 -1
  8. package/__cjs/cache/core/types/Cache.d.cts +200 -15
  9. package/__cjs/cache/{core/types/DataProxy.cjs → deprecated.cjs} +1 -1
  10. package/__cjs/cache/deprecated.cjs.map +1 -0
  11. package/__cjs/cache/deprecated.d.cts +6 -0
  12. package/__cjs/cache/index.cjs.map +1 -1
  13. package/__cjs/cache/index.d.cts +2 -2
  14. package/__cjs/cache/inmemory/entityStore.cjs +25 -28
  15. package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
  16. package/__cjs/cache/inmemory/entityStore.d.cts +17 -16
  17. package/__cjs/cache/inmemory/inMemoryCache.cjs.map +1 -1
  18. package/__cjs/cache/inmemory/inMemoryCache.d.cts +4 -4
  19. package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
  20. package/__cjs/cache/inmemory/policies.cjs +4 -4
  21. package/__cjs/cache/inmemory/policies.cjs.map +1 -1
  22. package/__cjs/cache/inmemory/policies.d.cts +3 -2
  23. package/__cjs/cache/inmemory/readFromStore.cjs +2 -2
  24. package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
  25. package/__cjs/cache/inmemory/writeToStore.cjs.map +1 -1
  26. package/__cjs/cache/inmemory/writeToStore.d.cts +1 -1
  27. package/__cjs/core/ApolloClient.cjs +92 -110
  28. package/__cjs/core/ApolloClient.cjs.map +1 -1
  29. package/__cjs/core/ApolloClient.d.cts +774 -180
  30. package/__cjs/core/ObservableQuery.cjs +10 -10
  31. package/__cjs/core/ObservableQuery.cjs.map +1 -1
  32. package/__cjs/core/ObservableQuery.d.cts +120 -68
  33. package/__cjs/core/QueryInfo.cjs.map +1 -1
  34. package/__cjs/core/QueryInfo.d.cts +5 -4
  35. package/__cjs/core/QueryManager.cjs +15 -13
  36. package/__cjs/core/QueryManager.cjs.map +1 -1
  37. package/__cjs/core/QueryManager.d.cts +17 -17
  38. package/__cjs/core/deprecated.cjs +3 -0
  39. package/__cjs/core/deprecated.cjs.map +1 -0
  40. package/__cjs/core/deprecated.d.cts +29 -0
  41. package/__cjs/core/index.cjs.map +1 -1
  42. package/__cjs/core/index.d.cts +9 -5
  43. package/__cjs/core/types.d.cts +29 -129
  44. package/__cjs/core/watchQueryOptions.d.cts +8 -297
  45. package/__cjs/dev/setErrorMessageHandler.cjs.map +1 -1
  46. package/__cjs/dev/setErrorMessageHandler.d.cts +4 -4
  47. package/__cjs/errors/CombinedGraphQLErrors.cjs +59 -11
  48. package/__cjs/errors/CombinedGraphQLErrors.cjs.map +1 -1
  49. package/__cjs/errors/CombinedGraphQLErrors.d.cts +146 -11
  50. package/__cjs/errors/CombinedProtocolErrors.cjs +48 -1
  51. package/__cjs/errors/CombinedProtocolErrors.cjs.map +1 -1
  52. package/__cjs/errors/CombinedProtocolErrors.d.cts +126 -2
  53. package/__cjs/errors/LinkError.cjs +45 -2
  54. package/__cjs/errors/LinkError.cjs.map +1 -1
  55. package/__cjs/errors/LinkError.d.cts +45 -2
  56. package/__cjs/errors/LocalStateError.cjs +35 -5
  57. package/__cjs/errors/LocalStateError.cjs.map +1 -1
  58. package/__cjs/errors/LocalStateError.d.cts +41 -5
  59. package/__cjs/errors/ServerError.cjs +50 -8
  60. package/__cjs/errors/ServerError.cjs.map +1 -1
  61. package/__cjs/errors/ServerError.d.cts +70 -11
  62. package/__cjs/errors/ServerParseError.cjs +45 -8
  63. package/__cjs/errors/ServerParseError.cjs.map +1 -1
  64. package/__cjs/errors/ServerParseError.d.cts +71 -16
  65. package/__cjs/errors/UnconventionalError.cjs +46 -2
  66. package/__cjs/errors/UnconventionalError.cjs.map +1 -1
  67. package/__cjs/errors/UnconventionalError.d.cts +46 -2
  68. package/__cjs/incremental/handlers/notImplemented.cjs +1 -1
  69. package/__cjs/invariantErrorCodes.cjs +72 -80
  70. package/__cjs/link/batch/batchLink.cjs.map +1 -1
  71. package/__cjs/link/batch-http/batchHttpLink.cjs +2 -2
  72. package/__cjs/link/batch-http/batchHttpLink.cjs.map +1 -1
  73. package/__cjs/link/client-awareness/ClientAwarenessLink.cjs.map +1 -1
  74. package/__cjs/link/client-awareness/ClientAwarenessLink.d.cts +4 -4
  75. package/__cjs/link/context/index.cjs +1 -1
  76. package/__cjs/link/context/index.cjs.map +1 -1
  77. package/__cjs/link/context/index.d.cts +1 -1
  78. package/__cjs/link/core/ApolloLink.cjs +2 -2
  79. package/__cjs/link/core/types.d.cts +2 -2
  80. package/__cjs/link/error/index.cjs.map +1 -1
  81. package/__cjs/link/error/index.d.cts +16 -1
  82. package/__cjs/link/http/HttpLink.cjs.map +1 -1
  83. package/__cjs/link/http/HttpLink.d.cts +2 -1
  84. package/__cjs/link/http/checkFetcher.cjs +1 -1
  85. package/__cjs/link/http/parseAndCheckHttpResponse.cjs +1 -1
  86. package/__cjs/link/http/serializeFetchParameter.cjs +1 -1
  87. package/__cjs/link/persisted-queries/index.cjs +2 -2
  88. package/__cjs/link/persisted-queries/index.cjs.map +1 -1
  89. package/__cjs/link/persisted-queries/index.d.cts +11 -11
  90. package/__cjs/link/retry/delayFunction.cjs.map +1 -1
  91. package/__cjs/link/retry/delayFunction.d.cts +1 -1
  92. package/__cjs/link/retry/retryFunction.cjs.map +1 -1
  93. package/__cjs/link/retry/retryFunction.d.cts +1 -1
  94. package/__cjs/link/retry/retryLink.cjs.map +1 -1
  95. package/__cjs/link/schema/index.cjs.map +1 -1
  96. package/__cjs/link/utils/validateOperation.cjs +1 -1
  97. package/__cjs/link/ws/index.cjs.map +1 -1
  98. package/__cjs/local-state/LocalState.cjs +55 -9
  99. package/__cjs/local-state/LocalState.cjs.map +1 -1
  100. package/__cjs/local-state/LocalState.d.cts +94 -0
  101. package/__cjs/masking/GraphQLCodegenDataMasking.d.cts +6 -7
  102. package/__cjs/masking/internal/types.d.cts +70 -70
  103. package/__cjs/masking/maskDefinition.cjs +2 -2
  104. package/__cjs/masking/maskFragment.cjs +2 -2
  105. package/__cjs/masking/maskOperation.cjs +1 -1
  106. package/__cjs/masking/utils.cjs +3 -3
  107. package/__cjs/react/context/ApolloContext.cjs +1 -1
  108. package/__cjs/react/context/ApolloProvider.cjs +1 -1
  109. package/__cjs/react/hooks/internal/useDeepMemo.cjs +0 -3
  110. package/__cjs/react/hooks/internal/useDeepMemo.cjs.map +1 -1
  111. package/__cjs/react/hooks/internal/validateSuspenseHookOptions.cjs.map +1 -1
  112. package/__cjs/react/hooks/internal/validateSuspenseHookOptions.d.cts +2 -2
  113. package/__cjs/react/hooks/internal/wrapHook.cjs +1 -0
  114. package/__cjs/react/hooks/internal/wrapHook.cjs.map +1 -1
  115. package/__cjs/react/hooks/internal/wrapHook.d.cts +8 -7
  116. package/__cjs/react/hooks/useApolloClient.cjs +2 -2
  117. package/__cjs/react/hooks/useApolloClient.cjs.map +1 -1
  118. package/__cjs/react/hooks/useApolloClient.d.cts +2 -2
  119. package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
  120. package/__cjs/react/hooks/useBackgroundQuery.d.cts +814 -86
  121. package/__cjs/react/hooks/useFragment.cjs +7 -0
  122. package/__cjs/react/hooks/useFragment.cjs.map +1 -1
  123. package/__cjs/react/hooks/useFragment.d.cts +53 -2
  124. package/__cjs/react/hooks/useLazyQuery.cjs +0 -38
  125. package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
  126. package/__cjs/react/hooks/useLazyQuery.d.cts +309 -119
  127. package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
  128. package/__cjs/react/hooks/useLoadableQuery.d.cts +113 -126
  129. package/__cjs/react/hooks/useMutation.cjs +6 -7
  130. package/__cjs/react/hooks/useMutation.cjs.map +1 -1
  131. package/__cjs/react/hooks/useMutation.d.cts +57 -17
  132. package/__cjs/react/hooks/useQuery.cjs +1 -35
  133. package/__cjs/react/hooks/useQuery.cjs.map +1 -1
  134. package/__cjs/react/hooks/useQuery.d.cts +163 -18
  135. package/__cjs/react/hooks/useQueryRefHandlers.cjs +2 -1
  136. package/__cjs/react/hooks/useQueryRefHandlers.cjs.map +1 -1
  137. package/__cjs/react/hooks/useQueryRefHandlers.d.cts +21 -1
  138. package/__cjs/react/hooks/useReactiveVar.cjs +2 -1
  139. package/__cjs/react/hooks/useReactiveVar.cjs.map +1 -1
  140. package/__cjs/react/hooks/useReactiveVar.d.cts +2 -1
  141. package/__cjs/react/hooks/useReadQuery.cjs +29 -0
  142. package/__cjs/react/hooks/useReadQuery.cjs.map +1 -1
  143. package/__cjs/react/hooks/useReadQuery.d.cts +95 -16
  144. package/__cjs/react/hooks/useSubscription.cjs +8 -9
  145. package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
  146. package/__cjs/react/hooks/useSubscription.d.cts +99 -32
  147. package/__cjs/react/hooks/useSuspenseFragment.cjs.map +1 -1
  148. package/__cjs/react/hooks/useSuspenseFragment.d.cts +61 -29
  149. package/__cjs/react/hooks/useSuspenseQuery.cjs +4 -1
  150. package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
  151. package/__cjs/react/hooks/useSuspenseQuery.d.cts +438 -17
  152. package/__cjs/react/index.cjs +1 -3
  153. package/__cjs/react/index.cjs.map +1 -1
  154. package/__cjs/react/index.d.cts +0 -1
  155. package/__cjs/react/index.react-server.cjs +1 -3
  156. package/__cjs/react/index.react-server.cjs.map +1 -1
  157. package/__cjs/react/index.react-server.d.cts +0 -1
  158. package/__cjs/react/internal/cache/FragmentReference.cjs.map +1 -1
  159. package/__cjs/react/internal/cache/FragmentReference.d.cts +2 -3
  160. package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
  161. package/__cjs/react/internal/cache/QueryReference.d.cts +11 -11
  162. package/__cjs/react/internal/cache/SuspenseCache.cjs.map +1 -1
  163. package/__cjs/react/internal/cache/SuspenseCache.d.cts +2 -2
  164. package/__cjs/react/internal/cache/getSuspenseCache.cjs.map +1 -1
  165. package/__cjs/react/internal/cache/getSuspenseCache.d.cts +6 -4
  166. package/__cjs/react/internal/index.cjs +1 -0
  167. package/__cjs/react/internal/index.cjs.map +1 -1
  168. package/__cjs/react/internal/index.d.cts +1 -1
  169. package/__cjs/react/internal/types.d.cts +3 -3
  170. package/__cjs/react/query-preloader/createQueryPreloader.cjs +1 -1
  171. package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
  172. package/__cjs/react/query-preloader/createQueryPreloader.d.cts +31 -31
  173. package/__cjs/react/ssr/prerenderStatic.cjs +5 -4
  174. package/__cjs/react/ssr/prerenderStatic.cjs.map +1 -1
  175. package/__cjs/react/ssr/prerenderStatic.d.cts +11 -9
  176. package/__cjs/react/ssr/useSSRQuery.cjs.map +1 -1
  177. package/__cjs/react/types/deprecated.d.cts +1 -1
  178. package/__cjs/react/types/types.documentation.d.cts +10 -10
  179. package/__cjs/testing/core/mocking/mockLink.cjs.map +1 -1
  180. package/__cjs/testing/core/mocking/mockLink.d.cts +3 -2
  181. package/__cjs/testing/core/types/deprecated.d.cts +3 -2
  182. package/__cjs/testing/react/MockedProvider.cjs.map +1 -1
  183. package/__cjs/testing/react/MockedProvider.d.cts +2 -3
  184. package/__cjs/utilities/HKT.d.cts +8 -7
  185. package/__cjs/utilities/caching/sizes.cjs +3 -3
  186. package/__cjs/utilities/caching/sizes.cjs.map +1 -1
  187. package/__cjs/utilities/caching/sizes.d.cts +4 -6
  188. package/__cjs/utilities/graphql/DocumentTransform.cjs +2 -2
  189. package/__cjs/utilities/graphql/DocumentTransform.cjs.map +1 -1
  190. package/__cjs/utilities/index.cjs +2 -3
  191. package/__cjs/utilities/index.cjs.map +1 -1
  192. package/__cjs/utilities/index.d.cts +1 -2
  193. package/__cjs/utilities/{shared → internal}/canonicalStringify.cjs +5 -7
  194. package/__cjs/utilities/internal/canonicalStringify.cjs.map +1 -0
  195. package/__cjs/utilities/{shared → internal}/canonicalStringify.d.cts +1 -1
  196. package/__cjs/utilities/internal/checkDocument.cjs +2 -2
  197. package/__cjs/utilities/internal/checkDocument.cjs.map +1 -1
  198. package/__cjs/utilities/internal/createFragmentMap.cjs.map +1 -1
  199. package/__cjs/{core → utilities/internal}/equalByQuery.cjs +13 -7
  200. package/__cjs/utilities/internal/equalByQuery.cjs.map +1 -0
  201. package/__cjs/utilities/internal/equalByQuery.d.cts +5 -0
  202. package/__cjs/utilities/internal/getFragmentQueryDocument.cjs +13 -3
  203. package/__cjs/utilities/internal/getFragmentQueryDocument.cjs.map +1 -1
  204. package/__cjs/utilities/internal/getFragmentQueryDocument.d.cts +13 -3
  205. package/__cjs/utilities/internal/getMemoryInternals.cjs.map +1 -1
  206. package/__cjs/utilities/internal/getStoreKeyName.cjs +1 -2
  207. package/__cjs/utilities/internal/getStoreKeyName.cjs.map +1 -1
  208. package/__cjs/utilities/internal/index.cjs +6 -2
  209. package/__cjs/utilities/internal/index.cjs.map +1 -1
  210. package/__cjs/utilities/internal/index.d.cts +2 -0
  211. package/__cjs/utilities/internal/mergeOptions.cjs.map +1 -1
  212. package/__cjs/utilities/internal/mergeOptions.d.cts +2 -2
  213. package/__cjs/utilities/internal/toQueryResult.cjs.map +1 -1
  214. package/__cjs/utilities/internal/toQueryResult.d.cts +2 -2
  215. package/__cjs/utilities/internal/types/DocumentationTypes.d.cts +16 -2
  216. package/__cjs/utilities/internal/types/NoInfer.d.cts +31 -25
  217. package/__cjs/utilities/subscriptions/relay/index.cjs +2 -0
  218. package/__cjs/utilities/subscriptions/relay/index.cjs.map +1 -1
  219. package/__cjs/version.cjs +1 -1
  220. package/cache/core/cache.d.ts +65 -64
  221. package/cache/core/cache.js +3 -7
  222. package/cache/core/cache.js.map +1 -1
  223. package/cache/core/types/Cache.d.ts +200 -15
  224. package/cache/core/types/Cache.js +1 -3
  225. package/cache/core/types/Cache.js.map +1 -1
  226. package/cache/deprecated.d.ts +6 -0
  227. package/cache/deprecated.js +2 -0
  228. package/cache/deprecated.js.map +1 -0
  229. package/cache/index.d.ts +2 -2
  230. package/cache/index.js.map +1 -1
  231. package/cache/inmemory/entityStore.d.ts +17 -16
  232. package/cache/inmemory/entityStore.js +25 -28
  233. package/cache/inmemory/entityStore.js.map +1 -1
  234. package/cache/inmemory/inMemoryCache.d.ts +4 -4
  235. package/cache/inmemory/inMemoryCache.js.map +1 -1
  236. package/cache/inmemory/key-extractor.js +1 -1
  237. package/cache/inmemory/policies.d.ts +3 -2
  238. package/cache/inmemory/policies.js +4 -4
  239. package/cache/inmemory/policies.js.map +1 -1
  240. package/cache/inmemory/readFromStore.js +2 -2
  241. package/cache/inmemory/writeToStore.d.ts +1 -1
  242. package/cache/inmemory/writeToStore.js +4 -4
  243. package/cache/inmemory/writeToStore.js.map +1 -1
  244. package/core/ApolloClient.d.ts +774 -180
  245. package/core/ApolloClient.js +92 -110
  246. package/core/ApolloClient.js.map +1 -1
  247. package/core/ObservableQuery.d.ts +120 -68
  248. package/core/ObservableQuery.js +10 -10
  249. package/core/ObservableQuery.js.map +1 -1
  250. package/core/QueryInfo.d.ts +5 -4
  251. package/core/QueryInfo.js.map +1 -1
  252. package/core/QueryManager.d.ts +17 -17
  253. package/core/QueryManager.js +15 -13
  254. package/core/QueryManager.js.map +1 -1
  255. package/core/deprecated.d.ts +29 -0
  256. package/core/deprecated.js +2 -0
  257. package/core/deprecated.js.map +1 -0
  258. package/core/index.d.ts +9 -5
  259. package/core/index.js.map +1 -1
  260. package/core/types.d.ts +29 -129
  261. package/core/types.js.map +1 -1
  262. package/core/watchQueryOptions.d.ts +9 -298
  263. package/core/watchQueryOptions.js.map +1 -1
  264. package/dev/setErrorMessageHandler.d.ts +4 -4
  265. package/dev/setErrorMessageHandler.js.map +1 -1
  266. package/errors/CombinedGraphQLErrors.d.ts +147 -12
  267. package/errors/CombinedGraphQLErrors.js +60 -12
  268. package/errors/CombinedGraphQLErrors.js.map +1 -1
  269. package/errors/CombinedProtocolErrors.d.ts +127 -3
  270. package/errors/CombinedProtocolErrors.js +49 -2
  271. package/errors/CombinedProtocolErrors.js.map +1 -1
  272. package/errors/LinkError.d.ts +45 -2
  273. package/errors/LinkError.js +45 -2
  274. package/errors/LinkError.js.map +1 -1
  275. package/errors/LocalStateError.d.ts +42 -6
  276. package/errors/LocalStateError.js +36 -6
  277. package/errors/LocalStateError.js.map +1 -1
  278. package/errors/ServerError.d.ts +71 -12
  279. package/errors/ServerError.js +51 -9
  280. package/errors/ServerError.js.map +1 -1
  281. package/errors/ServerParseError.d.ts +72 -17
  282. package/errors/ServerParseError.js +46 -9
  283. package/errors/ServerParseError.js.map +1 -1
  284. package/errors/UnconventionalError.d.ts +46 -2
  285. package/errors/UnconventionalError.js +46 -2
  286. package/errors/UnconventionalError.js.map +1 -1
  287. package/incremental/handlers/notImplemented.js +1 -1
  288. package/invariantErrorCodes.js +72 -80
  289. package/link/batch/batchLink.js.map +1 -1
  290. package/link/batch-http/batchHttpLink.js +1 -1
  291. package/link/batch-http/batchHttpLink.js.map +1 -1
  292. package/link/client-awareness/ClientAwarenessLink.d.ts +4 -4
  293. package/link/client-awareness/ClientAwarenessLink.js.map +1 -1
  294. package/link/context/index.d.ts +1 -1
  295. package/link/context/index.js +1 -1
  296. package/link/context/index.js.map +1 -1
  297. package/link/core/ApolloLink.js +2 -2
  298. package/link/core/types.d.ts +2 -2
  299. package/link/core/types.js.map +1 -1
  300. package/link/error/index.d.ts +16 -1
  301. package/link/error/index.js.map +1 -1
  302. package/link/http/HttpLink.d.ts +2 -1
  303. package/link/http/HttpLink.js.map +1 -1
  304. package/link/http/checkFetcher.js +1 -1
  305. package/link/http/parseAndCheckHttpResponse.js +1 -1
  306. package/link/http/serializeFetchParameter.js +1 -1
  307. package/link/persisted-queries/index.d.ts +11 -11
  308. package/link/persisted-queries/index.js +2 -2
  309. package/link/persisted-queries/index.js.map +1 -1
  310. package/link/retry/delayFunction.d.ts +1 -1
  311. package/link/retry/delayFunction.js.map +1 -1
  312. package/link/retry/retryFunction.d.ts +1 -1
  313. package/link/retry/retryFunction.js.map +1 -1
  314. package/link/retry/retryLink.js.map +1 -1
  315. package/link/schema/index.js.map +1 -1
  316. package/link/utils/validateOperation.js +1 -1
  317. package/link/ws/index.js.map +1 -1
  318. package/local-state/LocalState.d.ts +94 -0
  319. package/local-state/LocalState.js +55 -9
  320. package/local-state/LocalState.js.map +1 -1
  321. package/masking/GraphQLCodegenDataMasking.d.ts +6 -7
  322. package/masking/GraphQLCodegenDataMasking.js.map +1 -1
  323. package/masking/internal/types.d.ts +70 -70
  324. package/masking/internal/types.js.map +1 -1
  325. package/masking/maskDefinition.js +2 -2
  326. package/masking/maskFragment.js +2 -2
  327. package/masking/maskOperation.js +1 -1
  328. package/masking/types.js.map +1 -1
  329. package/masking/utils.js +3 -3
  330. package/package.json +1 -1
  331. package/react/context/ApolloContext.js +1 -1
  332. package/react/context/ApolloProvider.js +1 -1
  333. package/react/hooks/internal/useDeepMemo.js +0 -3
  334. package/react/hooks/internal/useDeepMemo.js.map +1 -1
  335. package/react/hooks/internal/validateSuspenseHookOptions.d.ts +2 -2
  336. package/react/hooks/internal/validateSuspenseHookOptions.js.map +1 -1
  337. package/react/hooks/internal/wrapHook.d.ts +8 -7
  338. package/react/hooks/internal/wrapHook.js +1 -0
  339. package/react/hooks/internal/wrapHook.js.map +1 -1
  340. package/react/hooks/useApolloClient.d.ts +2 -2
  341. package/react/hooks/useApolloClient.js +2 -2
  342. package/react/hooks/useApolloClient.js.map +1 -1
  343. package/react/hooks/useBackgroundQuery.d.ts +814 -86
  344. package/react/hooks/useBackgroundQuery.js.map +1 -1
  345. package/react/hooks/useFragment.d.ts +54 -3
  346. package/react/hooks/useFragment.js +7 -0
  347. package/react/hooks/useFragment.js.map +1 -1
  348. package/react/hooks/useLazyQuery.d.ts +309 -119
  349. package/react/hooks/useLazyQuery.js +0 -38
  350. package/react/hooks/useLazyQuery.js.map +1 -1
  351. package/react/hooks/useLoadableQuery.d.ts +113 -126
  352. package/react/hooks/useLoadableQuery.js.map +1 -1
  353. package/react/hooks/useMutation.d.ts +57 -17
  354. package/react/hooks/useMutation.js +6 -7
  355. package/react/hooks/useMutation.js.map +1 -1
  356. package/react/hooks/useQuery.d.ts +163 -18
  357. package/react/hooks/useQuery.js +1 -35
  358. package/react/hooks/useQuery.js.map +1 -1
  359. package/react/hooks/useQueryRefHandlers.d.ts +21 -1
  360. package/react/hooks/useQueryRefHandlers.js +2 -1
  361. package/react/hooks/useQueryRefHandlers.js.map +1 -1
  362. package/react/hooks/useReactiveVar.d.ts +2 -1
  363. package/react/hooks/useReactiveVar.js +2 -1
  364. package/react/hooks/useReactiveVar.js.map +1 -1
  365. package/react/hooks/useReadQuery.d.ts +96 -17
  366. package/react/hooks/useReadQuery.js +29 -0
  367. package/react/hooks/useReadQuery.js.map +1 -1
  368. package/react/hooks/useSubscription.d.ts +99 -32
  369. package/react/hooks/useSubscription.js +8 -9
  370. package/react/hooks/useSubscription.js.map +1 -1
  371. package/react/hooks/useSuspenseFragment.d.ts +62 -30
  372. package/react/hooks/useSuspenseFragment.js.map +1 -1
  373. package/react/hooks/useSuspenseQuery.d.ts +438 -17
  374. package/react/hooks/useSuspenseQuery.js +4 -1
  375. package/react/hooks/useSuspenseQuery.js.map +1 -1
  376. package/react/hooks-compiled/internal/useDeepMemo.js +0 -3
  377. package/react/hooks-compiled/internal/useDeepMemo.js.map +1 -1
  378. package/react/hooks-compiled/internal/validateSuspenseHookOptions.d.ts +2 -2
  379. package/react/hooks-compiled/internal/validateSuspenseHookOptions.js.map +1 -1
  380. package/react/hooks-compiled/internal/wrapHook.d.ts +8 -7
  381. package/react/hooks-compiled/internal/wrapHook.js +1 -0
  382. package/react/hooks-compiled/internal/wrapHook.js.map +1 -1
  383. package/react/hooks-compiled/useApolloClient.d.ts +2 -2
  384. package/react/hooks-compiled/useApolloClient.js +2 -2
  385. package/react/hooks-compiled/useApolloClient.js.map +1 -1
  386. package/react/hooks-compiled/useBackgroundQuery.d.ts +814 -86
  387. package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
  388. package/react/hooks-compiled/useFragment.d.ts +54 -3
  389. package/react/hooks-compiled/useFragment.js +7 -0
  390. package/react/hooks-compiled/useFragment.js.map +1 -1
  391. package/react/hooks-compiled/useLazyQuery.d.ts +309 -119
  392. package/react/hooks-compiled/useLazyQuery.js +0 -38
  393. package/react/hooks-compiled/useLazyQuery.js.map +1 -1
  394. package/react/hooks-compiled/useLoadableQuery.d.ts +113 -126
  395. package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
  396. package/react/hooks-compiled/useMutation.d.ts +57 -17
  397. package/react/hooks-compiled/useMutation.js +6 -7
  398. package/react/hooks-compiled/useMutation.js.map +1 -1
  399. package/react/hooks-compiled/useQuery.d.ts +163 -18
  400. package/react/hooks-compiled/useQuery.js +1 -35
  401. package/react/hooks-compiled/useQuery.js.map +1 -1
  402. package/react/hooks-compiled/useQueryRefHandlers.d.ts +21 -1
  403. package/react/hooks-compiled/useQueryRefHandlers.js +2 -1
  404. package/react/hooks-compiled/useQueryRefHandlers.js.map +1 -1
  405. package/react/hooks-compiled/useReactiveVar.d.ts +2 -1
  406. package/react/hooks-compiled/useReactiveVar.js +2 -1
  407. package/react/hooks-compiled/useReactiveVar.js.map +1 -1
  408. package/react/hooks-compiled/useReadQuery.d.ts +96 -17
  409. package/react/hooks-compiled/useReadQuery.js +29 -0
  410. package/react/hooks-compiled/useReadQuery.js.map +1 -1
  411. package/react/hooks-compiled/useSubscription.d.ts +99 -32
  412. package/react/hooks-compiled/useSubscription.js +8 -9
  413. package/react/hooks-compiled/useSubscription.js.map +1 -1
  414. package/react/hooks-compiled/useSuspenseFragment.d.ts +62 -30
  415. package/react/hooks-compiled/useSuspenseFragment.js.map +1 -1
  416. package/react/hooks-compiled/useSuspenseQuery.d.ts +438 -17
  417. package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
  418. package/react/index.compiled.d.ts +0 -1
  419. package/react/index.compiled.js +0 -1
  420. package/react/index.compiled.js.map +1 -1
  421. package/react/index.d.ts +0 -1
  422. package/react/index.js +0 -1
  423. package/react/index.js.map +1 -1
  424. package/react/index.react-server.d.ts +0 -1
  425. package/react/index.react-server.js +0 -2
  426. package/react/index.react-server.js.map +1 -1
  427. package/react/internal/cache/FragmentReference.d.ts +2 -3
  428. package/react/internal/cache/FragmentReference.js.map +1 -1
  429. package/react/internal/cache/QueryReference.d.ts +11 -11
  430. package/react/internal/cache/QueryReference.js.map +1 -1
  431. package/react/internal/cache/SuspenseCache.d.ts +2 -2
  432. package/react/internal/cache/SuspenseCache.js.map +1 -1
  433. package/react/internal/cache/getSuspenseCache.d.ts +6 -4
  434. package/react/internal/cache/getSuspenseCache.js.map +1 -1
  435. package/react/internal/index.d.ts +1 -1
  436. package/react/internal/index.js +1 -0
  437. package/react/internal/index.js.map +1 -1
  438. package/react/internal/types.d.ts +3 -3
  439. package/react/internal/types.js.map +1 -1
  440. package/react/query-preloader/createQueryPreloader.d.ts +31 -31
  441. package/react/query-preloader/createQueryPreloader.js +1 -1
  442. package/react/query-preloader/createQueryPreloader.js.map +1 -1
  443. package/react/ssr/prerenderStatic.d.ts +11 -9
  444. package/react/ssr/prerenderStatic.js +5 -4
  445. package/react/ssr/prerenderStatic.js.map +1 -1
  446. package/react/ssr/useSSRQuery.js.map +1 -1
  447. package/react/types/deprecated.d.ts +1 -1
  448. package/react/types/deprecated.js.map +1 -1
  449. package/react/types/types.documentation.d.ts +10 -10
  450. package/react/types/types.documentation.js.map +1 -1
  451. package/testing/core/mocking/mockLink.d.ts +3 -2
  452. package/testing/core/mocking/mockLink.js.map +1 -1
  453. package/testing/core/types/deprecated.d.ts +3 -2
  454. package/testing/core/types/deprecated.js.map +1 -1
  455. package/testing/react/MockedProvider.d.ts +2 -3
  456. package/testing/react/MockedProvider.js.map +1 -1
  457. package/utilities/HKT.d.ts +8 -7
  458. package/utilities/HKT.js.map +1 -1
  459. package/utilities/caching/sizes.d.ts +4 -6
  460. package/utilities/caching/sizes.js +3 -3
  461. package/utilities/caching/sizes.js.map +1 -1
  462. package/utilities/graphql/DocumentTransform.js +1 -1
  463. package/utilities/graphql/DocumentTransform.js.map +1 -1
  464. package/utilities/index.d.ts +1 -2
  465. package/utilities/index.js +1 -2
  466. package/utilities/index.js.map +1 -1
  467. package/utilities/{shared → internal}/canonicalStringify.d.ts +1 -1
  468. package/utilities/{shared → internal}/canonicalStringify.js +4 -6
  469. package/utilities/internal/canonicalStringify.js.map +1 -0
  470. package/utilities/internal/checkDocument.js +1 -1
  471. package/utilities/internal/checkDocument.js.map +1 -1
  472. package/utilities/internal/createFragmentMap.js.map +1 -1
  473. package/utilities/internal/equalByQuery.d.ts +5 -0
  474. package/{core → utilities/internal}/equalByQuery.js +7 -1
  475. package/utilities/internal/equalByQuery.js.map +1 -0
  476. package/utilities/internal/getFragmentQueryDocument.d.ts +13 -3
  477. package/utilities/internal/getFragmentQueryDocument.js +13 -3
  478. package/utilities/internal/getFragmentQueryDocument.js.map +1 -1
  479. package/utilities/internal/getMemoryInternals.js.map +1 -1
  480. package/utilities/internal/getStoreKeyName.js +1 -2
  481. package/utilities/internal/getStoreKeyName.js.map +1 -1
  482. package/utilities/internal/index.d.ts +2 -0
  483. package/utilities/internal/index.js +2 -0
  484. package/utilities/internal/index.js.map +1 -1
  485. package/utilities/internal/mergeOptions.d.ts +2 -2
  486. package/utilities/internal/mergeOptions.js.map +1 -1
  487. package/utilities/internal/toQueryResult.d.ts +2 -2
  488. package/utilities/internal/toQueryResult.js.map +1 -1
  489. package/utilities/internal/types/DocumentationTypes.d.ts +16 -2
  490. package/utilities/internal/types/DocumentationTypes.js.map +1 -1
  491. package/utilities/internal/types/NoInfer.d.ts +31 -25
  492. package/utilities/internal/types/NoInfer.js.map +1 -1
  493. package/utilities/subscriptions/relay/index.js +2 -0
  494. package/utilities/subscriptions/relay/index.js.map +1 -1
  495. package/version.js +1 -1
  496. package/__cjs/cache/core/types/DataProxy.cjs.map +0 -1
  497. package/__cjs/cache/core/types/DataProxy.d.cts +0 -140
  498. package/__cjs/core/equalByQuery.cjs.map +0 -1
  499. package/__cjs/core/equalByQuery.d.cts +0 -4
  500. package/__cjs/react/context/ApolloConsumer.cjs +0 -16
  501. package/__cjs/react/context/ApolloConsumer.cjs.map +0 -1
  502. package/__cjs/react/context/ApolloConsumer.d.cts +0 -10
  503. package/__cjs/utilities/shared/canonicalStringify.cjs.map +0 -1
  504. package/cache/core/types/DataProxy.d.ts +0 -140
  505. package/cache/core/types/DataProxy.js +0 -2
  506. package/cache/core/types/DataProxy.js.map +0 -1
  507. package/core/equalByQuery.d.ts +0 -4
  508. package/core/equalByQuery.js.map +0 -1
  509. package/react/context/ApolloConsumer.d.ts +0 -10
  510. package/react/context/ApolloConsumer.js +0 -11
  511. package/react/context/ApolloConsumer.js.map +0 -1
  512. package/utilities/shared/canonicalStringify.js.map +0 -1
@@ -1,127 +1,285 @@
1
1
  import type { ApolloClient, DefaultContext, DocumentNode, ErrorPolicy, OperationVariables, RefetchWritePolicy, TypedDocumentNode, WatchQueryFetchPolicy } from "@apollo/client";
2
2
  import type { SubscribeToMoreFunction } from "@apollo/client";
3
3
  import type { FetchMoreFunction, QueryRef, RefetchFunction } from "@apollo/client/react/internal";
4
- import type { NoInfer, VariablesOption } from "@apollo/client/utilities/internal";
4
+ import type { DocumentationTypes as UtilityDocumentationTypes, NoInfer, VariablesOption } from "@apollo/client/utilities/internal";
5
5
  import type { SkipToken } from "./constants.cjs";
6
6
  export declare namespace useBackgroundQuery {
7
+ import _self = useBackgroundQuery;
7
8
  type FetchPolicy = Extract<WatchQueryFetchPolicy, "cache-first" | "network-only" | "no-cache" | "cache-and-network">;
8
- type Options<TVariables extends OperationVariables = OperationVariables> = {
9
+ namespace Base {
10
+ interface Options {
11
+ /**
12
+ * The instance of `ApolloClient` to use to execute the query.
13
+ *
14
+ * By default, the instance that's passed down via context is used, but you can provide a different instance here.
15
+ *
16
+ * @docGroup
17
+ *
18
+ * 1. Operation options
19
+ */
20
+ client?: ApolloClient;
21
+ /**
22
+ * Watched queries must opt into overwriting existing data on refetch, by passing refetchWritePolicy: "overwrite" in their WatchQueryOptions.
23
+ *
24
+ * The default value is "overwrite".
25
+ *
26
+ * @docGroup
27
+ *
28
+ * 3. Caching options
29
+ */
30
+ refetchWritePolicy?: RefetchWritePolicy;
31
+ /**
32
+ * Specifies how the query handles a response that returns both GraphQL errors and partial results.
33
+ *
34
+ * For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).
35
+ *
36
+ * The default value is `none`, meaning that the query result includes error details but not partial results.
37
+ *
38
+ * @docGroup
39
+ *
40
+ * 1. Operation options
41
+ */
42
+ errorPolicy?: ErrorPolicy;
43
+ /**
44
+ * 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.
45
+ *
46
+ * @docGroup
47
+ *
48
+ * 2. Networking options
49
+ */
50
+ context?: DefaultContext;
51
+ /**
52
+ * If `true`, the query can return partial results from the cache if the cache doesn't contain results for all queried fields.
53
+ *
54
+ * The default value is `false`.
55
+ *
56
+ * @docGroup
57
+ *
58
+ * 3. Caching options
59
+ */
60
+ returnPartialData?: boolean;
61
+ /**
62
+ * Specifies how the query interacts with the Apollo Client cache during execution (for example, whether it checks the cache for results before sending a request to the server).
63
+ *
64
+ * For details, see [Setting a fetch policy](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy).
65
+ *
66
+ * The default value is `cache-first`.
67
+ *
68
+ * @docGroup
69
+ *
70
+ * 3. Caching options
71
+ */
72
+ fetchPolicy?: FetchPolicy;
73
+ /**
74
+ * A unique identifier for the query. Each item in the array must be a stable identifier to prevent infinite fetches.
75
+ *
76
+ * This is useful when using the same query and variables combination in more than one component, otherwise the components may clobber each other. This can also be used to force the query to re-evaluate fresh.
77
+ *
78
+ * @docGroup
79
+ *
80
+ * 1. Operation options
81
+ */
82
+ queryKey?: string | number | any[];
83
+ /**
84
+ * If `true`, the query is not executed. The default value is `false`.
85
+ *
86
+ * @deprecated
87
+ *
88
+ * We recommend using `skipToken` in place of the `skip` option as it is more type-safe.
89
+ *
90
+ * This option is deprecated and only supported to ease the migration from `useQuery`. It will be removed in a future release. Please use [`skipToken`](https://www.apollographql.com/docs/react/api/react/hooks#skiptoken) instead of the `skip` option as it is more type-safe.
91
+ *
92
+ * @docGroup
93
+ *
94
+ * 1. Operation options
95
+ *
96
+ *
97
+ * @example Recommended usage of `skipToken`:
98
+ *
99
+ * ```ts
100
+ * import { skipToken, useBackgroundQuery } from "@apollo/client";
101
+ *
102
+ * const [queryRef] = useBackgroundQuery(
103
+ * query,
104
+ * id ? { variables: { id } } : skipToken
105
+ * );
106
+ * ```
107
+ */
108
+ skip?: boolean;
109
+ }
110
+ }
111
+ type Options<TVariables extends OperationVariables = OperationVariables> = Base.Options & VariablesOption<TVariables>;
112
+ namespace DocumentationTypes {
113
+ namespace useBackgroundQuery {
114
+ interface Options<TVariables extends OperationVariables = OperationVariables> extends Base.Options, UtilityDocumentationTypes.VariableOptions<TVariables> {
115
+ }
116
+ }
117
+ }
118
+ interface Result<TData = unknown, TVariables extends OperationVariables = OperationVariables> {
9
119
  /**
10
- * The instance of `ApolloClient` to use to execute the query.
11
- *
12
- * By default, the instance that's passed down via context is used, but you can provide a different instance here.
13
- *
14
- * @docGroup
120
+ * 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.
15
121
  *
16
- * 1. Operation options
122
+ * This function returns _another_ function that you can call to terminate the subscription.
17
123
  */
18
- client?: ApolloClient;
124
+ subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;
19
125
  /**
20
- * Specifies whether a `NetworkStatus.refetch` operation should merge incoming field data with existing data, or overwrite the existing data. Overwriting is probably preferable, but merging is currently the default behavior, for backwards compatibility with Apollo Client 3.x.
21
- *
22
- * @docGroup
126
+ * 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/).
23
127
  *
24
- * 3. Caching options
128
+ *
129
+ * @remarks
130
+ * Calling this function will cause the component to re-suspend, unless the call site is wrapped in [`startTransition`](https://react.dev/reference/react/startTransition).
25
131
  */
26
- refetchWritePolicy?: RefetchWritePolicy;
132
+ fetchMore: FetchMoreFunction<TData, TVariables>;
27
133
  /**
28
- * Specifies how the query handles a response that returns both GraphQL errors and partial results.
29
- *
30
- * For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).
134
+ * A function that enables you to re-execute the query, optionally passing in new `variables`.
31
135
  *
32
- * The default value is `none`, meaning that the query result includes error details but not partial results.
136
+ * To guarantee that the refetch performs a network request, its `fetchPolicy` is set to `network-only` (unless the original query's `fetchPolicy` is `no-cache` or `cache-and-network`, which also guarantee a network request).
33
137
  *
34
- * @docGroup
138
+ * See also [Refetching](https://www.apollographql.com/docs/react/data/queries/#refetching).
35
139
  *
36
- * 1. Operation options
37
- */
38
- errorPolicy?: ErrorPolicy;
39
- /**
40
- * 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.
140
+ * Returns a `ResultPromise` with an additional `.retain()` method. Calling `.retain()` keeps the network operation running even if the `ObservableQuery` no longer requires the result.
41
141
  *
42
142
  * @docGroup
43
143
  *
44
- * 2. Networking options
45
- */
46
- context?: DefaultContext;
47
- /**
48
- * If `true`, the query can return partial results from the cache if the cache doesn't contain results for all queried fields.
49
- *
50
- * The default value is `false`.
144
+ * 3. Helper functions
51
145
  *
52
- * @docGroup
53
- *
54
- * 3. Caching options
146
+ *
147
+ * @remarks
148
+ * Calling this function will cause the component to re-suspend, unless the call site is wrapped in [`startTransition`](https://react.dev/reference/react/startTransition).
55
149
  */
56
- returnPartialData?: boolean;
150
+ refetch: RefetchFunction<TData, TVariables>;
151
+ }
152
+ namespace DocumentationTypes {
153
+ namespace useBackgroundQuery {
154
+ interface Result<TData = unknown, TVariables extends OperationVariables = OperationVariables> extends _self.Result<TData, TVariables> {
155
+ }
156
+ }
157
+ }
158
+ namespace DocumentationTypes {
57
159
  /**
58
- * Specifies how the query interacts with the Apollo Client cache during execution (for example, whether it checks the cache for results before sending a request to the server).
160
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
59
161
  *
60
- * For details, see [Setting a fetch policy](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy).
162
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
61
163
  *
62
- * The default value is `cache-first`.
164
+ * @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
63
165
  *
64
- * @docGroup
166
+ * @returns A tuple containing:
65
167
  *
66
- * 3. Caching options
67
- */
68
- fetchPolicy?: FetchPolicy;
69
- /**
70
- * A unique identifier for the query. Each item in the array must be a stable identifier to prevent infinite fetches.
168
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped. 2. An object containing helper functions for the query: - `refetch`: A function to re-execute the query - `fetchMore`: A function to fetch more results for pagination - `subscribeToMore`: A function to subscribe to updates
71
169
  *
72
- * This is useful when using the same query and variables combination in more than one component, otherwise the components may clobber each other. This can also be used to force the query to re-evaluate fresh.
170
+ * @example
171
+ * ```jsx
172
+ * import { Suspense } from "react";
173
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
174
+ * import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
73
175
  *
74
- * @docGroup
176
+ * const query = gql`
177
+ * foo {
178
+ * bar
179
+ * }
180
+ * `;
75
181
  *
76
- * 1. Operation options
77
- */
78
- queryKey?: string | number | any[];
79
- /**
80
- * If `true`, the query is not executed. The default value is `false`.
182
+ * const client = new ApolloClient({
183
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
184
+ * cache: new InMemoryCache(),
185
+ * });
81
186
  *
82
- * @deprecated
187
+ * function SuspenseFallback() {
188
+ * return <div>Loading...</div>;
189
+ * }
83
190
  *
84
- * We recommend using `skipToken` in place of the `skip` option as it is more type-safe.
191
+ * function Child({ queryRef }) {
192
+ * const { data } = useReadQuery(queryRef);
85
193
  *
86
- * This option is deprecated and only supported to ease the migration from useQuery. It will be removed in a future release.
194
+ * return <div>{data.foo.bar}</div>;
195
+ * }
87
196
  *
88
- * @docGroup
197
+ * function Parent() {
198
+ * const [queryRef] = useBackgroundQuery(query);
89
199
  *
90
- * 1. Operation options
200
+ * return (
201
+ * <Suspense fallback={<SuspenseFallback />}>
202
+ * <Child queryRef={queryRef} />
203
+ * </Suspense>
204
+ * );
205
+ * }
91
206
  *
92
- *
93
- * @example Recommended usage of `skipToken`:
94
- * ```ts
95
- * import { skipToken, useBackgroundQuery } from '@apollo/client';
96
- *
97
- * const [queryRef] = useBackgroundQuery(query, id ? { variables: { id } } : skipToken);
207
+ * function App() {
208
+ * return (
209
+ * <ApolloProvider client={client}>
210
+ * <Parent />
211
+ * </ApolloProvider>
212
+ * );
213
+ * }
98
214
  * ```
99
215
  */
100
- skip?: boolean;
101
- } & VariablesOption<TVariables>;
102
- type Result<TData = unknown, TVariables extends OperationVariables = OperationVariables> = {
103
- /**
104
- * 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.
105
- *
106
- * This function returns _another_ function that you can call to terminate the subscription.
107
- */
108
- subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;
109
- /**
110
- * 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/).
111
- */
112
- fetchMore: FetchMoreFunction<TData, TVariables>;
113
- /**
114
- * Update the variables of this observable query, and fetch the new results. This method should be preferred over `setVariables` in most use cases.
115
- *
116
- * Returns a `ResultPromise` with an additional `.retain()` method. Calling `.retain()` keeps the network operation running even if the `ObservableQuery` no longer requires the result.
117
- *
118
- * Note: `refetch()` guarantees that a value will be emitted from the observable, even if the result is deep equal to the previous value.
119
- *
120
- * @param variables - The new set of variables. If there are missing variables, the previous values of those variables will be used.
121
- */
122
- refetch: RefetchFunction<TData, TVariables>;
123
- };
216
+ function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | useBackgroundQuery.Options<TVariables>): [
217
+ QueryRef<TData, TVariables> | undefined,
218
+ useBackgroundQuery.Result<TData, TVariables>
219
+ ];
220
+ }
124
221
  }
222
+ /**
223
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
224
+ *
225
+ * @returns A tuple containing:
226
+ *
227
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
228
+ * 2. An object containing helper functions for the query:
229
+ * - `refetch`: A function to re-execute the query
230
+ * - `fetchMore`: A function to fetch more results for pagination
231
+ * - `subscribeToMore`: A function to subscribe to updates
232
+ *
233
+ * @example
234
+ *
235
+ * ```jsx
236
+ * import { Suspense } from "react";
237
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
238
+ * import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
239
+ *
240
+ * const query = gql`
241
+ * foo {
242
+ * bar
243
+ * }
244
+ * `;
245
+ *
246
+ * const client = new ApolloClient({
247
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
248
+ * cache: new InMemoryCache(),
249
+ * });
250
+ *
251
+ * function SuspenseFallback() {
252
+ * return <div>Loading...</div>;
253
+ * }
254
+ *
255
+ * function Child({ queryRef }) {
256
+ * const { data } = useReadQuery(queryRef);
257
+ *
258
+ * return <div>{data.foo.bar}</div>;
259
+ * }
260
+ *
261
+ * function Parent() {
262
+ * const [queryRef] = useBackgroundQuery(query);
263
+ *
264
+ * return (
265
+ * <Suspense fallback={<SuspenseFallback />}>
266
+ * <Child queryRef={queryRef} />
267
+ * </Suspense>
268
+ * );
269
+ * }
270
+ *
271
+ * function App() {
272
+ * return (
273
+ * <ApolloProvider client={client}>
274
+ * <Parent />
275
+ * </ApolloProvider>
276
+ * );
277
+ * }
278
+ * ```
279
+ *
280
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
281
+ * @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
282
+ */
125
283
  export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
126
284
  /** @deprecated `returnPartialData` has no effect on `no-cache` queries */
127
285
  returnPartialData: boolean;
@@ -130,6 +288,63 @@ export declare function useBackgroundQuery<TData = unknown, TVariables extends O
130
288
  QueryRef<TData, TVariables, "complete" | "streaming">,
131
289
  useBackgroundQuery.Result<TData, TVariables>
132
290
  ];
291
+ /**
292
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
293
+ *
294
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
295
+ *
296
+ * @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
297
+ *
298
+ * @returns A tuple containing:
299
+ *
300
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped. 2. An object containing helper functions for the query: - `refetch`: A function to re-execute the query - `fetchMore`: A function to fetch more results for pagination - `subscribeToMore`: A function to subscribe to updates
301
+ *
302
+ * @example
303
+ * ```jsx
304
+ * import { Suspense } from "react";
305
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
306
+ * import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
307
+ *
308
+ * const query = gql`
309
+ * foo {
310
+ * bar
311
+ * }
312
+ * `;
313
+ *
314
+ * const client = new ApolloClient({
315
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
316
+ * cache: new InMemoryCache(),
317
+ * });
318
+ *
319
+ * function SuspenseFallback() {
320
+ * return <div>Loading...</div>;
321
+ * }
322
+ *
323
+ * function Child({ queryRef }) {
324
+ * const { data } = useReadQuery(queryRef);
325
+ *
326
+ * return <div>{data.foo.bar}</div>;
327
+ * }
328
+ *
329
+ * function Parent() {
330
+ * const [queryRef] = useBackgroundQuery(query);
331
+ *
332
+ * return (
333
+ * <Suspense fallback={<SuspenseFallback />}>
334
+ * <Child queryRef={queryRef} />
335
+ * </Suspense>
336
+ * );
337
+ * }
338
+ *
339
+ * function App() {
340
+ * return (
341
+ * <ApolloProvider client={client}>
342
+ * <Parent />
343
+ * </ApolloProvider>
344
+ * );
345
+ * }
346
+ * ```
347
+ */
133
348
  export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
134
349
  returnPartialData: false;
135
350
  errorPolicy: "ignore" | "all";
@@ -137,6 +352,63 @@ export declare function useBackgroundQuery<TData = unknown, TVariables extends O
137
352
  QueryRef<TData, TVariables, "complete" | "streaming" | "empty">,
138
353
  useBackgroundQuery.Result<TData, TVariables>
139
354
  ];
355
+ /**
356
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
357
+ *
358
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
359
+ *
360
+ * @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
361
+ *
362
+ * @returns A tuple containing:
363
+ *
364
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped. 2. An object containing helper functions for the query: - `refetch`: A function to re-execute the query - `fetchMore`: A function to fetch more results for pagination - `subscribeToMore`: A function to subscribe to updates
365
+ *
366
+ * @example
367
+ * ```jsx
368
+ * import { Suspense } from "react";
369
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
370
+ * import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
371
+ *
372
+ * const query = gql`
373
+ * foo {
374
+ * bar
375
+ * }
376
+ * `;
377
+ *
378
+ * const client = new ApolloClient({
379
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
380
+ * cache: new InMemoryCache(),
381
+ * });
382
+ *
383
+ * function SuspenseFallback() {
384
+ * return <div>Loading...</div>;
385
+ * }
386
+ *
387
+ * function Child({ queryRef }) {
388
+ * const { data } = useReadQuery(queryRef);
389
+ *
390
+ * return <div>{data.foo.bar}</div>;
391
+ * }
392
+ *
393
+ * function Parent() {
394
+ * const [queryRef] = useBackgroundQuery(query);
395
+ *
396
+ * return (
397
+ * <Suspense fallback={<SuspenseFallback />}>
398
+ * <Child queryRef={queryRef} />
399
+ * </Suspense>
400
+ * );
401
+ * }
402
+ *
403
+ * function App() {
404
+ * return (
405
+ * <ApolloProvider client={client}>
406
+ * <Parent />
407
+ * </ApolloProvider>
408
+ * );
409
+ * }
410
+ * ```
411
+ */
140
412
  export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
141
413
  returnPartialData: boolean;
142
414
  errorPolicy: "ignore" | "all";
@@ -144,12 +416,126 @@ export declare function useBackgroundQuery<TData = unknown, TVariables extends O
144
416
  QueryRef<TData, TVariables, "complete" | "streaming" | "partial" | "empty">,
145
417
  useBackgroundQuery.Result<TData, TVariables>
146
418
  ];
419
+ /**
420
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
421
+ *
422
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
423
+ *
424
+ * @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
425
+ *
426
+ * @returns A tuple containing:
427
+ *
428
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped. 2. An object containing helper functions for the query: - `refetch`: A function to re-execute the query - `fetchMore`: A function to fetch more results for pagination - `subscribeToMore`: A function to subscribe to updates
429
+ *
430
+ * @example
431
+ * ```jsx
432
+ * import { Suspense } from "react";
433
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
434
+ * import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
435
+ *
436
+ * const query = gql`
437
+ * foo {
438
+ * bar
439
+ * }
440
+ * `;
441
+ *
442
+ * const client = new ApolloClient({
443
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
444
+ * cache: new InMemoryCache(),
445
+ * });
446
+ *
447
+ * function SuspenseFallback() {
448
+ * return <div>Loading...</div>;
449
+ * }
450
+ *
451
+ * function Child({ queryRef }) {
452
+ * const { data } = useReadQuery(queryRef);
453
+ *
454
+ * return <div>{data.foo.bar}</div>;
455
+ * }
456
+ *
457
+ * function Parent() {
458
+ * const [queryRef] = useBackgroundQuery(query);
459
+ *
460
+ * return (
461
+ * <Suspense fallback={<SuspenseFallback />}>
462
+ * <Child queryRef={queryRef} />
463
+ * </Suspense>
464
+ * );
465
+ * }
466
+ *
467
+ * function App() {
468
+ * return (
469
+ * <ApolloProvider client={client}>
470
+ * <Parent />
471
+ * </ApolloProvider>
472
+ * );
473
+ * }
474
+ * ```
475
+ */
147
476
  export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
148
477
  errorPolicy: "ignore" | "all";
149
478
  }): [
150
479
  QueryRef<TData, TVariables, "complete" | "streaming" | "empty">,
151
480
  useBackgroundQuery.Result<TData, TVariables>
152
481
  ];
482
+ /**
483
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
484
+ *
485
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
486
+ *
487
+ * @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
488
+ *
489
+ * @returns A tuple containing:
490
+ *
491
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped. 2. An object containing helper functions for the query: - `refetch`: A function to re-execute the query - `fetchMore`: A function to fetch more results for pagination - `subscribeToMore`: A function to subscribe to updates
492
+ *
493
+ * @example
494
+ * ```jsx
495
+ * import { Suspense } from "react";
496
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
497
+ * import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
498
+ *
499
+ * const query = gql`
500
+ * foo {
501
+ * bar
502
+ * }
503
+ * `;
504
+ *
505
+ * const client = new ApolloClient({
506
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
507
+ * cache: new InMemoryCache(),
508
+ * });
509
+ *
510
+ * function SuspenseFallback() {
511
+ * return <div>Loading...</div>;
512
+ * }
513
+ *
514
+ * function Child({ queryRef }) {
515
+ * const { data } = useReadQuery(queryRef);
516
+ *
517
+ * return <div>{data.foo.bar}</div>;
518
+ * }
519
+ *
520
+ * function Parent() {
521
+ * const [queryRef] = useBackgroundQuery(query);
522
+ *
523
+ * return (
524
+ * <Suspense fallback={<SuspenseFallback />}>
525
+ * <Child queryRef={queryRef} />
526
+ * </Suspense>
527
+ * );
528
+ * }
529
+ *
530
+ * function App() {
531
+ * return (
532
+ * <ApolloProvider client={client}>
533
+ * <Parent />
534
+ * </ApolloProvider>
535
+ * );
536
+ * }
537
+ * ```
538
+ */
153
539
  export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
154
540
  skip: boolean;
155
541
  returnPartialData: false;
@@ -157,6 +543,63 @@ export declare function useBackgroundQuery<TData = unknown, TVariables extends O
157
543
  QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
158
544
  useBackgroundQuery.Result<TData, TVariables>
159
545
  ];
546
+ /**
547
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
548
+ *
549
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
550
+ *
551
+ * @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
552
+ *
553
+ * @returns A tuple containing:
554
+ *
555
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped. 2. An object containing helper functions for the query: - `refetch`: A function to re-execute the query - `fetchMore`: A function to fetch more results for pagination - `subscribeToMore`: A function to subscribe to updates
556
+ *
557
+ * @example
558
+ * ```jsx
559
+ * import { Suspense } from "react";
560
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
561
+ * import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
562
+ *
563
+ * const query = gql`
564
+ * foo {
565
+ * bar
566
+ * }
567
+ * `;
568
+ *
569
+ * const client = new ApolloClient({
570
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
571
+ * cache: new InMemoryCache(),
572
+ * });
573
+ *
574
+ * function SuspenseFallback() {
575
+ * return <div>Loading...</div>;
576
+ * }
577
+ *
578
+ * function Child({ queryRef }) {
579
+ * const { data } = useReadQuery(queryRef);
580
+ *
581
+ * return <div>{data.foo.bar}</div>;
582
+ * }
583
+ *
584
+ * function Parent() {
585
+ * const [queryRef] = useBackgroundQuery(query);
586
+ *
587
+ * return (
588
+ * <Suspense fallback={<SuspenseFallback />}>
589
+ * <Child queryRef={queryRef} />
590
+ * </Suspense>
591
+ * );
592
+ * }
593
+ *
594
+ * function App() {
595
+ * return (
596
+ * <ApolloProvider client={client}>
597
+ * <Parent />
598
+ * </ApolloProvider>
599
+ * );
600
+ * }
601
+ * ```
602
+ */
160
603
  export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
161
604
  skip: boolean;
162
605
  returnPartialData: boolean;
@@ -164,25 +607,310 @@ export declare function useBackgroundQuery<TData = unknown, TVariables extends O
164
607
  QueryRef<TData, TVariables, "complete" | "streaming" | "partial"> | undefined,
165
608
  useBackgroundQuery.Result<TData, TVariables>
166
609
  ];
610
+ /**
611
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
612
+ *
613
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
614
+ *
615
+ * @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
616
+ *
617
+ * @returns A tuple containing:
618
+ *
619
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped. 2. An object containing helper functions for the query: - `refetch`: A function to re-execute the query - `fetchMore`: A function to fetch more results for pagination - `subscribeToMore`: A function to subscribe to updates
620
+ *
621
+ * @example
622
+ * ```jsx
623
+ * import { Suspense } from "react";
624
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
625
+ * import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
626
+ *
627
+ * const query = gql`
628
+ * foo {
629
+ * bar
630
+ * }
631
+ * `;
632
+ *
633
+ * const client = new ApolloClient({
634
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
635
+ * cache: new InMemoryCache(),
636
+ * });
637
+ *
638
+ * function SuspenseFallback() {
639
+ * return <div>Loading...</div>;
640
+ * }
641
+ *
642
+ * function Child({ queryRef }) {
643
+ * const { data } = useReadQuery(queryRef);
644
+ *
645
+ * return <div>{data.foo.bar}</div>;
646
+ * }
647
+ *
648
+ * function Parent() {
649
+ * const [queryRef] = useBackgroundQuery(query);
650
+ *
651
+ * return (
652
+ * <Suspense fallback={<SuspenseFallback />}>
653
+ * <Child queryRef={queryRef} />
654
+ * </Suspense>
655
+ * );
656
+ * }
657
+ *
658
+ * function App() {
659
+ * return (
660
+ * <ApolloProvider client={client}>
661
+ * <Parent />
662
+ * </ApolloProvider>
663
+ * );
664
+ * }
665
+ * ```
666
+ */
167
667
  export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
168
668
  returnPartialData: false;
169
669
  }): [
170
670
  QueryRef<TData, TVariables, "complete" | "streaming">,
171
671
  useBackgroundQuery.Result<TData, TVariables>
172
672
  ];
673
+ /**
674
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
675
+ *
676
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
677
+ *
678
+ * @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
679
+ *
680
+ * @returns A tuple containing:
681
+ *
682
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped. 2. An object containing helper functions for the query: - `refetch`: A function to re-execute the query - `fetchMore`: A function to fetch more results for pagination - `subscribeToMore`: A function to subscribe to updates
683
+ *
684
+ * @example
685
+ * ```jsx
686
+ * import { Suspense } from "react";
687
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
688
+ * import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
689
+ *
690
+ * const query = gql`
691
+ * foo {
692
+ * bar
693
+ * }
694
+ * `;
695
+ *
696
+ * const client = new ApolloClient({
697
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
698
+ * cache: new InMemoryCache(),
699
+ * });
700
+ *
701
+ * function SuspenseFallback() {
702
+ * return <div>Loading...</div>;
703
+ * }
704
+ *
705
+ * function Child({ queryRef }) {
706
+ * const { data } = useReadQuery(queryRef);
707
+ *
708
+ * return <div>{data.foo.bar}</div>;
709
+ * }
710
+ *
711
+ * function Parent() {
712
+ * const [queryRef] = useBackgroundQuery(query);
713
+ *
714
+ * return (
715
+ * <Suspense fallback={<SuspenseFallback />}>
716
+ * <Child queryRef={queryRef} />
717
+ * </Suspense>
718
+ * );
719
+ * }
720
+ *
721
+ * function App() {
722
+ * return (
723
+ * <ApolloProvider client={client}>
724
+ * <Parent />
725
+ * </ApolloProvider>
726
+ * );
727
+ * }
728
+ * ```
729
+ */
173
730
  export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
174
731
  returnPartialData: boolean;
175
732
  }): [
176
733
  QueryRef<TData, TVariables, "complete" | "streaming" | "partial">,
177
734
  useBackgroundQuery.Result<TData, TVariables>
178
735
  ];
736
+ /**
737
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
738
+ *
739
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
740
+ *
741
+ * @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
742
+ *
743
+ * @returns A tuple containing:
744
+ *
745
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped. 2. An object containing helper functions for the query: - `refetch`: A function to re-execute the query - `fetchMore`: A function to fetch more results for pagination - `subscribeToMore`: A function to subscribe to updates
746
+ *
747
+ * @example
748
+ * ```jsx
749
+ * import { Suspense } from "react";
750
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
751
+ * import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
752
+ *
753
+ * const query = gql`
754
+ * foo {
755
+ * bar
756
+ * }
757
+ * `;
758
+ *
759
+ * const client = new ApolloClient({
760
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
761
+ * cache: new InMemoryCache(),
762
+ * });
763
+ *
764
+ * function SuspenseFallback() {
765
+ * return <div>Loading...</div>;
766
+ * }
767
+ *
768
+ * function Child({ queryRef }) {
769
+ * const { data } = useReadQuery(queryRef);
770
+ *
771
+ * return <div>{data.foo.bar}</div>;
772
+ * }
773
+ *
774
+ * function Parent() {
775
+ * const [queryRef] = useBackgroundQuery(query);
776
+ *
777
+ * return (
778
+ * <Suspense fallback={<SuspenseFallback />}>
779
+ * <Child queryRef={queryRef} />
780
+ * </Suspense>
781
+ * );
782
+ * }
783
+ *
784
+ * function App() {
785
+ * return (
786
+ * <ApolloProvider client={client}>
787
+ * <Parent />
788
+ * </ApolloProvider>
789
+ * );
790
+ * }
791
+ * ```
792
+ */
179
793
  export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
180
794
  skip: boolean;
181
795
  }): [
182
796
  QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
183
797
  useBackgroundQuery.Result<TData, TVariables>
184
798
  ];
799
+ /**
800
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
801
+ *
802
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
803
+ *
804
+ * @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
805
+ *
806
+ * @returns A tuple containing:
807
+ *
808
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped. 2. An object containing helper functions for the query: - `refetch`: A function to re-execute the query - `fetchMore`: A function to fetch more results for pagination - `subscribeToMore`: A function to subscribe to updates
809
+ *
810
+ * @example
811
+ * ```jsx
812
+ * import { Suspense } from "react";
813
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
814
+ * import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
815
+ *
816
+ * const query = gql`
817
+ * foo {
818
+ * bar
819
+ * }
820
+ * `;
821
+ *
822
+ * const client = new ApolloClient({
823
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
824
+ * cache: new InMemoryCache(),
825
+ * });
826
+ *
827
+ * function SuspenseFallback() {
828
+ * return <div>Loading...</div>;
829
+ * }
830
+ *
831
+ * function Child({ queryRef }) {
832
+ * const { data } = useReadQuery(queryRef);
833
+ *
834
+ * return <div>{data.foo.bar}</div>;
835
+ * }
836
+ *
837
+ * function Parent() {
838
+ * const [queryRef] = useBackgroundQuery(query);
839
+ *
840
+ * return (
841
+ * <Suspense fallback={<SuspenseFallback />}>
842
+ * <Child queryRef={queryRef} />
843
+ * </Suspense>
844
+ * );
845
+ * }
846
+ *
847
+ * function App() {
848
+ * return (
849
+ * <ApolloProvider client={client}>
850
+ * <Parent />
851
+ * </ApolloProvider>
852
+ * );
853
+ * }
854
+ * ```
855
+ */
185
856
  export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken): [undefined, useBackgroundQuery.Result<TData, TVariables>];
857
+ /**
858
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
859
+ *
860
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
861
+ *
862
+ * @param options - An optional object containing options for the query. Instead of passing a `useBackgroundQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useBackgroundQuery` hook from executing the query or suspending.
863
+ *
864
+ * @returns A tuple containing:
865
+ *
866
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped. 2. An object containing helper functions for the query: - `refetch`: A function to re-execute the query - `fetchMore`: A function to fetch more results for pagination - `subscribeToMore`: A function to subscribe to updates
867
+ *
868
+ * @example
869
+ * ```jsx
870
+ * import { Suspense } from "react";
871
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
872
+ * import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
873
+ *
874
+ * const query = gql`
875
+ * foo {
876
+ * bar
877
+ * }
878
+ * `;
879
+ *
880
+ * const client = new ApolloClient({
881
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
882
+ * cache: new InMemoryCache(),
883
+ * });
884
+ *
885
+ * function SuspenseFallback() {
886
+ * return <div>Loading...</div>;
887
+ * }
888
+ *
889
+ * function Child({ queryRef }) {
890
+ * const { data } = useReadQuery(queryRef);
891
+ *
892
+ * return <div>{data.foo.bar}</div>;
893
+ * }
894
+ *
895
+ * function Parent() {
896
+ * const [queryRef] = useBackgroundQuery(query);
897
+ *
898
+ * return (
899
+ * <Suspense fallback={<SuspenseFallback />}>
900
+ * <Child queryRef={queryRef} />
901
+ * </Suspense>
902
+ * );
903
+ * }
904
+ *
905
+ * function App() {
906
+ * return (
907
+ * <ApolloProvider client={client}>
908
+ * <Parent />
909
+ * </ApolloProvider>
910
+ * );
911
+ * }
912
+ * ```
913
+ */
186
914
  export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (useBackgroundQuery.Options<NoInfer<TVariables>> & {
187
915
  returnPartialData: false;
188
916
  })): [