@octanejs/apollo-client 0.1.0

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 (85) hide show
  1. package/LICENSE +49 -0
  2. package/README.md +97 -0
  3. package/package.json +77 -0
  4. package/src/index.d.ts +1 -0
  5. package/src/index.js +3 -0
  6. package/src/react/context/ApolloContext.d.ts +8 -0
  7. package/src/react/context/ApolloContext.js +21 -0
  8. package/src/react/context/ApolloProvider.d.ts +9 -0
  9. package/src/react/context/ApolloProvider.js +15 -0
  10. package/src/react/hooks/constants.d.ts +2 -0
  11. package/src/react/hooks/constants.js +1 -0
  12. package/src/react/hooks/internal/__use.d.ts +3 -0
  13. package/src/react/hooks/internal/__use.js +9 -0
  14. package/src/react/hooks/internal/index.d.ts +5 -0
  15. package/src/react/hooks/internal/index.js +6 -0
  16. package/src/react/hooks/internal/site.d.ts +2 -0
  17. package/src/react/hooks/internal/site.js +20 -0
  18. package/src/react/hooks/internal/useDeepMemo.d.ts +5 -0
  19. package/src/react/hooks/internal/useDeepMemo.js +11 -0
  20. package/src/react/hooks/internal/useIsomorphicLayoutEffect.d.ts +2 -0
  21. package/src/react/hooks/internal/useIsomorphicLayoutEffect.js +8 -0
  22. package/src/react/hooks/internal/useRenderGuard.d.ts +1 -0
  23. package/src/react/hooks/internal/useRenderGuard.js +14 -0
  24. package/src/react/hooks/internal/useSuspenseHookCacheKey.d.ts +13 -0
  25. package/src/react/hooks/internal/useSuspenseHookCacheKey.js +19 -0
  26. package/src/react/hooks/internal/validateSuspenseHookOptions.d.ts +4 -0
  27. package/src/react/hooks/internal/validateSuspenseHookOptions.js +16 -0
  28. package/src/react/hooks/internal/wrapHook.d.ts +77 -0
  29. package/src/react/hooks/internal/wrapHook.js +64 -0
  30. package/src/react/hooks/useApolloClient.d.ts +17 -0
  31. package/src/react/hooks/useApolloClient.js +27 -0
  32. package/src/react/hooks/useBackgroundQuery.d.ts +3061 -0
  33. package/src/react/hooks/useBackgroundQuery.js +88 -0
  34. package/src/react/hooks/useFragment.d.ts +205 -0
  35. package/src/react/hooks/useFragment.js +75 -0
  36. package/src/react/hooks/useLazyQuery.d.ts +947 -0
  37. package/src/react/hooks/useLazyQuery.js +156 -0
  38. package/src/react/hooks/useLoadableQuery.d.ts +955 -0
  39. package/src/react/hooks/useLoadableQuery.js +98 -0
  40. package/src/react/hooks/useMutation.d.ts +585 -0
  41. package/src/react/hooks/useMutation.js +121 -0
  42. package/src/react/hooks/useQuery.d.ts +1401 -0
  43. package/src/react/hooks/useQuery.js +234 -0
  44. package/src/react/hooks/useQueryRefHandlers.d.ts +85 -0
  45. package/src/react/hooks/useQueryRefHandlers.js +79 -0
  46. package/src/react/hooks/useReactiveVar.d.ts +21 -0
  47. package/src/react/hooks/useReactiveVar.js +41 -0
  48. package/src/react/hooks/useReadQuery.d.ts +104 -0
  49. package/src/react/hooks/useReadQuery.js +83 -0
  50. package/src/react/hooks/useSubscription.d.ts +289 -0
  51. package/src/react/hooks/useSubscription.js +258 -0
  52. package/src/react/hooks/useSuspenseFragment.d.ts +154 -0
  53. package/src/react/hooks/useSuspenseFragment.js +50 -0
  54. package/src/react/hooks/useSuspenseQuery.d.ts +1629 -0
  55. package/src/react/hooks/useSuspenseQuery.js +130 -0
  56. package/src/react/hooks/useSyncExternalStore.d.ts +2 -0
  57. package/src/react/hooks/useSyncExternalStore.js +125 -0
  58. package/src/react/index.d.ts +68 -0
  59. package/src/react/index.js +18 -0
  60. package/src/react/internal/cache/FragmentReference.d.ts +41 -0
  61. package/src/react/internal/cache/FragmentReference.js +117 -0
  62. package/src/react/internal/cache/QueryReference.d.ts +180 -0
  63. package/src/react/internal/cache/QueryReference.js +310 -0
  64. package/src/react/internal/cache/SuspenseCache.d.ts +38 -0
  65. package/src/react/internal/cache/SuspenseCache.js +39 -0
  66. package/src/react/internal/cache/getSuspenseCache.d.ts +26 -0
  67. package/src/react/internal/cache/getSuspenseCache.js +8 -0
  68. package/src/react/internal/cache/types.d.ts +13 -0
  69. package/src/react/internal/cache/types.js +1 -0
  70. package/src/react/internal/index.d.ts +16 -0
  71. package/src/react/internal/index.js +10 -0
  72. package/src/react/internal/types.d.ts +15 -0
  73. package/src/react/internal/types.js +1 -0
  74. package/src/react/query-preloader/createQueryPreloader.d.ts +630 -0
  75. package/src/react/query-preloader/createQueryPreloader.js +89 -0
  76. package/src/react/types/deprecated.d.ts +140 -0
  77. package/src/react/types/deprecated.js +1 -0
  78. package/src/react/types/types.documentation.d.ts +551 -0
  79. package/src/react/types/types.documentation.js +1 -0
  80. package/src/testing/index.d.ts +1 -0
  81. package/src/testing/index.js +1 -0
  82. package/src/testing/react/MockedProvider.d.ts +21 -0
  83. package/src/testing/react/MockedProvider.js +53 -0
  84. package/src/testing/react/index.d.ts +2 -0
  85. package/src/testing/react/index.js +1 -0
@@ -0,0 +1,3061 @@
1
+ import type {
2
+ ApolloClient,
3
+ DefaultContext,
4
+ DocumentNode,
5
+ ErrorPolicy,
6
+ OperationVariables,
7
+ RefetchOn,
8
+ RefetchWritePolicy,
9
+ TypedDocumentNode,
10
+ WatchQueryFetchPolicy,
11
+ } from '@apollo/client';
12
+ import type { SubscribeToMoreFunction } from '@apollo/client';
13
+ import type { QueryRef } from '@octanejs/apollo-client/react';
14
+ import type { FetchMoreFunction, RefetchFunction } from '@octanejs/apollo-client/react/internal';
15
+ import type {
16
+ DocumentationTypes as UtilityDocumentationTypes,
17
+ NoInfer,
18
+ OptionWithFallback,
19
+ SignatureStyle,
20
+ VariablesOption,
21
+ } from '@apollo/client/utilities/internal';
22
+ import type { SkipToken } from './constants.js';
23
+ export declare namespace useBackgroundQuery {
24
+ import _self = useBackgroundQuery;
25
+ type FetchPolicy = Extract<
26
+ WatchQueryFetchPolicy,
27
+ 'cache-first' | 'network-only' | 'no-cache' | 'cache-and-network'
28
+ >;
29
+ namespace Base {
30
+ interface Options {
31
+ /**
32
+ * The instance of `ApolloClient` to use to execute the query.
33
+ *
34
+ * By default, the instance that's passed down via context is used, but you
35
+ * can provide a different instance here.
36
+ *
37
+ * @docGroup 1. Operation options
38
+ */
39
+ client?: ApolloClient;
40
+ /**
41
+ * Watched queries must opt into overwriting existing data on refetch, by passing refetchWritePolicy: "overwrite" in their WatchQueryOptions.
42
+ *
43
+ * The default value is "overwrite".
44
+ *
45
+ * @docGroup 3. Caching options
46
+ */
47
+ refetchWritePolicy?: RefetchWritePolicy;
48
+ /**
49
+ * Specifies how the query handles a response that returns both GraphQL errors and partial results.
50
+ *
51
+ * For details, see [GraphQL error policies](https://www.apollographql.com/docs/react/data/error-handling/#graphql-error-policies).
52
+ *
53
+ * The default value is `none`, meaning that the query result includes error details but not partial results.
54
+ *
55
+ * @docGroup 1. Operation options
56
+ */
57
+ errorPolicy?: ErrorPolicy;
58
+ /**
59
+ * 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.
60
+ *
61
+ * @docGroup 2. Networking options
62
+ */
63
+ context?: DefaultContext;
64
+ /**
65
+ * If `true`, the query can return partial results from the cache if the cache doesn't contain results for all queried fields.
66
+ *
67
+ * The default value is `false`.
68
+ *
69
+ * @docGroup 3. Caching options
70
+ */
71
+ returnPartialData?: boolean;
72
+ /**
73
+ * 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).
74
+ *
75
+ * For details, see [Setting a fetch policy](https://www.apollographql.com/docs/react/data/queries/#setting-a-fetch-policy).
76
+ *
77
+ * The default value is `cache-first`.
78
+ *
79
+ * @docGroup 3. Caching options
80
+ */
81
+ fetchPolicy?: FetchPolicy;
82
+ /**
83
+ * A unique identifier for the query. Each item in the array must be a stable
84
+ * identifier to prevent infinite fetches.
85
+ *
86
+ * This is useful when using the same query and variables combination in more
87
+ * than one component, otherwise the components may clobber each other. This
88
+ * can also be used to force the query to re-evaluate fresh.
89
+ *
90
+ * @docGroup 1. Operation options
91
+ */
92
+ queryKey?: string | number | any[];
93
+ /**
94
+ * Determines whether events trigger refetches for the query. Provide an
95
+ * object mapping each refetch event to `true` (enable), `false` (disable)
96
+ * or a callback function that returns `true`/`false` to control individual
97
+ * events. Provide `false` to disable all automatic refetch events for this
98
+ * query. Provide `true` to enable all automatic refetch events for this query.
99
+ * Provide a callback function to perform additional logic to determine
100
+ * whether to enable or disable a refetch for a query.
101
+ *
102
+ * `@remarks`
103
+ * `refetchOn` inherits from `defaultOptions.watchQuery.refetchOn`. If
104
+ * `defaultOptions.watchQuery.refetchOn` is not set, all refetch events are
105
+ * enabled by default.
106
+ *
107
+ * This option only has an effect when the client is configured with a
108
+ * `refetchEventManager`.
109
+ * @docGroup 1. Operation options
110
+ */
111
+ refetchOn?: RefetchOn.Option;
112
+ /**
113
+ * If `true`, the query is not executed. The default value is `false`.
114
+ *
115
+ * @deprecated We recommend using `skipToken` in place of the `skip` option as
116
+ * it is more type-safe.
117
+ *
118
+ * This option is deprecated and only supported to ease the migration from `useQuery`. It will be removed in a future release.
119
+ * Please use [`skipToken`](https://www.apollographql.com/docs/react/api/react/hooks#skiptoken) instead of the `skip` option as it is more type-safe.
120
+ *
121
+ * @docGroup 1. Operation options
122
+ *
123
+ *
124
+ * @example Recommended usage of `skipToken`:
125
+ *
126
+ * ```ts
127
+ * import { skipToken, useBackgroundQuery } from "@apollo/client";
128
+ *
129
+ * const [queryRef] = useBackgroundQuery(
130
+ * query,
131
+ * id ? { variables: { id } } : skipToken
132
+ * );
133
+ * ```
134
+ */
135
+ skip?: boolean;
136
+ }
137
+ }
138
+ type Options<TVariables extends OperationVariables = OperationVariables> = Base.Options &
139
+ VariablesOption<TVariables>;
140
+ namespace DocumentationTypes {
141
+ namespace useBackgroundQuery {
142
+ interface Options<TVariables extends OperationVariables = OperationVariables>
143
+ extends Base.Options, UtilityDocumentationTypes.VariableOptions<TVariables> {}
144
+ }
145
+ }
146
+ interface Result<TData = unknown, TVariables extends OperationVariables = OperationVariables> {
147
+ /**
148
+ * 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.
149
+ *
150
+ * This function returns _another_ function that you can call to terminate the subscription.
151
+ */
152
+ subscribeToMore: SubscribeToMoreFunction<TData, TVariables>;
153
+ /**
154
+ * 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/).
155
+ *
156
+ *
157
+ * @remarks
158
+ * Calling this function will cause the component to re-suspend, unless the call site is wrapped in [`startTransition`](https://react.dev/reference/react/startTransition).
159
+ */
160
+ fetchMore: FetchMoreFunction<TData, TVariables>;
161
+ /**
162
+ * A function that enables you to re-execute the query, optionally passing in new `variables`.
163
+ *
164
+ * 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).
165
+ *
166
+ * See also [Refetching](https://www.apollographql.com/docs/react/data/queries/#refetching).
167
+ *
168
+ * Returns a `ResultPromise` with an additional `.retain()` method. Calling
169
+ * `.retain()` keeps the network operation running even if the `ObservableQuery`
170
+ * no longer requires the result.
171
+ *
172
+ * @docGroup 3. Helper functions
173
+ *
174
+ *
175
+ * @remarks
176
+ * Calling this function will cause the component to re-suspend, unless the call site is wrapped in [`startTransition`](https://react.dev/reference/react/startTransition).
177
+ */
178
+ refetch: RefetchFunction<TData, TVariables>;
179
+ }
180
+ namespace DocumentationTypes {
181
+ namespace useBackgroundQuery {
182
+ interface Result<
183
+ TData = unknown,
184
+ TVariables extends OperationVariables = OperationVariables,
185
+ > extends _self.Result<TData, TVariables> {}
186
+ }
187
+ }
188
+ interface DefaultOptions extends ApolloClient.DefaultOptions.WatchQuery.Calculated {
189
+ skip: false;
190
+ }
191
+ type ResultForOptions<
192
+ TData,
193
+ TVariables extends OperationVariables,
194
+ TOptions extends Record<string, never> | Options<TVariables> | SkipToken,
195
+ > = [
196
+ queryRef: TOptions extends any
197
+ ? TOptions extends SkipToken
198
+ ? undefined
199
+ :
200
+ | QueryRef<
201
+ TData,
202
+ TVariables,
203
+ | 'complete'
204
+ | 'streaming'
205
+ | (
206
+ | (OptionWithFallback<TOptions, DefaultOptions, 'errorPolicy'> extends 'none'
207
+ ? never
208
+ : 'empty')
209
+ | (OptionWithFallback<
210
+ TOptions,
211
+ DefaultOptions,
212
+ 'returnPartialData'
213
+ > extends false
214
+ ? never
215
+ : 'partial')
216
+ )
217
+ >
218
+ | (OptionWithFallback<TOptions, DefaultOptions, 'skip'> extends false
219
+ ? never
220
+ : undefined)
221
+ : never,
222
+ result: useBackgroundQuery.Result<TData, TVariables>,
223
+ ];
224
+ namespace DocumentationTypes {
225
+ interface useBackgroundQuery {
226
+ /**
227
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
228
+ *
229
+ * @returns A tuple containing:
230
+ *
231
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
232
+ * 2. An object containing helper functions for the query:
233
+ * - `refetch`: A function to re-execute the query
234
+ * - `fetchMore`: A function to fetch more results for pagination
235
+ * - `subscribeToMore`: A function to subscribe to updates
236
+ *
237
+ * @example
238
+ *
239
+ * ```jsx
240
+ * import { Suspense } from "octane";
241
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
242
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
243
+ *
244
+ * const query = gql`
245
+ * foo {
246
+ * bar
247
+ * }
248
+ * `;
249
+ *
250
+ * const client = new ApolloClient({
251
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
252
+ * cache: new InMemoryCache(),
253
+ * });
254
+ *
255
+ * function SuspenseFallback() {
256
+ * return <div>Loading...</div>;
257
+ * }
258
+ *
259
+ * function Child({ queryRef }) {
260
+ * const { data } = useReadQuery(queryRef);
261
+ *
262
+ * return <div>{data.foo.bar}</div>;
263
+ * }
264
+ *
265
+ * function Parent() {
266
+ * const [queryRef] = useBackgroundQuery(query);
267
+ *
268
+ * return (
269
+ * <Suspense fallback={<SuspenseFallback />}>
270
+ * <Child queryRef={queryRef} />
271
+ * </Suspense>
272
+ * );
273
+ * }
274
+ *
275
+ * function App() {
276
+ * return (
277
+ * <ApolloProvider client={client}>
278
+ * <Parent />
279
+ * </ApolloProvider>
280
+ * );
281
+ * }
282
+ * ```
283
+ *
284
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
285
+ * @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.
286
+ */
287
+ <TData = unknown, TVariables extends OperationVariables = OperationVariables>(
288
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
289
+ options: SkipToken | useBackgroundQuery.Options<TVariables>,
290
+ ): [QueryRef<TData, TVariables> | undefined, useBackgroundQuery.Result<TData, TVariables>];
291
+ }
292
+ interface useBackgroundQuery_Deprecated {
293
+ /**
294
+ * @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
295
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
296
+ *
297
+ *
298
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
299
+ *
300
+ * @returns A tuple containing:
301
+ *
302
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
303
+ * 2. An object containing helper functions for the query:
304
+ * - `refetch`: A function to re-execute the query
305
+ * - `fetchMore`: A function to fetch more results for pagination
306
+ * - `subscribeToMore`: A function to subscribe to updates
307
+ *
308
+ * @example
309
+ *
310
+ * ```jsx
311
+ * import { Suspense } from "octane";
312
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
313
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
314
+ *
315
+ * const query = gql`
316
+ * foo {
317
+ * bar
318
+ * }
319
+ * `;
320
+ *
321
+ * const client = new ApolloClient({
322
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
323
+ * cache: new InMemoryCache(),
324
+ * });
325
+ *
326
+ * function SuspenseFallback() {
327
+ * return <div>Loading...</div>;
328
+ * }
329
+ *
330
+ * function Child({ queryRef }) {
331
+ * const { data } = useReadQuery(queryRef);
332
+ *
333
+ * return <div>{data.foo.bar}</div>;
334
+ * }
335
+ *
336
+ * function Parent() {
337
+ * const [queryRef] = useBackgroundQuery(query);
338
+ *
339
+ * return (
340
+ * <Suspense fallback={<SuspenseFallback />}>
341
+ * <Child queryRef={queryRef} />
342
+ * </Suspense>
343
+ * );
344
+ * }
345
+ *
346
+ * function App() {
347
+ * return (
348
+ * <ApolloProvider client={client}>
349
+ * <Parent />
350
+ * </ApolloProvider>
351
+ * );
352
+ * }
353
+ * ```
354
+ *
355
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
356
+ * @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.
357
+ */
358
+ <TData = unknown, TVariables extends OperationVariables = OperationVariables>(
359
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
360
+ options: SkipToken | useBackgroundQuery.Options<TVariables>,
361
+ ): [QueryRef<TData, TVariables> | undefined, useBackgroundQuery.Result<TData, TVariables>];
362
+ }
363
+ }
364
+ namespace Signatures {
365
+ /**
366
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
367
+ *
368
+ * @returns A tuple containing:
369
+ *
370
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
371
+ * 2. An object containing helper functions for the query:
372
+ * - `refetch`: A function to re-execute the query
373
+ * - `fetchMore`: A function to fetch more results for pagination
374
+ * - `subscribeToMore`: A function to subscribe to updates
375
+ *
376
+ * @example
377
+ *
378
+ * ```jsx
379
+ * import { Suspense } from "octane";
380
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
381
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
382
+ *
383
+ * const query = gql`
384
+ * foo {
385
+ * bar
386
+ * }
387
+ * `;
388
+ *
389
+ * const client = new ApolloClient({
390
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
391
+ * cache: new InMemoryCache(),
392
+ * });
393
+ *
394
+ * function SuspenseFallback() {
395
+ * return <div>Loading...</div>;
396
+ * }
397
+ *
398
+ * function Child({ queryRef }) {
399
+ * const { data } = useReadQuery(queryRef);
400
+ *
401
+ * return <div>{data.foo.bar}</div>;
402
+ * }
403
+ *
404
+ * function Parent() {
405
+ * const [queryRef] = useBackgroundQuery(query);
406
+ *
407
+ * return (
408
+ * <Suspense fallback={<SuspenseFallback />}>
409
+ * <Child queryRef={queryRef} />
410
+ * </Suspense>
411
+ * );
412
+ * }
413
+ *
414
+ * function App() {
415
+ * return (
416
+ * <ApolloProvider client={client}>
417
+ * <Parent />
418
+ * </ApolloProvider>
419
+ * );
420
+ * }
421
+ * ```
422
+ *
423
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
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
+ interface Classic {
427
+ /**
428
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
429
+ *
430
+ * @returns A tuple containing:
431
+ *
432
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
433
+ * 2. An object containing helper functions for the query:
434
+ * - `refetch`: A function to re-execute the query
435
+ * - `fetchMore`: A function to fetch more results for pagination
436
+ * - `subscribeToMore`: A function to subscribe to updates
437
+ *
438
+ * @example
439
+ *
440
+ * ```jsx
441
+ * import { Suspense } from "octane";
442
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
443
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
444
+ *
445
+ * const query = gql`
446
+ * foo {
447
+ * bar
448
+ * }
449
+ * `;
450
+ *
451
+ * const client = new ApolloClient({
452
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
453
+ * cache: new InMemoryCache(),
454
+ * });
455
+ *
456
+ * function SuspenseFallback() {
457
+ * return <div>Loading...</div>;
458
+ * }
459
+ *
460
+ * function Child({ queryRef }) {
461
+ * const { data } = useReadQuery(queryRef);
462
+ *
463
+ * return <div>{data.foo.bar}</div>;
464
+ * }
465
+ *
466
+ * function Parent() {
467
+ * const [queryRef] = useBackgroundQuery(query);
468
+ *
469
+ * return (
470
+ * <Suspense fallback={<SuspenseFallback />}>
471
+ * <Child queryRef={queryRef} />
472
+ * </Suspense>
473
+ * );
474
+ * }
475
+ *
476
+ * function App() {
477
+ * return (
478
+ * <ApolloProvider client={client}>
479
+ * <Parent />
480
+ * </ApolloProvider>
481
+ * );
482
+ * }
483
+ * ```
484
+ *
485
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
486
+ * @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.
487
+ */
488
+ <
489
+ TData,
490
+ TVariables extends OperationVariables,
491
+ _INFERENCE_ONLY_DO_NOT_SPECIFY extends 'inferred',
492
+ >(
493
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
494
+ options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
495
+ /** @deprecated `returnPartialData` has no effect on `no-cache` queries */
496
+ returnPartialData: boolean;
497
+ fetchPolicy: 'no-cache';
498
+ },
499
+ ): [
500
+ QueryRef<TData, TVariables, 'complete' | 'streaming'>,
501
+ useBackgroundQuery.Result<TData, TVariables>,
502
+ ];
503
+ /**
504
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
505
+ *
506
+ * @returns A tuple containing:
507
+ *
508
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
509
+ * 2. An object containing helper functions for the query:
510
+ * - `refetch`: A function to re-execute the query
511
+ * - `fetchMore`: A function to fetch more results for pagination
512
+ * - `subscribeToMore`: A function to subscribe to updates
513
+ *
514
+ * @example
515
+ *
516
+ * ```jsx
517
+ * import { Suspense } from "octane";
518
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
519
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
520
+ *
521
+ * const query = gql`
522
+ * foo {
523
+ * bar
524
+ * }
525
+ * `;
526
+ *
527
+ * const client = new ApolloClient({
528
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
529
+ * cache: new InMemoryCache(),
530
+ * });
531
+ *
532
+ * function SuspenseFallback() {
533
+ * return <div>Loading...</div>;
534
+ * }
535
+ *
536
+ * function Child({ queryRef }) {
537
+ * const { data } = useReadQuery(queryRef);
538
+ *
539
+ * return <div>{data.foo.bar}</div>;
540
+ * }
541
+ *
542
+ * function Parent() {
543
+ * const [queryRef] = useBackgroundQuery(query);
544
+ *
545
+ * return (
546
+ * <Suspense fallback={<SuspenseFallback />}>
547
+ * <Child queryRef={queryRef} />
548
+ * </Suspense>
549
+ * );
550
+ * }
551
+ *
552
+ * function App() {
553
+ * return (
554
+ * <ApolloProvider client={client}>
555
+ * <Parent />
556
+ * </ApolloProvider>
557
+ * );
558
+ * }
559
+ * ```
560
+ *
561
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
562
+ * @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.
563
+ */
564
+ <
565
+ TData,
566
+ TVariables extends OperationVariables,
567
+ _INFERENCE_ONLY_DO_NOT_SPECIFY extends 'inferred',
568
+ >(
569
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
570
+ options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
571
+ returnPartialData: false;
572
+ errorPolicy: 'ignore' | 'all';
573
+ },
574
+ ): [
575
+ QueryRef<TData, TVariables, 'complete' | 'streaming' | 'empty'>,
576
+ useBackgroundQuery.Result<TData, TVariables>,
577
+ ];
578
+ /**
579
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
580
+ *
581
+ * @returns A tuple containing:
582
+ *
583
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
584
+ * 2. An object containing helper functions for the query:
585
+ * - `refetch`: A function to re-execute the query
586
+ * - `fetchMore`: A function to fetch more results for pagination
587
+ * - `subscribeToMore`: A function to subscribe to updates
588
+ *
589
+ * @example
590
+ *
591
+ * ```jsx
592
+ * import { Suspense } from "octane";
593
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
594
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
595
+ *
596
+ * const query = gql`
597
+ * foo {
598
+ * bar
599
+ * }
600
+ * `;
601
+ *
602
+ * const client = new ApolloClient({
603
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
604
+ * cache: new InMemoryCache(),
605
+ * });
606
+ *
607
+ * function SuspenseFallback() {
608
+ * return <div>Loading...</div>;
609
+ * }
610
+ *
611
+ * function Child({ queryRef }) {
612
+ * const { data } = useReadQuery(queryRef);
613
+ *
614
+ * return <div>{data.foo.bar}</div>;
615
+ * }
616
+ *
617
+ * function Parent() {
618
+ * const [queryRef] = useBackgroundQuery(query);
619
+ *
620
+ * return (
621
+ * <Suspense fallback={<SuspenseFallback />}>
622
+ * <Child queryRef={queryRef} />
623
+ * </Suspense>
624
+ * );
625
+ * }
626
+ *
627
+ * function App() {
628
+ * return (
629
+ * <ApolloProvider client={client}>
630
+ * <Parent />
631
+ * </ApolloProvider>
632
+ * );
633
+ * }
634
+ * ```
635
+ *
636
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
637
+ * @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.
638
+ */
639
+ <
640
+ TData,
641
+ TVariables extends OperationVariables,
642
+ _INFERENCE_ONLY_DO_NOT_SPECIFY extends 'inferred',
643
+ >(
644
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
645
+ options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
646
+ returnPartialData: boolean;
647
+ errorPolicy: 'ignore' | 'all';
648
+ },
649
+ ): [
650
+ QueryRef<TData, TVariables, 'complete' | 'streaming' | 'partial' | 'empty'>,
651
+ useBackgroundQuery.Result<TData, TVariables>,
652
+ ];
653
+ /**
654
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
655
+ *
656
+ * @returns A tuple containing:
657
+ *
658
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
659
+ * 2. An object containing helper functions for the query:
660
+ * - `refetch`: A function to re-execute the query
661
+ * - `fetchMore`: A function to fetch more results for pagination
662
+ * - `subscribeToMore`: A function to subscribe to updates
663
+ *
664
+ * @example
665
+ *
666
+ * ```jsx
667
+ * import { Suspense } from "octane";
668
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
669
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
670
+ *
671
+ * const query = gql`
672
+ * foo {
673
+ * bar
674
+ * }
675
+ * `;
676
+ *
677
+ * const client = new ApolloClient({
678
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
679
+ * cache: new InMemoryCache(),
680
+ * });
681
+ *
682
+ * function SuspenseFallback() {
683
+ * return <div>Loading...</div>;
684
+ * }
685
+ *
686
+ * function Child({ queryRef }) {
687
+ * const { data } = useReadQuery(queryRef);
688
+ *
689
+ * return <div>{data.foo.bar}</div>;
690
+ * }
691
+ *
692
+ * function Parent() {
693
+ * const [queryRef] = useBackgroundQuery(query);
694
+ *
695
+ * return (
696
+ * <Suspense fallback={<SuspenseFallback />}>
697
+ * <Child queryRef={queryRef} />
698
+ * </Suspense>
699
+ * );
700
+ * }
701
+ *
702
+ * function App() {
703
+ * return (
704
+ * <ApolloProvider client={client}>
705
+ * <Parent />
706
+ * </ApolloProvider>
707
+ * );
708
+ * }
709
+ * ```
710
+ *
711
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
712
+ * @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.
713
+ */
714
+ <
715
+ TData,
716
+ TVariables extends OperationVariables,
717
+ _INFERENCE_ONLY_DO_NOT_SPECIFY extends 'inferred',
718
+ >(
719
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
720
+ options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
721
+ errorPolicy: 'ignore' | 'all';
722
+ },
723
+ ): [
724
+ QueryRef<TData, TVariables, 'complete' | 'streaming' | 'empty'>,
725
+ useBackgroundQuery.Result<TData, TVariables>,
726
+ ];
727
+ /**
728
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
729
+ *
730
+ * @returns A tuple containing:
731
+ *
732
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
733
+ * 2. An object containing helper functions for the query:
734
+ * - `refetch`: A function to re-execute the query
735
+ * - `fetchMore`: A function to fetch more results for pagination
736
+ * - `subscribeToMore`: A function to subscribe to updates
737
+ *
738
+ * @example
739
+ *
740
+ * ```jsx
741
+ * import { Suspense } from "octane";
742
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
743
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
744
+ *
745
+ * const query = gql`
746
+ * foo {
747
+ * bar
748
+ * }
749
+ * `;
750
+ *
751
+ * const client = new ApolloClient({
752
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
753
+ * cache: new InMemoryCache(),
754
+ * });
755
+ *
756
+ * function SuspenseFallback() {
757
+ * return <div>Loading...</div>;
758
+ * }
759
+ *
760
+ * function Child({ queryRef }) {
761
+ * const { data } = useReadQuery(queryRef);
762
+ *
763
+ * return <div>{data.foo.bar}</div>;
764
+ * }
765
+ *
766
+ * function Parent() {
767
+ * const [queryRef] = useBackgroundQuery(query);
768
+ *
769
+ * return (
770
+ * <Suspense fallback={<SuspenseFallback />}>
771
+ * <Child queryRef={queryRef} />
772
+ * </Suspense>
773
+ * );
774
+ * }
775
+ *
776
+ * function App() {
777
+ * return (
778
+ * <ApolloProvider client={client}>
779
+ * <Parent />
780
+ * </ApolloProvider>
781
+ * );
782
+ * }
783
+ * ```
784
+ *
785
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
786
+ * @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.
787
+ */
788
+ <
789
+ TData,
790
+ TVariables extends OperationVariables,
791
+ _INFERENCE_ONLY_DO_NOT_SPECIFY extends 'inferred',
792
+ >(
793
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
794
+ options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
795
+ skip: boolean;
796
+ returnPartialData: false;
797
+ },
798
+ ): [
799
+ QueryRef<TData, TVariables, 'complete' | 'streaming'> | undefined,
800
+ useBackgroundQuery.Result<TData, TVariables>,
801
+ ];
802
+ /**
803
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
804
+ *
805
+ * @returns A tuple containing:
806
+ *
807
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
808
+ * 2. An object containing helper functions for the query:
809
+ * - `refetch`: A function to re-execute the query
810
+ * - `fetchMore`: A function to fetch more results for pagination
811
+ * - `subscribeToMore`: A function to subscribe to updates
812
+ *
813
+ * @example
814
+ *
815
+ * ```jsx
816
+ * import { Suspense } from "octane";
817
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
818
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
819
+ *
820
+ * const query = gql`
821
+ * foo {
822
+ * bar
823
+ * }
824
+ * `;
825
+ *
826
+ * const client = new ApolloClient({
827
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
828
+ * cache: new InMemoryCache(),
829
+ * });
830
+ *
831
+ * function SuspenseFallback() {
832
+ * return <div>Loading...</div>;
833
+ * }
834
+ *
835
+ * function Child({ queryRef }) {
836
+ * const { data } = useReadQuery(queryRef);
837
+ *
838
+ * return <div>{data.foo.bar}</div>;
839
+ * }
840
+ *
841
+ * function Parent() {
842
+ * const [queryRef] = useBackgroundQuery(query);
843
+ *
844
+ * return (
845
+ * <Suspense fallback={<SuspenseFallback />}>
846
+ * <Child queryRef={queryRef} />
847
+ * </Suspense>
848
+ * );
849
+ * }
850
+ *
851
+ * function App() {
852
+ * return (
853
+ * <ApolloProvider client={client}>
854
+ * <Parent />
855
+ * </ApolloProvider>
856
+ * );
857
+ * }
858
+ * ```
859
+ *
860
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
861
+ * @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.
862
+ */
863
+ <
864
+ TData,
865
+ TVariables extends OperationVariables,
866
+ _INFERENCE_ONLY_DO_NOT_SPECIFY extends 'inferred',
867
+ >(
868
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
869
+ options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
870
+ skip: boolean;
871
+ returnPartialData: boolean;
872
+ },
873
+ ): [
874
+ QueryRef<TData, TVariables, 'complete' | 'streaming' | 'partial'> | undefined,
875
+ useBackgroundQuery.Result<TData, TVariables>,
876
+ ];
877
+ /**
878
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
879
+ *
880
+ * @returns A tuple containing:
881
+ *
882
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
883
+ * 2. An object containing helper functions for the query:
884
+ * - `refetch`: A function to re-execute the query
885
+ * - `fetchMore`: A function to fetch more results for pagination
886
+ * - `subscribeToMore`: A function to subscribe to updates
887
+ *
888
+ * @example
889
+ *
890
+ * ```jsx
891
+ * import { Suspense } from "octane";
892
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
893
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
894
+ *
895
+ * const query = gql`
896
+ * foo {
897
+ * bar
898
+ * }
899
+ * `;
900
+ *
901
+ * const client = new ApolloClient({
902
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
903
+ * cache: new InMemoryCache(),
904
+ * });
905
+ *
906
+ * function SuspenseFallback() {
907
+ * return <div>Loading...</div>;
908
+ * }
909
+ *
910
+ * function Child({ queryRef }) {
911
+ * const { data } = useReadQuery(queryRef);
912
+ *
913
+ * return <div>{data.foo.bar}</div>;
914
+ * }
915
+ *
916
+ * function Parent() {
917
+ * const [queryRef] = useBackgroundQuery(query);
918
+ *
919
+ * return (
920
+ * <Suspense fallback={<SuspenseFallback />}>
921
+ * <Child queryRef={queryRef} />
922
+ * </Suspense>
923
+ * );
924
+ * }
925
+ *
926
+ * function App() {
927
+ * return (
928
+ * <ApolloProvider client={client}>
929
+ * <Parent />
930
+ * </ApolloProvider>
931
+ * );
932
+ * }
933
+ * ```
934
+ *
935
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
936
+ * @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.
937
+ */
938
+ <
939
+ TData,
940
+ TVariables extends OperationVariables,
941
+ _INFERENCE_ONLY_DO_NOT_SPECIFY extends 'inferred',
942
+ >(
943
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
944
+ options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
945
+ returnPartialData: false;
946
+ },
947
+ ): [
948
+ QueryRef<TData, TVariables, 'complete' | 'streaming'>,
949
+ useBackgroundQuery.Result<TData, TVariables>,
950
+ ];
951
+ /**
952
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
953
+ *
954
+ * @returns A tuple containing:
955
+ *
956
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
957
+ * 2. An object containing helper functions for the query:
958
+ * - `refetch`: A function to re-execute the query
959
+ * - `fetchMore`: A function to fetch more results for pagination
960
+ * - `subscribeToMore`: A function to subscribe to updates
961
+ *
962
+ * @example
963
+ *
964
+ * ```jsx
965
+ * import { Suspense } from "octane";
966
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
967
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
968
+ *
969
+ * const query = gql`
970
+ * foo {
971
+ * bar
972
+ * }
973
+ * `;
974
+ *
975
+ * const client = new ApolloClient({
976
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
977
+ * cache: new InMemoryCache(),
978
+ * });
979
+ *
980
+ * function SuspenseFallback() {
981
+ * return <div>Loading...</div>;
982
+ * }
983
+ *
984
+ * function Child({ queryRef }) {
985
+ * const { data } = useReadQuery(queryRef);
986
+ *
987
+ * return <div>{data.foo.bar}</div>;
988
+ * }
989
+ *
990
+ * function Parent() {
991
+ * const [queryRef] = useBackgroundQuery(query);
992
+ *
993
+ * return (
994
+ * <Suspense fallback={<SuspenseFallback />}>
995
+ * <Child queryRef={queryRef} />
996
+ * </Suspense>
997
+ * );
998
+ * }
999
+ *
1000
+ * function App() {
1001
+ * return (
1002
+ * <ApolloProvider client={client}>
1003
+ * <Parent />
1004
+ * </ApolloProvider>
1005
+ * );
1006
+ * }
1007
+ * ```
1008
+ *
1009
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
1010
+ * @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.
1011
+ */
1012
+ <
1013
+ TData,
1014
+ TVariables extends OperationVariables,
1015
+ _INFERENCE_ONLY_DO_NOT_SPECIFY extends 'inferred',
1016
+ >(
1017
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
1018
+ options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
1019
+ returnPartialData: boolean;
1020
+ },
1021
+ ): [
1022
+ QueryRef<TData, TVariables, 'complete' | 'streaming' | 'partial'>,
1023
+ useBackgroundQuery.Result<TData, TVariables>,
1024
+ ];
1025
+ /**
1026
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
1027
+ *
1028
+ * @returns A tuple containing:
1029
+ *
1030
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
1031
+ * 2. An object containing helper functions for the query:
1032
+ * - `refetch`: A function to re-execute the query
1033
+ * - `fetchMore`: A function to fetch more results for pagination
1034
+ * - `subscribeToMore`: A function to subscribe to updates
1035
+ *
1036
+ * @example
1037
+ *
1038
+ * ```jsx
1039
+ * import { Suspense } from "octane";
1040
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
1041
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
1042
+ *
1043
+ * const query = gql`
1044
+ * foo {
1045
+ * bar
1046
+ * }
1047
+ * `;
1048
+ *
1049
+ * const client = new ApolloClient({
1050
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
1051
+ * cache: new InMemoryCache(),
1052
+ * });
1053
+ *
1054
+ * function SuspenseFallback() {
1055
+ * return <div>Loading...</div>;
1056
+ * }
1057
+ *
1058
+ * function Child({ queryRef }) {
1059
+ * const { data } = useReadQuery(queryRef);
1060
+ *
1061
+ * return <div>{data.foo.bar}</div>;
1062
+ * }
1063
+ *
1064
+ * function Parent() {
1065
+ * const [queryRef] = useBackgroundQuery(query);
1066
+ *
1067
+ * return (
1068
+ * <Suspense fallback={<SuspenseFallback />}>
1069
+ * <Child queryRef={queryRef} />
1070
+ * </Suspense>
1071
+ * );
1072
+ * }
1073
+ *
1074
+ * function App() {
1075
+ * return (
1076
+ * <ApolloProvider client={client}>
1077
+ * <Parent />
1078
+ * </ApolloProvider>
1079
+ * );
1080
+ * }
1081
+ * ```
1082
+ *
1083
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
1084
+ * @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.
1085
+ */
1086
+ <
1087
+ TData,
1088
+ TVariables extends OperationVariables,
1089
+ _INFERENCE_ONLY_DO_NOT_SPECIFY extends 'inferred',
1090
+ >(
1091
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
1092
+ options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
1093
+ skip: boolean;
1094
+ },
1095
+ ): [
1096
+ QueryRef<TData, TVariables, 'complete' | 'streaming'> | undefined,
1097
+ useBackgroundQuery.Result<TData, TVariables>,
1098
+ ];
1099
+ /**
1100
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
1101
+ *
1102
+ * @returns A tuple containing:
1103
+ *
1104
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
1105
+ * 2. An object containing helper functions for the query:
1106
+ * - `refetch`: A function to re-execute the query
1107
+ * - `fetchMore`: A function to fetch more results for pagination
1108
+ * - `subscribeToMore`: A function to subscribe to updates
1109
+ *
1110
+ * @example
1111
+ *
1112
+ * ```jsx
1113
+ * import { Suspense } from "octane";
1114
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
1115
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
1116
+ *
1117
+ * const query = gql`
1118
+ * foo {
1119
+ * bar
1120
+ * }
1121
+ * `;
1122
+ *
1123
+ * const client = new ApolloClient({
1124
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
1125
+ * cache: new InMemoryCache(),
1126
+ * });
1127
+ *
1128
+ * function SuspenseFallback() {
1129
+ * return <div>Loading...</div>;
1130
+ * }
1131
+ *
1132
+ * function Child({ queryRef }) {
1133
+ * const { data } = useReadQuery(queryRef);
1134
+ *
1135
+ * return <div>{data.foo.bar}</div>;
1136
+ * }
1137
+ *
1138
+ * function Parent() {
1139
+ * const [queryRef] = useBackgroundQuery(query);
1140
+ *
1141
+ * return (
1142
+ * <Suspense fallback={<SuspenseFallback />}>
1143
+ * <Child queryRef={queryRef} />
1144
+ * </Suspense>
1145
+ * );
1146
+ * }
1147
+ *
1148
+ * function App() {
1149
+ * return (
1150
+ * <ApolloProvider client={client}>
1151
+ * <Parent />
1152
+ * </ApolloProvider>
1153
+ * );
1154
+ * }
1155
+ * ```
1156
+ *
1157
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
1158
+ * @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.
1159
+ */
1160
+ <
1161
+ TData,
1162
+ TVariables extends OperationVariables,
1163
+ _INFERENCE_ONLY_DO_NOT_SPECIFY extends 'inferred',
1164
+ >(
1165
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
1166
+ options: SkipToken,
1167
+ ): [undefined, useBackgroundQuery.Result<TData, TVariables>];
1168
+ /**
1169
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
1170
+ *
1171
+ * @returns A tuple containing:
1172
+ *
1173
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
1174
+ * 2. An object containing helper functions for the query:
1175
+ * - `refetch`: A function to re-execute the query
1176
+ * - `fetchMore`: A function to fetch more results for pagination
1177
+ * - `subscribeToMore`: A function to subscribe to updates
1178
+ *
1179
+ * @example
1180
+ *
1181
+ * ```jsx
1182
+ * import { Suspense } from "octane";
1183
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
1184
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
1185
+ *
1186
+ * const query = gql`
1187
+ * foo {
1188
+ * bar
1189
+ * }
1190
+ * `;
1191
+ *
1192
+ * const client = new ApolloClient({
1193
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
1194
+ * cache: new InMemoryCache(),
1195
+ * });
1196
+ *
1197
+ * function SuspenseFallback() {
1198
+ * return <div>Loading...</div>;
1199
+ * }
1200
+ *
1201
+ * function Child({ queryRef }) {
1202
+ * const { data } = useReadQuery(queryRef);
1203
+ *
1204
+ * return <div>{data.foo.bar}</div>;
1205
+ * }
1206
+ *
1207
+ * function Parent() {
1208
+ * const [queryRef] = useBackgroundQuery(query);
1209
+ *
1210
+ * return (
1211
+ * <Suspense fallback={<SuspenseFallback />}>
1212
+ * <Child queryRef={queryRef} />
1213
+ * </Suspense>
1214
+ * );
1215
+ * }
1216
+ *
1217
+ * function App() {
1218
+ * return (
1219
+ * <ApolloProvider client={client}>
1220
+ * <Parent />
1221
+ * </ApolloProvider>
1222
+ * );
1223
+ * }
1224
+ * ```
1225
+ *
1226
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
1227
+ * @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.
1228
+ */
1229
+ <
1230
+ TData,
1231
+ TVariables extends OperationVariables,
1232
+ _INFERENCE_ONLY_DO_NOT_SPECIFY extends 'inferred',
1233
+ >(
1234
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
1235
+ options:
1236
+ | SkipToken
1237
+ | (useBackgroundQuery.Options<NoInfer<TVariables>> & {
1238
+ returnPartialData: false;
1239
+ }),
1240
+ ): [
1241
+ QueryRef<TData, TVariables, 'complete' | 'streaming'> | undefined,
1242
+ useBackgroundQuery.Result<TData, TVariables>,
1243
+ ];
1244
+ /**
1245
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
1246
+ *
1247
+ * @returns A tuple containing:
1248
+ *
1249
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
1250
+ * 2. An object containing helper functions for the query:
1251
+ * - `refetch`: A function to re-execute the query
1252
+ * - `fetchMore`: A function to fetch more results for pagination
1253
+ * - `subscribeToMore`: A function to subscribe to updates
1254
+ *
1255
+ * @example
1256
+ *
1257
+ * ```jsx
1258
+ * import { Suspense } from "octane";
1259
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
1260
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
1261
+ *
1262
+ * const query = gql`
1263
+ * foo {
1264
+ * bar
1265
+ * }
1266
+ * `;
1267
+ *
1268
+ * const client = new ApolloClient({
1269
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
1270
+ * cache: new InMemoryCache(),
1271
+ * });
1272
+ *
1273
+ * function SuspenseFallback() {
1274
+ * return <div>Loading...</div>;
1275
+ * }
1276
+ *
1277
+ * function Child({ queryRef }) {
1278
+ * const { data } = useReadQuery(queryRef);
1279
+ *
1280
+ * return <div>{data.foo.bar}</div>;
1281
+ * }
1282
+ *
1283
+ * function Parent() {
1284
+ * const [queryRef] = useBackgroundQuery(query);
1285
+ *
1286
+ * return (
1287
+ * <Suspense fallback={<SuspenseFallback />}>
1288
+ * <Child queryRef={queryRef} />
1289
+ * </Suspense>
1290
+ * );
1291
+ * }
1292
+ *
1293
+ * function App() {
1294
+ * return (
1295
+ * <ApolloProvider client={client}>
1296
+ * <Parent />
1297
+ * </ApolloProvider>
1298
+ * );
1299
+ * }
1300
+ * ```
1301
+ *
1302
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
1303
+ * @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.
1304
+ */
1305
+ <
1306
+ TData,
1307
+ TVariables extends OperationVariables,
1308
+ _INFERENCE_ONLY_DO_NOT_SPECIFY extends 'inferred',
1309
+ >(
1310
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
1311
+ options:
1312
+ | SkipToken
1313
+ | (useBackgroundQuery.Options<NoInfer<TVariables>> & {
1314
+ returnPartialData: boolean;
1315
+ }),
1316
+ ): [
1317
+ QueryRef<TData, TVariables, 'complete' | 'streaming' | 'partial'> | undefined,
1318
+ useBackgroundQuery.Result<TData, TVariables>,
1319
+ ];
1320
+ /**
1321
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
1322
+ *
1323
+ * @returns A tuple containing:
1324
+ *
1325
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
1326
+ * 2. An object containing helper functions for the query:
1327
+ * - `refetch`: A function to re-execute the query
1328
+ * - `fetchMore`: A function to fetch more results for pagination
1329
+ * - `subscribeToMore`: A function to subscribe to updates
1330
+ *
1331
+ * @example
1332
+ *
1333
+ * ```jsx
1334
+ * import { Suspense } from "octane";
1335
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
1336
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
1337
+ *
1338
+ * const query = gql`
1339
+ * foo {
1340
+ * bar
1341
+ * }
1342
+ * `;
1343
+ *
1344
+ * const client = new ApolloClient({
1345
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
1346
+ * cache: new InMemoryCache(),
1347
+ * });
1348
+ *
1349
+ * function SuspenseFallback() {
1350
+ * return <div>Loading...</div>;
1351
+ * }
1352
+ *
1353
+ * function Child({ queryRef }) {
1354
+ * const { data } = useReadQuery(queryRef);
1355
+ *
1356
+ * return <div>{data.foo.bar}</div>;
1357
+ * }
1358
+ *
1359
+ * function Parent() {
1360
+ * const [queryRef] = useBackgroundQuery(query);
1361
+ *
1362
+ * return (
1363
+ * <Suspense fallback={<SuspenseFallback />}>
1364
+ * <Child queryRef={queryRef} />
1365
+ * </Suspense>
1366
+ * );
1367
+ * }
1368
+ *
1369
+ * function App() {
1370
+ * return (
1371
+ * <ApolloProvider client={client}>
1372
+ * <Parent />
1373
+ * </ApolloProvider>
1374
+ * );
1375
+ * }
1376
+ * ```
1377
+ *
1378
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
1379
+ * @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.
1380
+ */
1381
+ <
1382
+ TData,
1383
+ TVariables extends OperationVariables,
1384
+ _INFERENCE_ONLY_DO_NOT_SPECIFY extends 'inferred',
1385
+ >(
1386
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
1387
+ ...[options]: {} extends TVariables
1388
+ ? [options?: useBackgroundQuery.Options<NoInfer<TVariables>>]
1389
+ : [options: useBackgroundQuery.Options<NoInfer<TVariables>>]
1390
+ ): [
1391
+ QueryRef<TData, TVariables, 'complete' | 'streaming'>,
1392
+ useBackgroundQuery.Result<TData, TVariables>,
1393
+ ];
1394
+ /**
1395
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
1396
+ *
1397
+ * @returns A tuple containing:
1398
+ *
1399
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
1400
+ * 2. An object containing helper functions for the query:
1401
+ * - `refetch`: A function to re-execute the query
1402
+ * - `fetchMore`: A function to fetch more results for pagination
1403
+ * - `subscribeToMore`: A function to subscribe to updates
1404
+ *
1405
+ * @example
1406
+ *
1407
+ * ```jsx
1408
+ * import { Suspense } from "octane";
1409
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
1410
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
1411
+ *
1412
+ * const query = gql`
1413
+ * foo {
1414
+ * bar
1415
+ * }
1416
+ * `;
1417
+ *
1418
+ * const client = new ApolloClient({
1419
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
1420
+ * cache: new InMemoryCache(),
1421
+ * });
1422
+ *
1423
+ * function SuspenseFallback() {
1424
+ * return <div>Loading...</div>;
1425
+ * }
1426
+ *
1427
+ * function Child({ queryRef }) {
1428
+ * const { data } = useReadQuery(queryRef);
1429
+ *
1430
+ * return <div>{data.foo.bar}</div>;
1431
+ * }
1432
+ *
1433
+ * function Parent() {
1434
+ * const [queryRef] = useBackgroundQuery(query);
1435
+ *
1436
+ * return (
1437
+ * <Suspense fallback={<SuspenseFallback />}>
1438
+ * <Child queryRef={queryRef} />
1439
+ * </Suspense>
1440
+ * );
1441
+ * }
1442
+ *
1443
+ * function App() {
1444
+ * return (
1445
+ * <ApolloProvider client={client}>
1446
+ * <Parent />
1447
+ * </ApolloProvider>
1448
+ * );
1449
+ * }
1450
+ * ```
1451
+ *
1452
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
1453
+ * @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.
1454
+ */
1455
+ <
1456
+ TData,
1457
+ TVariables extends OperationVariables,
1458
+ _INFERENCE_ONLY_DO_NOT_SPECIFY extends 'inferred',
1459
+ >(
1460
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
1461
+ ...[options]: {} extends TVariables
1462
+ ? [options?: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>]
1463
+ : [options: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>]
1464
+ ): [
1465
+ QueryRef<TData, TVariables, 'complete' | 'streaming'> | undefined,
1466
+ useBackgroundQuery.Result<TData, TVariables>,
1467
+ ];
1468
+ /**
1469
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
1470
+ *
1471
+ * @returns A tuple containing:
1472
+ *
1473
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
1474
+ * 2. An object containing helper functions for the query:
1475
+ * - `refetch`: A function to re-execute the query
1476
+ * - `fetchMore`: A function to fetch more results for pagination
1477
+ * - `subscribeToMore`: A function to subscribe to updates
1478
+ *
1479
+ * @example
1480
+ *
1481
+ * ```jsx
1482
+ * import { Suspense } from "octane";
1483
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
1484
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
1485
+ *
1486
+ * const query = gql`
1487
+ * foo {
1488
+ * bar
1489
+ * }
1490
+ * `;
1491
+ *
1492
+ * const client = new ApolloClient({
1493
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
1494
+ * cache: new InMemoryCache(),
1495
+ * });
1496
+ *
1497
+ * function SuspenseFallback() {
1498
+ * return <div>Loading...</div>;
1499
+ * }
1500
+ *
1501
+ * function Child({ queryRef }) {
1502
+ * const { data } = useReadQuery(queryRef);
1503
+ *
1504
+ * return <div>{data.foo.bar}</div>;
1505
+ * }
1506
+ *
1507
+ * function Parent() {
1508
+ * const [queryRef] = useBackgroundQuery(query);
1509
+ *
1510
+ * return (
1511
+ * <Suspense fallback={<SuspenseFallback />}>
1512
+ * <Child queryRef={queryRef} />
1513
+ * </Suspense>
1514
+ * );
1515
+ * }
1516
+ *
1517
+ * function App() {
1518
+ * return (
1519
+ * <ApolloProvider client={client}>
1520
+ * <Parent />
1521
+ * </ApolloProvider>
1522
+ * );
1523
+ * }
1524
+ * ```
1525
+ *
1526
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
1527
+ * @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.
1528
+ */
1529
+ <
1530
+ TData,
1531
+ TVariables extends OperationVariables,
1532
+ _INFERENCE_ONLY_DO_NOT_SPECIFY extends 'inferred',
1533
+ >(
1534
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
1535
+ options: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>,
1536
+ ): [
1537
+ QueryRef<TData, TVariables, 'complete' | 'streaming'> | undefined,
1538
+ useBackgroundQuery.Result<TData, TVariables>,
1539
+ ];
1540
+ /**
1541
+ * @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
1542
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
1543
+ *
1544
+ *
1545
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
1546
+ *
1547
+ * @returns A tuple containing:
1548
+ *
1549
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
1550
+ * 2. An object containing helper functions for the query:
1551
+ * - `refetch`: A function to re-execute the query
1552
+ * - `fetchMore`: A function to fetch more results for pagination
1553
+ * - `subscribeToMore`: A function to subscribe to updates
1554
+ *
1555
+ * @example
1556
+ *
1557
+ * ```jsx
1558
+ * import { Suspense } from "octane";
1559
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
1560
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
1561
+ *
1562
+ * const query = gql`
1563
+ * foo {
1564
+ * bar
1565
+ * }
1566
+ * `;
1567
+ *
1568
+ * const client = new ApolloClient({
1569
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
1570
+ * cache: new InMemoryCache(),
1571
+ * });
1572
+ *
1573
+ * function SuspenseFallback() {
1574
+ * return <div>Loading...</div>;
1575
+ * }
1576
+ *
1577
+ * function Child({ queryRef }) {
1578
+ * const { data } = useReadQuery(queryRef);
1579
+ *
1580
+ * return <div>{data.foo.bar}</div>;
1581
+ * }
1582
+ *
1583
+ * function Parent() {
1584
+ * const [queryRef] = useBackgroundQuery(query);
1585
+ *
1586
+ * return (
1587
+ * <Suspense fallback={<SuspenseFallback />}>
1588
+ * <Child queryRef={queryRef} />
1589
+ * </Suspense>
1590
+ * );
1591
+ * }
1592
+ *
1593
+ * function App() {
1594
+ * return (
1595
+ * <ApolloProvider client={client}>
1596
+ * <Parent />
1597
+ * </ApolloProvider>
1598
+ * );
1599
+ * }
1600
+ * ```
1601
+ *
1602
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
1603
+ * @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.
1604
+ */
1605
+ <TData, TVariables extends OperationVariables = OperationVariables>(
1606
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
1607
+ options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
1608
+ /** @deprecated `returnPartialData` has no effect on `no-cache` queries */
1609
+ returnPartialData: boolean;
1610
+ fetchPolicy: 'no-cache';
1611
+ },
1612
+ ): [
1613
+ QueryRef<TData, TVariables, 'complete' | 'streaming'>,
1614
+ useBackgroundQuery.Result<TData, TVariables>,
1615
+ ];
1616
+ /**
1617
+ * @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
1618
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
1619
+ *
1620
+ *
1621
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
1622
+ *
1623
+ * @returns A tuple containing:
1624
+ *
1625
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
1626
+ * 2. An object containing helper functions for the query:
1627
+ * - `refetch`: A function to re-execute the query
1628
+ * - `fetchMore`: A function to fetch more results for pagination
1629
+ * - `subscribeToMore`: A function to subscribe to updates
1630
+ *
1631
+ * @example
1632
+ *
1633
+ * ```jsx
1634
+ * import { Suspense } from "octane";
1635
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
1636
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
1637
+ *
1638
+ * const query = gql`
1639
+ * foo {
1640
+ * bar
1641
+ * }
1642
+ * `;
1643
+ *
1644
+ * const client = new ApolloClient({
1645
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
1646
+ * cache: new InMemoryCache(),
1647
+ * });
1648
+ *
1649
+ * function SuspenseFallback() {
1650
+ * return <div>Loading...</div>;
1651
+ * }
1652
+ *
1653
+ * function Child({ queryRef }) {
1654
+ * const { data } = useReadQuery(queryRef);
1655
+ *
1656
+ * return <div>{data.foo.bar}</div>;
1657
+ * }
1658
+ *
1659
+ * function Parent() {
1660
+ * const [queryRef] = useBackgroundQuery(query);
1661
+ *
1662
+ * return (
1663
+ * <Suspense fallback={<SuspenseFallback />}>
1664
+ * <Child queryRef={queryRef} />
1665
+ * </Suspense>
1666
+ * );
1667
+ * }
1668
+ *
1669
+ * function App() {
1670
+ * return (
1671
+ * <ApolloProvider client={client}>
1672
+ * <Parent />
1673
+ * </ApolloProvider>
1674
+ * );
1675
+ * }
1676
+ * ```
1677
+ *
1678
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
1679
+ * @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.
1680
+ */
1681
+ <TData, TVariables extends OperationVariables = OperationVariables>(
1682
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
1683
+ options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
1684
+ returnPartialData: false;
1685
+ errorPolicy: 'ignore' | 'all';
1686
+ },
1687
+ ): [
1688
+ QueryRef<TData, TVariables, 'complete' | 'streaming' | 'empty'>,
1689
+ useBackgroundQuery.Result<TData, TVariables>,
1690
+ ];
1691
+ /**
1692
+ * @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
1693
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
1694
+ *
1695
+ *
1696
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
1697
+ *
1698
+ * @returns A tuple containing:
1699
+ *
1700
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
1701
+ * 2. An object containing helper functions for the query:
1702
+ * - `refetch`: A function to re-execute the query
1703
+ * - `fetchMore`: A function to fetch more results for pagination
1704
+ * - `subscribeToMore`: A function to subscribe to updates
1705
+ *
1706
+ * @example
1707
+ *
1708
+ * ```jsx
1709
+ * import { Suspense } from "octane";
1710
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
1711
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
1712
+ *
1713
+ * const query = gql`
1714
+ * foo {
1715
+ * bar
1716
+ * }
1717
+ * `;
1718
+ *
1719
+ * const client = new ApolloClient({
1720
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
1721
+ * cache: new InMemoryCache(),
1722
+ * });
1723
+ *
1724
+ * function SuspenseFallback() {
1725
+ * return <div>Loading...</div>;
1726
+ * }
1727
+ *
1728
+ * function Child({ queryRef }) {
1729
+ * const { data } = useReadQuery(queryRef);
1730
+ *
1731
+ * return <div>{data.foo.bar}</div>;
1732
+ * }
1733
+ *
1734
+ * function Parent() {
1735
+ * const [queryRef] = useBackgroundQuery(query);
1736
+ *
1737
+ * return (
1738
+ * <Suspense fallback={<SuspenseFallback />}>
1739
+ * <Child queryRef={queryRef} />
1740
+ * </Suspense>
1741
+ * );
1742
+ * }
1743
+ *
1744
+ * function App() {
1745
+ * return (
1746
+ * <ApolloProvider client={client}>
1747
+ * <Parent />
1748
+ * </ApolloProvider>
1749
+ * );
1750
+ * }
1751
+ * ```
1752
+ *
1753
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
1754
+ * @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.
1755
+ */
1756
+ <TData, TVariables extends OperationVariables = OperationVariables>(
1757
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
1758
+ options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
1759
+ returnPartialData: boolean;
1760
+ errorPolicy: 'ignore' | 'all';
1761
+ },
1762
+ ): [
1763
+ QueryRef<TData, TVariables, 'complete' | 'streaming' | 'partial' | 'empty'>,
1764
+ useBackgroundQuery.Result<TData, TVariables>,
1765
+ ];
1766
+ /**
1767
+ * @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
1768
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
1769
+ *
1770
+ *
1771
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
1772
+ *
1773
+ * @returns A tuple containing:
1774
+ *
1775
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
1776
+ * 2. An object containing helper functions for the query:
1777
+ * - `refetch`: A function to re-execute the query
1778
+ * - `fetchMore`: A function to fetch more results for pagination
1779
+ * - `subscribeToMore`: A function to subscribe to updates
1780
+ *
1781
+ * @example
1782
+ *
1783
+ * ```jsx
1784
+ * import { Suspense } from "octane";
1785
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
1786
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
1787
+ *
1788
+ * const query = gql`
1789
+ * foo {
1790
+ * bar
1791
+ * }
1792
+ * `;
1793
+ *
1794
+ * const client = new ApolloClient({
1795
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
1796
+ * cache: new InMemoryCache(),
1797
+ * });
1798
+ *
1799
+ * function SuspenseFallback() {
1800
+ * return <div>Loading...</div>;
1801
+ * }
1802
+ *
1803
+ * function Child({ queryRef }) {
1804
+ * const { data } = useReadQuery(queryRef);
1805
+ *
1806
+ * return <div>{data.foo.bar}</div>;
1807
+ * }
1808
+ *
1809
+ * function Parent() {
1810
+ * const [queryRef] = useBackgroundQuery(query);
1811
+ *
1812
+ * return (
1813
+ * <Suspense fallback={<SuspenseFallback />}>
1814
+ * <Child queryRef={queryRef} />
1815
+ * </Suspense>
1816
+ * );
1817
+ * }
1818
+ *
1819
+ * function App() {
1820
+ * return (
1821
+ * <ApolloProvider client={client}>
1822
+ * <Parent />
1823
+ * </ApolloProvider>
1824
+ * );
1825
+ * }
1826
+ * ```
1827
+ *
1828
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
1829
+ * @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.
1830
+ */
1831
+ <TData, TVariables extends OperationVariables = OperationVariables>(
1832
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
1833
+ options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
1834
+ errorPolicy: 'ignore' | 'all';
1835
+ },
1836
+ ): [
1837
+ QueryRef<TData, TVariables, 'complete' | 'streaming' | 'empty'>,
1838
+ useBackgroundQuery.Result<TData, TVariables>,
1839
+ ];
1840
+ /**
1841
+ * @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
1842
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
1843
+ *
1844
+ *
1845
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
1846
+ *
1847
+ * @returns A tuple containing:
1848
+ *
1849
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
1850
+ * 2. An object containing helper functions for the query:
1851
+ * - `refetch`: A function to re-execute the query
1852
+ * - `fetchMore`: A function to fetch more results for pagination
1853
+ * - `subscribeToMore`: A function to subscribe to updates
1854
+ *
1855
+ * @example
1856
+ *
1857
+ * ```jsx
1858
+ * import { Suspense } from "octane";
1859
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
1860
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
1861
+ *
1862
+ * const query = gql`
1863
+ * foo {
1864
+ * bar
1865
+ * }
1866
+ * `;
1867
+ *
1868
+ * const client = new ApolloClient({
1869
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
1870
+ * cache: new InMemoryCache(),
1871
+ * });
1872
+ *
1873
+ * function SuspenseFallback() {
1874
+ * return <div>Loading...</div>;
1875
+ * }
1876
+ *
1877
+ * function Child({ queryRef }) {
1878
+ * const { data } = useReadQuery(queryRef);
1879
+ *
1880
+ * return <div>{data.foo.bar}</div>;
1881
+ * }
1882
+ *
1883
+ * function Parent() {
1884
+ * const [queryRef] = useBackgroundQuery(query);
1885
+ *
1886
+ * return (
1887
+ * <Suspense fallback={<SuspenseFallback />}>
1888
+ * <Child queryRef={queryRef} />
1889
+ * </Suspense>
1890
+ * );
1891
+ * }
1892
+ *
1893
+ * function App() {
1894
+ * return (
1895
+ * <ApolloProvider client={client}>
1896
+ * <Parent />
1897
+ * </ApolloProvider>
1898
+ * );
1899
+ * }
1900
+ * ```
1901
+ *
1902
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
1903
+ * @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.
1904
+ */
1905
+ <TData, TVariables extends OperationVariables = OperationVariables>(
1906
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
1907
+ options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
1908
+ skip: boolean;
1909
+ returnPartialData: false;
1910
+ },
1911
+ ): [
1912
+ QueryRef<TData, TVariables, 'complete' | 'streaming'> | undefined,
1913
+ useBackgroundQuery.Result<TData, TVariables>,
1914
+ ];
1915
+ /**
1916
+ * @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
1917
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
1918
+ *
1919
+ *
1920
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
1921
+ *
1922
+ * @returns A tuple containing:
1923
+ *
1924
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
1925
+ * 2. An object containing helper functions for the query:
1926
+ * - `refetch`: A function to re-execute the query
1927
+ * - `fetchMore`: A function to fetch more results for pagination
1928
+ * - `subscribeToMore`: A function to subscribe to updates
1929
+ *
1930
+ * @example
1931
+ *
1932
+ * ```jsx
1933
+ * import { Suspense } from "octane";
1934
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
1935
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
1936
+ *
1937
+ * const query = gql`
1938
+ * foo {
1939
+ * bar
1940
+ * }
1941
+ * `;
1942
+ *
1943
+ * const client = new ApolloClient({
1944
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
1945
+ * cache: new InMemoryCache(),
1946
+ * });
1947
+ *
1948
+ * function SuspenseFallback() {
1949
+ * return <div>Loading...</div>;
1950
+ * }
1951
+ *
1952
+ * function Child({ queryRef }) {
1953
+ * const { data } = useReadQuery(queryRef);
1954
+ *
1955
+ * return <div>{data.foo.bar}</div>;
1956
+ * }
1957
+ *
1958
+ * function Parent() {
1959
+ * const [queryRef] = useBackgroundQuery(query);
1960
+ *
1961
+ * return (
1962
+ * <Suspense fallback={<SuspenseFallback />}>
1963
+ * <Child queryRef={queryRef} />
1964
+ * </Suspense>
1965
+ * );
1966
+ * }
1967
+ *
1968
+ * function App() {
1969
+ * return (
1970
+ * <ApolloProvider client={client}>
1971
+ * <Parent />
1972
+ * </ApolloProvider>
1973
+ * );
1974
+ * }
1975
+ * ```
1976
+ *
1977
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
1978
+ * @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.
1979
+ */
1980
+ <TData, TVariables extends OperationVariables = OperationVariables>(
1981
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
1982
+ options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
1983
+ skip: boolean;
1984
+ returnPartialData: boolean;
1985
+ },
1986
+ ): [
1987
+ QueryRef<TData, TVariables, 'complete' | 'streaming' | 'partial'> | undefined,
1988
+ useBackgroundQuery.Result<TData, TVariables>,
1989
+ ];
1990
+ /**
1991
+ * @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
1992
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
1993
+ *
1994
+ *
1995
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
1996
+ *
1997
+ * @returns A tuple containing:
1998
+ *
1999
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
2000
+ * 2. An object containing helper functions for the query:
2001
+ * - `refetch`: A function to re-execute the query
2002
+ * - `fetchMore`: A function to fetch more results for pagination
2003
+ * - `subscribeToMore`: A function to subscribe to updates
2004
+ *
2005
+ * @example
2006
+ *
2007
+ * ```jsx
2008
+ * import { Suspense } from "octane";
2009
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
2010
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
2011
+ *
2012
+ * const query = gql`
2013
+ * foo {
2014
+ * bar
2015
+ * }
2016
+ * `;
2017
+ *
2018
+ * const client = new ApolloClient({
2019
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
2020
+ * cache: new InMemoryCache(),
2021
+ * });
2022
+ *
2023
+ * function SuspenseFallback() {
2024
+ * return <div>Loading...</div>;
2025
+ * }
2026
+ *
2027
+ * function Child({ queryRef }) {
2028
+ * const { data } = useReadQuery(queryRef);
2029
+ *
2030
+ * return <div>{data.foo.bar}</div>;
2031
+ * }
2032
+ *
2033
+ * function Parent() {
2034
+ * const [queryRef] = useBackgroundQuery(query);
2035
+ *
2036
+ * return (
2037
+ * <Suspense fallback={<SuspenseFallback />}>
2038
+ * <Child queryRef={queryRef} />
2039
+ * </Suspense>
2040
+ * );
2041
+ * }
2042
+ *
2043
+ * function App() {
2044
+ * return (
2045
+ * <ApolloProvider client={client}>
2046
+ * <Parent />
2047
+ * </ApolloProvider>
2048
+ * );
2049
+ * }
2050
+ * ```
2051
+ *
2052
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
2053
+ * @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.
2054
+ */
2055
+ <TData, TVariables extends OperationVariables = OperationVariables>(
2056
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
2057
+ options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
2058
+ returnPartialData: false;
2059
+ },
2060
+ ): [
2061
+ QueryRef<TData, TVariables, 'complete' | 'streaming'>,
2062
+ useBackgroundQuery.Result<TData, TVariables>,
2063
+ ];
2064
+ /**
2065
+ * @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
2066
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
2067
+ *
2068
+ *
2069
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
2070
+ *
2071
+ * @returns A tuple containing:
2072
+ *
2073
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
2074
+ * 2. An object containing helper functions for the query:
2075
+ * - `refetch`: A function to re-execute the query
2076
+ * - `fetchMore`: A function to fetch more results for pagination
2077
+ * - `subscribeToMore`: A function to subscribe to updates
2078
+ *
2079
+ * @example
2080
+ *
2081
+ * ```jsx
2082
+ * import { Suspense } from "octane";
2083
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
2084
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
2085
+ *
2086
+ * const query = gql`
2087
+ * foo {
2088
+ * bar
2089
+ * }
2090
+ * `;
2091
+ *
2092
+ * const client = new ApolloClient({
2093
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
2094
+ * cache: new InMemoryCache(),
2095
+ * });
2096
+ *
2097
+ * function SuspenseFallback() {
2098
+ * return <div>Loading...</div>;
2099
+ * }
2100
+ *
2101
+ * function Child({ queryRef }) {
2102
+ * const { data } = useReadQuery(queryRef);
2103
+ *
2104
+ * return <div>{data.foo.bar}</div>;
2105
+ * }
2106
+ *
2107
+ * function Parent() {
2108
+ * const [queryRef] = useBackgroundQuery(query);
2109
+ *
2110
+ * return (
2111
+ * <Suspense fallback={<SuspenseFallback />}>
2112
+ * <Child queryRef={queryRef} />
2113
+ * </Suspense>
2114
+ * );
2115
+ * }
2116
+ *
2117
+ * function App() {
2118
+ * return (
2119
+ * <ApolloProvider client={client}>
2120
+ * <Parent />
2121
+ * </ApolloProvider>
2122
+ * );
2123
+ * }
2124
+ * ```
2125
+ *
2126
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
2127
+ * @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.
2128
+ */
2129
+ <TData, TVariables extends OperationVariables = OperationVariables>(
2130
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
2131
+ options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
2132
+ returnPartialData: boolean;
2133
+ },
2134
+ ): [
2135
+ QueryRef<TData, TVariables, 'complete' | 'streaming' | 'partial'>,
2136
+ useBackgroundQuery.Result<TData, TVariables>,
2137
+ ];
2138
+ /**
2139
+ * @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
2140
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
2141
+ *
2142
+ *
2143
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
2144
+ *
2145
+ * @returns A tuple containing:
2146
+ *
2147
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
2148
+ * 2. An object containing helper functions for the query:
2149
+ * - `refetch`: A function to re-execute the query
2150
+ * - `fetchMore`: A function to fetch more results for pagination
2151
+ * - `subscribeToMore`: A function to subscribe to updates
2152
+ *
2153
+ * @example
2154
+ *
2155
+ * ```jsx
2156
+ * import { Suspense } from "octane";
2157
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
2158
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
2159
+ *
2160
+ * const query = gql`
2161
+ * foo {
2162
+ * bar
2163
+ * }
2164
+ * `;
2165
+ *
2166
+ * const client = new ApolloClient({
2167
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
2168
+ * cache: new InMemoryCache(),
2169
+ * });
2170
+ *
2171
+ * function SuspenseFallback() {
2172
+ * return <div>Loading...</div>;
2173
+ * }
2174
+ *
2175
+ * function Child({ queryRef }) {
2176
+ * const { data } = useReadQuery(queryRef);
2177
+ *
2178
+ * return <div>{data.foo.bar}</div>;
2179
+ * }
2180
+ *
2181
+ * function Parent() {
2182
+ * const [queryRef] = useBackgroundQuery(query);
2183
+ *
2184
+ * return (
2185
+ * <Suspense fallback={<SuspenseFallback />}>
2186
+ * <Child queryRef={queryRef} />
2187
+ * </Suspense>
2188
+ * );
2189
+ * }
2190
+ *
2191
+ * function App() {
2192
+ * return (
2193
+ * <ApolloProvider client={client}>
2194
+ * <Parent />
2195
+ * </ApolloProvider>
2196
+ * );
2197
+ * }
2198
+ * ```
2199
+ *
2200
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
2201
+ * @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.
2202
+ */
2203
+ <TData, TVariables extends OperationVariables = OperationVariables>(
2204
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
2205
+ options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
2206
+ skip: boolean;
2207
+ },
2208
+ ): [
2209
+ QueryRef<TData, TVariables, 'complete' | 'streaming'> | undefined,
2210
+ useBackgroundQuery.Result<TData, TVariables>,
2211
+ ];
2212
+ /**
2213
+ * @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
2214
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
2215
+ *
2216
+ *
2217
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
2218
+ *
2219
+ * @returns A tuple containing:
2220
+ *
2221
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
2222
+ * 2. An object containing helper functions for the query:
2223
+ * - `refetch`: A function to re-execute the query
2224
+ * - `fetchMore`: A function to fetch more results for pagination
2225
+ * - `subscribeToMore`: A function to subscribe to updates
2226
+ *
2227
+ * @example
2228
+ *
2229
+ * ```jsx
2230
+ * import { Suspense } from "octane";
2231
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
2232
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
2233
+ *
2234
+ * const query = gql`
2235
+ * foo {
2236
+ * bar
2237
+ * }
2238
+ * `;
2239
+ *
2240
+ * const client = new ApolloClient({
2241
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
2242
+ * cache: new InMemoryCache(),
2243
+ * });
2244
+ *
2245
+ * function SuspenseFallback() {
2246
+ * return <div>Loading...</div>;
2247
+ * }
2248
+ *
2249
+ * function Child({ queryRef }) {
2250
+ * const { data } = useReadQuery(queryRef);
2251
+ *
2252
+ * return <div>{data.foo.bar}</div>;
2253
+ * }
2254
+ *
2255
+ * function Parent() {
2256
+ * const [queryRef] = useBackgroundQuery(query);
2257
+ *
2258
+ * return (
2259
+ * <Suspense fallback={<SuspenseFallback />}>
2260
+ * <Child queryRef={queryRef} />
2261
+ * </Suspense>
2262
+ * );
2263
+ * }
2264
+ *
2265
+ * function App() {
2266
+ * return (
2267
+ * <ApolloProvider client={client}>
2268
+ * <Parent />
2269
+ * </ApolloProvider>
2270
+ * );
2271
+ * }
2272
+ * ```
2273
+ *
2274
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
2275
+ * @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.
2276
+ */
2277
+ <TData, TVariables extends OperationVariables = OperationVariables>(
2278
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
2279
+ options: SkipToken,
2280
+ ): [undefined, useBackgroundQuery.Result<TData, TVariables>];
2281
+ /**
2282
+ * @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
2283
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
2284
+ *
2285
+ *
2286
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
2287
+ *
2288
+ * @returns A tuple containing:
2289
+ *
2290
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
2291
+ * 2. An object containing helper functions for the query:
2292
+ * - `refetch`: A function to re-execute the query
2293
+ * - `fetchMore`: A function to fetch more results for pagination
2294
+ * - `subscribeToMore`: A function to subscribe to updates
2295
+ *
2296
+ * @example
2297
+ *
2298
+ * ```jsx
2299
+ * import { Suspense } from "octane";
2300
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
2301
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
2302
+ *
2303
+ * const query = gql`
2304
+ * foo {
2305
+ * bar
2306
+ * }
2307
+ * `;
2308
+ *
2309
+ * const client = new ApolloClient({
2310
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
2311
+ * cache: new InMemoryCache(),
2312
+ * });
2313
+ *
2314
+ * function SuspenseFallback() {
2315
+ * return <div>Loading...</div>;
2316
+ * }
2317
+ *
2318
+ * function Child({ queryRef }) {
2319
+ * const { data } = useReadQuery(queryRef);
2320
+ *
2321
+ * return <div>{data.foo.bar}</div>;
2322
+ * }
2323
+ *
2324
+ * function Parent() {
2325
+ * const [queryRef] = useBackgroundQuery(query);
2326
+ *
2327
+ * return (
2328
+ * <Suspense fallback={<SuspenseFallback />}>
2329
+ * <Child queryRef={queryRef} />
2330
+ * </Suspense>
2331
+ * );
2332
+ * }
2333
+ *
2334
+ * function App() {
2335
+ * return (
2336
+ * <ApolloProvider client={client}>
2337
+ * <Parent />
2338
+ * </ApolloProvider>
2339
+ * );
2340
+ * }
2341
+ * ```
2342
+ *
2343
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
2344
+ * @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.
2345
+ */
2346
+ <TData, TVariables extends OperationVariables = OperationVariables>(
2347
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
2348
+ options:
2349
+ | SkipToken
2350
+ | (useBackgroundQuery.Options<NoInfer<TVariables>> & {
2351
+ returnPartialData: false;
2352
+ }),
2353
+ ): [
2354
+ QueryRef<TData, TVariables, 'complete' | 'streaming'> | undefined,
2355
+ useBackgroundQuery.Result<TData, TVariables>,
2356
+ ];
2357
+ /**
2358
+ * @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
2359
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
2360
+ *
2361
+ *
2362
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
2363
+ *
2364
+ * @returns A tuple containing:
2365
+ *
2366
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
2367
+ * 2. An object containing helper functions for the query:
2368
+ * - `refetch`: A function to re-execute the query
2369
+ * - `fetchMore`: A function to fetch more results for pagination
2370
+ * - `subscribeToMore`: A function to subscribe to updates
2371
+ *
2372
+ * @example
2373
+ *
2374
+ * ```jsx
2375
+ * import { Suspense } from "octane";
2376
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
2377
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
2378
+ *
2379
+ * const query = gql`
2380
+ * foo {
2381
+ * bar
2382
+ * }
2383
+ * `;
2384
+ *
2385
+ * const client = new ApolloClient({
2386
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
2387
+ * cache: new InMemoryCache(),
2388
+ * });
2389
+ *
2390
+ * function SuspenseFallback() {
2391
+ * return <div>Loading...</div>;
2392
+ * }
2393
+ *
2394
+ * function Child({ queryRef }) {
2395
+ * const { data } = useReadQuery(queryRef);
2396
+ *
2397
+ * return <div>{data.foo.bar}</div>;
2398
+ * }
2399
+ *
2400
+ * function Parent() {
2401
+ * const [queryRef] = useBackgroundQuery(query);
2402
+ *
2403
+ * return (
2404
+ * <Suspense fallback={<SuspenseFallback />}>
2405
+ * <Child queryRef={queryRef} />
2406
+ * </Suspense>
2407
+ * );
2408
+ * }
2409
+ *
2410
+ * function App() {
2411
+ * return (
2412
+ * <ApolloProvider client={client}>
2413
+ * <Parent />
2414
+ * </ApolloProvider>
2415
+ * );
2416
+ * }
2417
+ * ```
2418
+ *
2419
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
2420
+ * @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.
2421
+ */
2422
+ <TData, TVariables extends OperationVariables = OperationVariables>(
2423
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
2424
+ options:
2425
+ | SkipToken
2426
+ | (useBackgroundQuery.Options<NoInfer<TVariables>> & {
2427
+ returnPartialData: boolean;
2428
+ }),
2429
+ ): [
2430
+ QueryRef<TData, TVariables, 'complete' | 'streaming' | 'partial'> | undefined,
2431
+ useBackgroundQuery.Result<TData, TVariables>,
2432
+ ];
2433
+ /**
2434
+ * @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
2435
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
2436
+ *
2437
+ *
2438
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
2439
+ *
2440
+ * @returns A tuple containing:
2441
+ *
2442
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
2443
+ * 2. An object containing helper functions for the query:
2444
+ * - `refetch`: A function to re-execute the query
2445
+ * - `fetchMore`: A function to fetch more results for pagination
2446
+ * - `subscribeToMore`: A function to subscribe to updates
2447
+ *
2448
+ * @example
2449
+ *
2450
+ * ```jsx
2451
+ * import { Suspense } from "octane";
2452
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
2453
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
2454
+ *
2455
+ * const query = gql`
2456
+ * foo {
2457
+ * bar
2458
+ * }
2459
+ * `;
2460
+ *
2461
+ * const client = new ApolloClient({
2462
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
2463
+ * cache: new InMemoryCache(),
2464
+ * });
2465
+ *
2466
+ * function SuspenseFallback() {
2467
+ * return <div>Loading...</div>;
2468
+ * }
2469
+ *
2470
+ * function Child({ queryRef }) {
2471
+ * const { data } = useReadQuery(queryRef);
2472
+ *
2473
+ * return <div>{data.foo.bar}</div>;
2474
+ * }
2475
+ *
2476
+ * function Parent() {
2477
+ * const [queryRef] = useBackgroundQuery(query);
2478
+ *
2479
+ * return (
2480
+ * <Suspense fallback={<SuspenseFallback />}>
2481
+ * <Child queryRef={queryRef} />
2482
+ * </Suspense>
2483
+ * );
2484
+ * }
2485
+ *
2486
+ * function App() {
2487
+ * return (
2488
+ * <ApolloProvider client={client}>
2489
+ * <Parent />
2490
+ * </ApolloProvider>
2491
+ * );
2492
+ * }
2493
+ * ```
2494
+ *
2495
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
2496
+ * @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.
2497
+ */
2498
+ <TData, TVariables extends OperationVariables = OperationVariables>(
2499
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
2500
+ ...[options]: {} extends TVariables
2501
+ ? [options?: useBackgroundQuery.Options<NoInfer<TVariables>>]
2502
+ : [options: useBackgroundQuery.Options<NoInfer<TVariables>>]
2503
+ ): [
2504
+ QueryRef<TData, TVariables, 'complete' | 'streaming'>,
2505
+ useBackgroundQuery.Result<TData, TVariables>,
2506
+ ];
2507
+ /**
2508
+ * @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
2509
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
2510
+ *
2511
+ *
2512
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
2513
+ *
2514
+ * @returns A tuple containing:
2515
+ *
2516
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
2517
+ * 2. An object containing helper functions for the query:
2518
+ * - `refetch`: A function to re-execute the query
2519
+ * - `fetchMore`: A function to fetch more results for pagination
2520
+ * - `subscribeToMore`: A function to subscribe to updates
2521
+ *
2522
+ * @example
2523
+ *
2524
+ * ```jsx
2525
+ * import { Suspense } from "octane";
2526
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
2527
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
2528
+ *
2529
+ * const query = gql`
2530
+ * foo {
2531
+ * bar
2532
+ * }
2533
+ * `;
2534
+ *
2535
+ * const client = new ApolloClient({
2536
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
2537
+ * cache: new InMemoryCache(),
2538
+ * });
2539
+ *
2540
+ * function SuspenseFallback() {
2541
+ * return <div>Loading...</div>;
2542
+ * }
2543
+ *
2544
+ * function Child({ queryRef }) {
2545
+ * const { data } = useReadQuery(queryRef);
2546
+ *
2547
+ * return <div>{data.foo.bar}</div>;
2548
+ * }
2549
+ *
2550
+ * function Parent() {
2551
+ * const [queryRef] = useBackgroundQuery(query);
2552
+ *
2553
+ * return (
2554
+ * <Suspense fallback={<SuspenseFallback />}>
2555
+ * <Child queryRef={queryRef} />
2556
+ * </Suspense>
2557
+ * );
2558
+ * }
2559
+ *
2560
+ * function App() {
2561
+ * return (
2562
+ * <ApolloProvider client={client}>
2563
+ * <Parent />
2564
+ * </ApolloProvider>
2565
+ * );
2566
+ * }
2567
+ * ```
2568
+ *
2569
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
2570
+ * @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.
2571
+ */
2572
+ <TData, TVariables extends OperationVariables = OperationVariables>(
2573
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
2574
+ ...[options]: {} extends TVariables
2575
+ ? [options?: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>]
2576
+ : [options: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>]
2577
+ ): [
2578
+ QueryRef<TData, TVariables, 'complete' | 'streaming'> | undefined,
2579
+ useBackgroundQuery.Result<TData, TVariables>,
2580
+ ];
2581
+ /**
2582
+ * @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
2583
+ * Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
2584
+ *
2585
+ *
2586
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
2587
+ *
2588
+ * @returns A tuple containing:
2589
+ *
2590
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
2591
+ * 2. An object containing helper functions for the query:
2592
+ * - `refetch`: A function to re-execute the query
2593
+ * - `fetchMore`: A function to fetch more results for pagination
2594
+ * - `subscribeToMore`: A function to subscribe to updates
2595
+ *
2596
+ * @example
2597
+ *
2598
+ * ```jsx
2599
+ * import { Suspense } from "octane";
2600
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
2601
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
2602
+ *
2603
+ * const query = gql`
2604
+ * foo {
2605
+ * bar
2606
+ * }
2607
+ * `;
2608
+ *
2609
+ * const client = new ApolloClient({
2610
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
2611
+ * cache: new InMemoryCache(),
2612
+ * });
2613
+ *
2614
+ * function SuspenseFallback() {
2615
+ * return <div>Loading...</div>;
2616
+ * }
2617
+ *
2618
+ * function Child({ queryRef }) {
2619
+ * const { data } = useReadQuery(queryRef);
2620
+ *
2621
+ * return <div>{data.foo.bar}</div>;
2622
+ * }
2623
+ *
2624
+ * function Parent() {
2625
+ * const [queryRef] = useBackgroundQuery(query);
2626
+ *
2627
+ * return (
2628
+ * <Suspense fallback={<SuspenseFallback />}>
2629
+ * <Child queryRef={queryRef} />
2630
+ * </Suspense>
2631
+ * );
2632
+ * }
2633
+ *
2634
+ * function App() {
2635
+ * return (
2636
+ * <ApolloProvider client={client}>
2637
+ * <Parent />
2638
+ * </ApolloProvider>
2639
+ * );
2640
+ * }
2641
+ * ```
2642
+ *
2643
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
2644
+ * @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.
2645
+ */
2646
+ <TData, TVariables extends OperationVariables = OperationVariables>(
2647
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
2648
+ options: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>,
2649
+ ): [
2650
+ QueryRef<TData, TVariables, 'complete' | 'streaming'> | undefined,
2651
+ useBackgroundQuery.Result<TData, TVariables>,
2652
+ ];
2653
+ }
2654
+ /**
2655
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
2656
+ *
2657
+ * @returns A tuple containing:
2658
+ *
2659
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
2660
+ * 2. An object containing helper functions for the query:
2661
+ * - `refetch`: A function to re-execute the query
2662
+ * - `fetchMore`: A function to fetch more results for pagination
2663
+ * - `subscribeToMore`: A function to subscribe to updates
2664
+ *
2665
+ * @example
2666
+ *
2667
+ * ```jsx
2668
+ * import { Suspense } from "octane";
2669
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
2670
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
2671
+ *
2672
+ * const query = gql`
2673
+ * foo {
2674
+ * bar
2675
+ * }
2676
+ * `;
2677
+ *
2678
+ * const client = new ApolloClient({
2679
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
2680
+ * cache: new InMemoryCache(),
2681
+ * });
2682
+ *
2683
+ * function SuspenseFallback() {
2684
+ * return <div>Loading...</div>;
2685
+ * }
2686
+ *
2687
+ * function Child({ queryRef }) {
2688
+ * const { data } = useReadQuery(queryRef);
2689
+ *
2690
+ * return <div>{data.foo.bar}</div>;
2691
+ * }
2692
+ *
2693
+ * function Parent() {
2694
+ * const [queryRef] = useBackgroundQuery(query);
2695
+ *
2696
+ * return (
2697
+ * <Suspense fallback={<SuspenseFallback />}>
2698
+ * <Child queryRef={queryRef} />
2699
+ * </Suspense>
2700
+ * );
2701
+ * }
2702
+ *
2703
+ * function App() {
2704
+ * return (
2705
+ * <ApolloProvider client={client}>
2706
+ * <Parent />
2707
+ * </ApolloProvider>
2708
+ * );
2709
+ * }
2710
+ * ```
2711
+ *
2712
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
2713
+ * @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.
2714
+ */
2715
+ interface Modern {
2716
+ /**
2717
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
2718
+ *
2719
+ * @returns A tuple containing:
2720
+ *
2721
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
2722
+ * 2. An object containing helper functions for the query:
2723
+ * - `refetch`: A function to re-execute the query
2724
+ * - `fetchMore`: A function to fetch more results for pagination
2725
+ * - `subscribeToMore`: A function to subscribe to updates
2726
+ *
2727
+ * @example
2728
+ *
2729
+ * ```jsx
2730
+ * import { Suspense } from "octane";
2731
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
2732
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
2733
+ *
2734
+ * const query = gql`
2735
+ * foo {
2736
+ * bar
2737
+ * }
2738
+ * `;
2739
+ *
2740
+ * const client = new ApolloClient({
2741
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
2742
+ * cache: new InMemoryCache(),
2743
+ * });
2744
+ *
2745
+ * function SuspenseFallback() {
2746
+ * return <div>Loading...</div>;
2747
+ * }
2748
+ *
2749
+ * function Child({ queryRef }) {
2750
+ * const { data } = useReadQuery(queryRef);
2751
+ *
2752
+ * return <div>{data.foo.bar}</div>;
2753
+ * }
2754
+ *
2755
+ * function Parent() {
2756
+ * const [queryRef] = useBackgroundQuery(query);
2757
+ *
2758
+ * return (
2759
+ * <Suspense fallback={<SuspenseFallback />}>
2760
+ * <Child queryRef={queryRef} />
2761
+ * </Suspense>
2762
+ * );
2763
+ * }
2764
+ *
2765
+ * function App() {
2766
+ * return (
2767
+ * <ApolloProvider client={client}>
2768
+ * <Parent />
2769
+ * </ApolloProvider>
2770
+ * );
2771
+ * }
2772
+ * ```
2773
+ *
2774
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
2775
+ * @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.
2776
+ */
2777
+ <TData, TVariables extends OperationVariables, TOptions extends never>(
2778
+ query: {} extends TVariables ? DocumentNode | TypedDocumentNode<TData, TVariables> : never,
2779
+ ): useBackgroundQuery.ResultForOptions<TData, TVariables, Record<string, never>>;
2780
+ /**
2781
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
2782
+ *
2783
+ * @returns A tuple containing:
2784
+ *
2785
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
2786
+ * 2. An object containing helper functions for the query:
2787
+ * - `refetch`: A function to re-execute the query
2788
+ * - `fetchMore`: A function to fetch more results for pagination
2789
+ * - `subscribeToMore`: A function to subscribe to updates
2790
+ *
2791
+ * @example
2792
+ *
2793
+ * ```jsx
2794
+ * import { Suspense } from "octane";
2795
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
2796
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
2797
+ *
2798
+ * const query = gql`
2799
+ * foo {
2800
+ * bar
2801
+ * }
2802
+ * `;
2803
+ *
2804
+ * const client = new ApolloClient({
2805
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
2806
+ * cache: new InMemoryCache(),
2807
+ * });
2808
+ *
2809
+ * function SuspenseFallback() {
2810
+ * return <div>Loading...</div>;
2811
+ * }
2812
+ *
2813
+ * function Child({ queryRef }) {
2814
+ * const { data } = useReadQuery(queryRef);
2815
+ *
2816
+ * return <div>{data.foo.bar}</div>;
2817
+ * }
2818
+ *
2819
+ * function Parent() {
2820
+ * const [queryRef] = useBackgroundQuery(query);
2821
+ *
2822
+ * return (
2823
+ * <Suspense fallback={<SuspenseFallback />}>
2824
+ * <Child queryRef={queryRef} />
2825
+ * </Suspense>
2826
+ * );
2827
+ * }
2828
+ *
2829
+ * function App() {
2830
+ * return (
2831
+ * <ApolloProvider client={client}>
2832
+ * <Parent />
2833
+ * </ApolloProvider>
2834
+ * );
2835
+ * }
2836
+ * ```
2837
+ *
2838
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
2839
+ * @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.
2840
+ */
2841
+ <
2842
+ TData,
2843
+ TVariables extends OperationVariables,
2844
+ TOptions extends useBackgroundQuery.Options<NoInfer<TVariables>> &
2845
+ VariablesOption<
2846
+ TVariables & {
2847
+ [K in Exclude<keyof TOptions['variables'], keyof TVariables>]?: never;
2848
+ }
2849
+ >,
2850
+ >(
2851
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
2852
+ ...[options]: {} extends TVariables ? [options?: TOptions] : [options: TOptions]
2853
+ ): useBackgroundQuery.ResultForOptions<TData, TVariables, TOptions>;
2854
+ /**
2855
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
2856
+ *
2857
+ * @returns A tuple containing:
2858
+ *
2859
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
2860
+ * 2. An object containing helper functions for the query:
2861
+ * - `refetch`: A function to re-execute the query
2862
+ * - `fetchMore`: A function to fetch more results for pagination
2863
+ * - `subscribeToMore`: A function to subscribe to updates
2864
+ *
2865
+ * @example
2866
+ *
2867
+ * ```jsx
2868
+ * import { Suspense } from "octane";
2869
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
2870
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
2871
+ *
2872
+ * const query = gql`
2873
+ * foo {
2874
+ * bar
2875
+ * }
2876
+ * `;
2877
+ *
2878
+ * const client = new ApolloClient({
2879
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
2880
+ * cache: new InMemoryCache(),
2881
+ * });
2882
+ *
2883
+ * function SuspenseFallback() {
2884
+ * return <div>Loading...</div>;
2885
+ * }
2886
+ *
2887
+ * function Child({ queryRef }) {
2888
+ * const { data } = useReadQuery(queryRef);
2889
+ *
2890
+ * return <div>{data.foo.bar}</div>;
2891
+ * }
2892
+ *
2893
+ * function Parent() {
2894
+ * const [queryRef] = useBackgroundQuery(query);
2895
+ *
2896
+ * return (
2897
+ * <Suspense fallback={<SuspenseFallback />}>
2898
+ * <Child queryRef={queryRef} />
2899
+ * </Suspense>
2900
+ * );
2901
+ * }
2902
+ *
2903
+ * function App() {
2904
+ * return (
2905
+ * <ApolloProvider client={client}>
2906
+ * <Parent />
2907
+ * </ApolloProvider>
2908
+ * );
2909
+ * }
2910
+ * ```
2911
+ *
2912
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
2913
+ * @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.
2914
+ */
2915
+ <TData, TVariables extends OperationVariables, TOptions extends never>(
2916
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
2917
+ skipToken: SkipToken,
2918
+ ): useBackgroundQuery.ResultForOptions<TData, TVariables, SkipToken>;
2919
+ /**
2920
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
2921
+ *
2922
+ * @returns A tuple containing:
2923
+ *
2924
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
2925
+ * 2. An object containing helper functions for the query:
2926
+ * - `refetch`: A function to re-execute the query
2927
+ * - `fetchMore`: A function to fetch more results for pagination
2928
+ * - `subscribeToMore`: A function to subscribe to updates
2929
+ *
2930
+ * @example
2931
+ *
2932
+ * ```jsx
2933
+ * import { Suspense } from "octane";
2934
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
2935
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
2936
+ *
2937
+ * const query = gql`
2938
+ * foo {
2939
+ * bar
2940
+ * }
2941
+ * `;
2942
+ *
2943
+ * const client = new ApolloClient({
2944
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
2945
+ * cache: new InMemoryCache(),
2946
+ * });
2947
+ *
2948
+ * function SuspenseFallback() {
2949
+ * return <div>Loading...</div>;
2950
+ * }
2951
+ *
2952
+ * function Child({ queryRef }) {
2953
+ * const { data } = useReadQuery(queryRef);
2954
+ *
2955
+ * return <div>{data.foo.bar}</div>;
2956
+ * }
2957
+ *
2958
+ * function Parent() {
2959
+ * const [queryRef] = useBackgroundQuery(query);
2960
+ *
2961
+ * return (
2962
+ * <Suspense fallback={<SuspenseFallback />}>
2963
+ * <Child queryRef={queryRef} />
2964
+ * </Suspense>
2965
+ * );
2966
+ * }
2967
+ *
2968
+ * function App() {
2969
+ * return (
2970
+ * <ApolloProvider client={client}>
2971
+ * <Parent />
2972
+ * </ApolloProvider>
2973
+ * );
2974
+ * }
2975
+ * ```
2976
+ *
2977
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
2978
+ * @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.
2979
+ */
2980
+ <
2981
+ TData,
2982
+ TVariables extends OperationVariables,
2983
+ TOptions extends useBackgroundQuery.Options<NoInfer<TVariables>> &
2984
+ VariablesOption<
2985
+ TVariables & {
2986
+ [K in Exclude<keyof TOptions['variables'], keyof TVariables>]?: never;
2987
+ }
2988
+ >,
2989
+ >(
2990
+ query: DocumentNode | TypedDocumentNode<TData, TVariables>,
2991
+ ...[options]: {} extends TVariables
2992
+ ? [options?: TOptions | SkipToken]
2993
+ : [options: TOptions | SkipToken]
2994
+ ): useBackgroundQuery.ResultForOptions<TData, TVariables, TOptions | SkipToken>;
2995
+ }
2996
+ type Evaluated = SignatureStyle extends 'classic' ? Classic : Modern;
2997
+ }
2998
+ /**
2999
+ * For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
3000
+ *
3001
+ * @returns A tuple containing:
3002
+ *
3003
+ * 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
3004
+ * 2. An object containing helper functions for the query:
3005
+ * - `refetch`: A function to re-execute the query
3006
+ * - `fetchMore`: A function to fetch more results for pagination
3007
+ * - `subscribeToMore`: A function to subscribe to updates
3008
+ *
3009
+ * @example
3010
+ *
3011
+ * ```jsx
3012
+ * import { Suspense } from "octane";
3013
+ * import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
3014
+ * import { useBackgroundQuery, useReadQuery } from "@octanejs/apollo-client/react";
3015
+ *
3016
+ * const query = gql`
3017
+ * foo {
3018
+ * bar
3019
+ * }
3020
+ * `;
3021
+ *
3022
+ * const client = new ApolloClient({
3023
+ * link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
3024
+ * cache: new InMemoryCache(),
3025
+ * });
3026
+ *
3027
+ * function SuspenseFallback() {
3028
+ * return <div>Loading...</div>;
3029
+ * }
3030
+ *
3031
+ * function Child({ queryRef }) {
3032
+ * const { data } = useReadQuery(queryRef);
3033
+ *
3034
+ * return <div>{data.foo.bar}</div>;
3035
+ * }
3036
+ *
3037
+ * function Parent() {
3038
+ * const [queryRef] = useBackgroundQuery(query);
3039
+ *
3040
+ * return (
3041
+ * <Suspense fallback={<SuspenseFallback />}>
3042
+ * <Child queryRef={queryRef} />
3043
+ * </Suspense>
3044
+ * );
3045
+ * }
3046
+ *
3047
+ * function App() {
3048
+ * return (
3049
+ * <ApolloProvider client={client}>
3050
+ * <Parent />
3051
+ * </ApolloProvider>
3052
+ * );
3053
+ * }
3054
+ * ```
3055
+ *
3056
+ * @param query - A GraphQL query document parsed into an AST by `gql`.
3057
+ * @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.
3058
+ */
3059
+ interface Signature extends Signatures.Evaluated {}
3060
+ }
3061
+ export declare const useBackgroundQuery: useBackgroundQuery.Signature;