@apollo/client 4.2.0-alpha.1 → 4.2.0-alpha.3
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.
- package/CHANGELOG.md +209 -0
- package/__cjs/core/ApolloClient.cjs +25 -12
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +305 -146
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/defaultOptions.cjs +3 -0
- package/__cjs/core/defaultOptions.cjs.map +1 -0
- package/__cjs/core/defaultOptions.d.cts +90 -0
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +2 -1
- package/__cjs/link/ws/index.cjs +9 -1
- package/__cjs/link/ws/index.cjs.map +1 -1
- package/__cjs/link/ws/index.d.cts +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.cjs +3 -3
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +1598 -765
- package/__cjs/react/hooks/useLazyQuery.cjs +3 -5
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +369 -115
- package/__cjs/react/hooks/useLoadableQuery.cjs +8 -4
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +507 -192
- package/__cjs/react/hooks/useMutation.cjs +5 -48
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +239 -130
- package/__cjs/react/hooks/useQuery.cjs +5 -5
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +636 -276
- package/__cjs/react/hooks/useSubscription.cjs +1 -1
- package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
- package/__cjs/react/hooks/useSubscription.d.cts +2 -2
- package/__cjs/react/hooks/useSuspenseQuery.cjs +3 -3
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +799 -399
- package/__cjs/react/internal/cache/getSuspenseCache.cjs.map +1 -1
- package/__cjs/react/internal/cache/getSuspenseCache.d.cts +7 -0
- package/__cjs/utilities/internal/LazyType.cjs +3 -0
- package/__cjs/utilities/internal/LazyType.cjs.map +1 -0
- package/__cjs/utilities/internal/LazyType.d.cts +10 -0
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +3 -0
- package/__cjs/utilities/internal/types/OptionWithFallback.cjs +3 -0
- package/__cjs/utilities/internal/types/OptionWithFallback.cjs.map +1 -0
- package/__cjs/utilities/internal/types/OptionWithFallback.d.cts +5 -0
- package/__cjs/utilities/internal/types/SignatureStyle.cjs +3 -0
- package/__cjs/utilities/internal/types/SignatureStyle.cjs.map +1 -0
- package/__cjs/utilities/internal/types/SignatureStyle.d.cts +24 -0
- package/__cjs/version.cjs +1 -1
- package/core/ApolloClient.d.ts +305 -146
- package/core/ApolloClient.js +25 -12
- package/core/ApolloClient.js.map +1 -1
- package/core/QueryManager.js.map +1 -1
- package/core/defaultOptions.d.ts +90 -0
- package/core/defaultOptions.js +2 -0
- package/core/defaultOptions.js.map +1 -0
- package/core/index.d.ts +2 -1
- package/core/index.js.map +1 -1
- package/link/ws/index.d.ts +1 -1
- package/link/ws/index.js +9 -1
- package/link/ws/index.js.map +1 -1
- package/package.json +3 -7
- package/react/hooks/useBackgroundQuery.d.ts +1598 -765
- package/react/hooks/useBackgroundQuery.js +2 -2
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +369 -115
- package/react/hooks/useLazyQuery.js +2 -4
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +507 -192
- package/react/hooks/useLoadableQuery.js +7 -3
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +239 -130
- package/react/hooks/useMutation.js +5 -48
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +636 -276
- package/react/hooks/useQuery.js +2 -2
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +2 -2
- package/react/hooks/useSubscription.js +1 -1
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +799 -399
- package/react/hooks/useSuspenseQuery.js +2 -2
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/useBackgroundQuery.d.ts +1598 -765
- package/react/hooks-compiled/useBackgroundQuery.js +2 -2
- package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.d.ts +369 -115
- package/react/hooks-compiled/useLazyQuery.js +2 -4
- package/react/hooks-compiled/useLazyQuery.js.map +1 -1
- package/react/hooks-compiled/useLoadableQuery.d.ts +507 -192
- package/react/hooks-compiled/useLoadableQuery.js +2 -2
- package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
- package/react/hooks-compiled/useMutation.d.ts +239 -130
- package/react/hooks-compiled/useMutation.js +4 -47
- package/react/hooks-compiled/useMutation.js.map +1 -1
- package/react/hooks-compiled/useQuery.d.ts +636 -276
- package/react/hooks-compiled/useQuery.js +2 -2
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/hooks-compiled/useSubscription.d.ts +2 -2
- package/react/hooks-compiled/useSubscription.js +1 -1
- package/react/hooks-compiled/useSubscription.js.map +1 -1
- package/react/hooks-compiled/useSuspenseQuery.d.ts +799 -399
- package/react/hooks-compiled/useSuspenseQuery.js +2 -2
- package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
- package/react/internal/cache/getSuspenseCache.d.ts +7 -0
- package/react/internal/cache/getSuspenseCache.js.map +1 -1
- package/skills/apollo-client/SKILL.md +168 -0
- package/skills/apollo-client/references/caching.md +560 -0
- package/skills/apollo-client/references/error-handling.md +350 -0
- package/skills/apollo-client/references/fragments.md +804 -0
- package/skills/apollo-client/references/integration-client.md +336 -0
- package/skills/apollo-client/references/integration-nextjs.md +325 -0
- package/skills/apollo-client/references/integration-react-router.md +256 -0
- package/skills/apollo-client/references/integration-tanstack-start.md +378 -0
- package/skills/apollo-client/references/mutations.md +549 -0
- package/skills/apollo-client/references/queries.md +416 -0
- package/skills/apollo-client/references/state-management.md +428 -0
- package/skills/apollo-client/references/suspense-hooks.md +773 -0
- package/skills/apollo-client/references/troubleshooting.md +487 -0
- package/skills/apollo-client/references/typescript-codegen.md +133 -0
- package/utilities/internal/LazyType.d.ts +10 -0
- package/utilities/internal/LazyType.js +2 -0
- package/utilities/internal/LazyType.js.map +1 -0
- package/utilities/internal/index.d.ts +3 -0
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/types/OptionWithFallback.d.ts +5 -0
- package/utilities/internal/types/OptionWithFallback.js +2 -0
- package/utilities/internal/types/OptionWithFallback.js.map +1 -0
- package/utilities/internal/types/SignatureStyle.d.ts +24 -0
- package/utilities/internal/types/SignatureStyle.js +2 -0
- package/utilities/internal/types/SignatureStyle.js.map +1 -0
- package/version.js +1 -1
|
@@ -2,7 +2,7 @@ import type { ApolloClient, DefaultContext, DocumentNode, ErrorPolicy, Operation
|
|
|
2
2
|
import type { SubscribeToMoreFunction } from "@apollo/client";
|
|
3
3
|
import type { QueryRef } from "@apollo/client/react";
|
|
4
4
|
import type { FetchMoreFunction, RefetchFunction } from "@apollo/client/react/internal";
|
|
5
|
-
import type { DocumentationTypes as UtilityDocumentationTypes, NoInfer, VariablesOption } from "@apollo/client/utilities/internal";
|
|
5
|
+
import type { DocumentationTypes as UtilityDocumentationTypes, NoInfer, OptionWithFallback, SignatureStyle, VariablesOption } from "@apollo/client/utilities/internal";
|
|
6
6
|
import type { SkipToken } from "./constants.cjs";
|
|
7
7
|
export declare namespace useBackgroundQuery {
|
|
8
8
|
import _self = useBackgroundQuery;
|
|
@@ -144,8 +144,159 @@ export declare namespace useBackgroundQuery {
|
|
|
144
144
|
}
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
|
+
interface DefaultOptions extends ApolloClient.DefaultOptions.WatchQuery.Calculated {
|
|
148
|
+
skip: false;
|
|
149
|
+
}
|
|
150
|
+
type ResultForOptions<TData, TVariables extends OperationVariables, TOptions extends Record<string, never> | Options<TVariables> | SkipToken> = [
|
|
151
|
+
queryRef: TOptions extends any ? TOptions extends SkipToken ? undefined : QueryRef<TData, TVariables, "complete" | "streaming" | ((OptionWithFallback<TOptions, DefaultOptions, "errorPolicy"> extends "none" ? never : "empty") | (OptionWithFallback<TOptions, DefaultOptions, "returnPartialData"> extends false ? never : "partial"))> | (OptionWithFallback<TOptions, DefaultOptions, "skip"> extends false ? never : undefined) : never,
|
|
152
|
+
result: useBackgroundQuery.Result<TData, TVariables>
|
|
153
|
+
];
|
|
147
154
|
namespace DocumentationTypes {
|
|
155
|
+
interface useBackgroundQuery {
|
|
156
|
+
/**
|
|
157
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
158
|
+
*
|
|
159
|
+
* @returns A tuple containing:
|
|
160
|
+
*
|
|
161
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
162
|
+
* 2. An object containing helper functions for the query:
|
|
163
|
+
* - `refetch`: A function to re-execute the query
|
|
164
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
165
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
166
|
+
*
|
|
167
|
+
* @example
|
|
168
|
+
*
|
|
169
|
+
* ```jsx
|
|
170
|
+
* import { Suspense } from "react";
|
|
171
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
172
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
173
|
+
*
|
|
174
|
+
* const query = gql`
|
|
175
|
+
* foo {
|
|
176
|
+
* bar
|
|
177
|
+
* }
|
|
178
|
+
* `;
|
|
179
|
+
*
|
|
180
|
+
* const client = new ApolloClient({
|
|
181
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
182
|
+
* cache: new InMemoryCache(),
|
|
183
|
+
* });
|
|
184
|
+
*
|
|
185
|
+
* function SuspenseFallback() {
|
|
186
|
+
* return <div>Loading...</div>;
|
|
187
|
+
* }
|
|
188
|
+
*
|
|
189
|
+
* function Child({ queryRef }) {
|
|
190
|
+
* const { data } = useReadQuery(queryRef);
|
|
191
|
+
*
|
|
192
|
+
* return <div>{data.foo.bar}</div>;
|
|
193
|
+
* }
|
|
194
|
+
*
|
|
195
|
+
* function Parent() {
|
|
196
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
197
|
+
*
|
|
198
|
+
* return (
|
|
199
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
200
|
+
* <Child queryRef={queryRef} />
|
|
201
|
+
* </Suspense>
|
|
202
|
+
* );
|
|
203
|
+
* }
|
|
204
|
+
*
|
|
205
|
+
* function App() {
|
|
206
|
+
* return (
|
|
207
|
+
* <ApolloProvider client={client}>
|
|
208
|
+
* <Parent />
|
|
209
|
+
* </ApolloProvider>
|
|
210
|
+
* );
|
|
211
|
+
* }
|
|
212
|
+
* ```
|
|
213
|
+
*
|
|
214
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
215
|
+
* @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.
|
|
216
|
+
*/
|
|
217
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | useBackgroundQuery.Options<TVariables>): [
|
|
218
|
+
QueryRef<TData, TVariables> | undefined,
|
|
219
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
220
|
+
];
|
|
221
|
+
}
|
|
222
|
+
interface useBackgroundQuery_Deprecated {
|
|
223
|
+
/**
|
|
224
|
+
* @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
|
|
225
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
226
|
+
*
|
|
227
|
+
*
|
|
228
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
229
|
+
*
|
|
230
|
+
* @returns A tuple containing:
|
|
231
|
+
*
|
|
232
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
233
|
+
* 2. An object containing helper functions for the query:
|
|
234
|
+
* - `refetch`: A function to re-execute the query
|
|
235
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
236
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
237
|
+
*
|
|
238
|
+
* @example
|
|
239
|
+
*
|
|
240
|
+
* ```jsx
|
|
241
|
+
* import { Suspense } from "react";
|
|
242
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
243
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
244
|
+
*
|
|
245
|
+
* const query = gql`
|
|
246
|
+
* foo {
|
|
247
|
+
* bar
|
|
248
|
+
* }
|
|
249
|
+
* `;
|
|
250
|
+
*
|
|
251
|
+
* const client = new ApolloClient({
|
|
252
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
253
|
+
* cache: new InMemoryCache(),
|
|
254
|
+
* });
|
|
255
|
+
*
|
|
256
|
+
* function SuspenseFallback() {
|
|
257
|
+
* return <div>Loading...</div>;
|
|
258
|
+
* }
|
|
259
|
+
*
|
|
260
|
+
* function Child({ queryRef }) {
|
|
261
|
+
* const { data } = useReadQuery(queryRef);
|
|
262
|
+
*
|
|
263
|
+
* return <div>{data.foo.bar}</div>;
|
|
264
|
+
* }
|
|
265
|
+
*
|
|
266
|
+
* function Parent() {
|
|
267
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
268
|
+
*
|
|
269
|
+
* return (
|
|
270
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
271
|
+
* <Child queryRef={queryRef} />
|
|
272
|
+
* </Suspense>
|
|
273
|
+
* );
|
|
274
|
+
* }
|
|
275
|
+
*
|
|
276
|
+
* function App() {
|
|
277
|
+
* return (
|
|
278
|
+
* <ApolloProvider client={client}>
|
|
279
|
+
* <Parent />
|
|
280
|
+
* </ApolloProvider>
|
|
281
|
+
* );
|
|
282
|
+
* }
|
|
283
|
+
* ```
|
|
284
|
+
*
|
|
285
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
286
|
+
* @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.
|
|
287
|
+
*/
|
|
288
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | useBackgroundQuery.Options<TVariables>): [
|
|
289
|
+
QueryRef<TData, TVariables> | undefined,
|
|
290
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
291
|
+
];
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
namespace Signatures {
|
|
148
295
|
/**
|
|
296
|
+
* @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
|
|
297
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
298
|
+
*
|
|
299
|
+
*
|
|
149
300
|
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
150
301
|
*
|
|
151
302
|
* @returns A tuple containing:
|
|
@@ -206,770 +357,1452 @@ export declare namespace useBackgroundQuery {
|
|
|
206
357
|
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
207
358
|
* @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.
|
|
208
359
|
*/
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
useBackgroundQuery
|
|
212
|
-
|
|
360
|
+
interface Classic {
|
|
361
|
+
/**
|
|
362
|
+
* @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
|
|
363
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
364
|
+
*
|
|
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 "react";
|
|
380
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
381
|
+
* import { useBackgroundQuery, useReadQuery } from "@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
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
427
|
+
/** @deprecated `returnPartialData` has no effect on `no-cache` queries */
|
|
428
|
+
returnPartialData: boolean;
|
|
429
|
+
fetchPolicy: "no-cache";
|
|
430
|
+
}): [
|
|
431
|
+
QueryRef<TData, TVariables, "complete" | "streaming">,
|
|
432
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
433
|
+
];
|
|
434
|
+
/**
|
|
435
|
+
* @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
|
|
436
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
437
|
+
*
|
|
438
|
+
*
|
|
439
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
440
|
+
*
|
|
441
|
+
* @returns A tuple containing:
|
|
442
|
+
*
|
|
443
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
444
|
+
* 2. An object containing helper functions for the query:
|
|
445
|
+
* - `refetch`: A function to re-execute the query
|
|
446
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
447
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
448
|
+
*
|
|
449
|
+
* @example
|
|
450
|
+
*
|
|
451
|
+
* ```jsx
|
|
452
|
+
* import { Suspense } from "react";
|
|
453
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
454
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
455
|
+
*
|
|
456
|
+
* const query = gql`
|
|
457
|
+
* foo {
|
|
458
|
+
* bar
|
|
459
|
+
* }
|
|
460
|
+
* `;
|
|
461
|
+
*
|
|
462
|
+
* const client = new ApolloClient({
|
|
463
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
464
|
+
* cache: new InMemoryCache(),
|
|
465
|
+
* });
|
|
466
|
+
*
|
|
467
|
+
* function SuspenseFallback() {
|
|
468
|
+
* return <div>Loading...</div>;
|
|
469
|
+
* }
|
|
470
|
+
*
|
|
471
|
+
* function Child({ queryRef }) {
|
|
472
|
+
* const { data } = useReadQuery(queryRef);
|
|
473
|
+
*
|
|
474
|
+
* return <div>{data.foo.bar}</div>;
|
|
475
|
+
* }
|
|
476
|
+
*
|
|
477
|
+
* function Parent() {
|
|
478
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
479
|
+
*
|
|
480
|
+
* return (
|
|
481
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
482
|
+
* <Child queryRef={queryRef} />
|
|
483
|
+
* </Suspense>
|
|
484
|
+
* );
|
|
485
|
+
* }
|
|
486
|
+
*
|
|
487
|
+
* function App() {
|
|
488
|
+
* return (
|
|
489
|
+
* <ApolloProvider client={client}>
|
|
490
|
+
* <Parent />
|
|
491
|
+
* </ApolloProvider>
|
|
492
|
+
* );
|
|
493
|
+
* }
|
|
494
|
+
* ```
|
|
495
|
+
*
|
|
496
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
497
|
+
* @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.
|
|
498
|
+
*/
|
|
499
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
500
|
+
returnPartialData: false;
|
|
501
|
+
errorPolicy: "ignore" | "all";
|
|
502
|
+
}): [
|
|
503
|
+
QueryRef<TData, TVariables, "complete" | "streaming" | "empty">,
|
|
504
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
505
|
+
];
|
|
506
|
+
/**
|
|
507
|
+
* @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
|
|
508
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
509
|
+
*
|
|
510
|
+
*
|
|
511
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
512
|
+
*
|
|
513
|
+
* @returns A tuple containing:
|
|
514
|
+
*
|
|
515
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
516
|
+
* 2. An object containing helper functions for the query:
|
|
517
|
+
* - `refetch`: A function to re-execute the query
|
|
518
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
519
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
520
|
+
*
|
|
521
|
+
* @example
|
|
522
|
+
*
|
|
523
|
+
* ```jsx
|
|
524
|
+
* import { Suspense } from "react";
|
|
525
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
526
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
527
|
+
*
|
|
528
|
+
* const query = gql`
|
|
529
|
+
* foo {
|
|
530
|
+
* bar
|
|
531
|
+
* }
|
|
532
|
+
* `;
|
|
533
|
+
*
|
|
534
|
+
* const client = new ApolloClient({
|
|
535
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
536
|
+
* cache: new InMemoryCache(),
|
|
537
|
+
* });
|
|
538
|
+
*
|
|
539
|
+
* function SuspenseFallback() {
|
|
540
|
+
* return <div>Loading...</div>;
|
|
541
|
+
* }
|
|
542
|
+
*
|
|
543
|
+
* function Child({ queryRef }) {
|
|
544
|
+
* const { data } = useReadQuery(queryRef);
|
|
545
|
+
*
|
|
546
|
+
* return <div>{data.foo.bar}</div>;
|
|
547
|
+
* }
|
|
548
|
+
*
|
|
549
|
+
* function Parent() {
|
|
550
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
551
|
+
*
|
|
552
|
+
* return (
|
|
553
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
554
|
+
* <Child queryRef={queryRef} />
|
|
555
|
+
* </Suspense>
|
|
556
|
+
* );
|
|
557
|
+
* }
|
|
558
|
+
*
|
|
559
|
+
* function App() {
|
|
560
|
+
* return (
|
|
561
|
+
* <ApolloProvider client={client}>
|
|
562
|
+
* <Parent />
|
|
563
|
+
* </ApolloProvider>
|
|
564
|
+
* );
|
|
565
|
+
* }
|
|
566
|
+
* ```
|
|
567
|
+
*
|
|
568
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
569
|
+
* @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.
|
|
570
|
+
*/
|
|
571
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
572
|
+
returnPartialData: boolean;
|
|
573
|
+
errorPolicy: "ignore" | "all";
|
|
574
|
+
}): [
|
|
575
|
+
QueryRef<TData, TVariables, "complete" | "streaming" | "partial" | "empty">,
|
|
576
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
577
|
+
];
|
|
578
|
+
/**
|
|
579
|
+
* @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
|
|
580
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
581
|
+
*
|
|
582
|
+
*
|
|
583
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
584
|
+
*
|
|
585
|
+
* @returns A tuple containing:
|
|
586
|
+
*
|
|
587
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
588
|
+
* 2. An object containing helper functions for the query:
|
|
589
|
+
* - `refetch`: A function to re-execute the query
|
|
590
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
591
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
592
|
+
*
|
|
593
|
+
* @example
|
|
594
|
+
*
|
|
595
|
+
* ```jsx
|
|
596
|
+
* import { Suspense } from "react";
|
|
597
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
598
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
599
|
+
*
|
|
600
|
+
* const query = gql`
|
|
601
|
+
* foo {
|
|
602
|
+
* bar
|
|
603
|
+
* }
|
|
604
|
+
* `;
|
|
605
|
+
*
|
|
606
|
+
* const client = new ApolloClient({
|
|
607
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
608
|
+
* cache: new InMemoryCache(),
|
|
609
|
+
* });
|
|
610
|
+
*
|
|
611
|
+
* function SuspenseFallback() {
|
|
612
|
+
* return <div>Loading...</div>;
|
|
613
|
+
* }
|
|
614
|
+
*
|
|
615
|
+
* function Child({ queryRef }) {
|
|
616
|
+
* const { data } = useReadQuery(queryRef);
|
|
617
|
+
*
|
|
618
|
+
* return <div>{data.foo.bar}</div>;
|
|
619
|
+
* }
|
|
620
|
+
*
|
|
621
|
+
* function Parent() {
|
|
622
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
623
|
+
*
|
|
624
|
+
* return (
|
|
625
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
626
|
+
* <Child queryRef={queryRef} />
|
|
627
|
+
* </Suspense>
|
|
628
|
+
* );
|
|
629
|
+
* }
|
|
630
|
+
*
|
|
631
|
+
* function App() {
|
|
632
|
+
* return (
|
|
633
|
+
* <ApolloProvider client={client}>
|
|
634
|
+
* <Parent />
|
|
635
|
+
* </ApolloProvider>
|
|
636
|
+
* );
|
|
637
|
+
* }
|
|
638
|
+
* ```
|
|
639
|
+
*
|
|
640
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
641
|
+
* @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.
|
|
642
|
+
*/
|
|
643
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
644
|
+
errorPolicy: "ignore" | "all";
|
|
645
|
+
}): [
|
|
646
|
+
QueryRef<TData, TVariables, "complete" | "streaming" | "empty">,
|
|
647
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
648
|
+
];
|
|
649
|
+
/**
|
|
650
|
+
* @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
|
|
651
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
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 "react";
|
|
668
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
669
|
+
* import { useBackgroundQuery, useReadQuery } from "@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
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
715
|
+
skip: boolean;
|
|
716
|
+
returnPartialData: false;
|
|
717
|
+
}): [
|
|
718
|
+
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
719
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
720
|
+
];
|
|
721
|
+
/**
|
|
722
|
+
* @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
|
|
723
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
724
|
+
*
|
|
725
|
+
*
|
|
726
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
727
|
+
*
|
|
728
|
+
* @returns A tuple containing:
|
|
729
|
+
*
|
|
730
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
731
|
+
* 2. An object containing helper functions for the query:
|
|
732
|
+
* - `refetch`: A function to re-execute the query
|
|
733
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
734
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
735
|
+
*
|
|
736
|
+
* @example
|
|
737
|
+
*
|
|
738
|
+
* ```jsx
|
|
739
|
+
* import { Suspense } from "react";
|
|
740
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
741
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
742
|
+
*
|
|
743
|
+
* const query = gql`
|
|
744
|
+
* foo {
|
|
745
|
+
* bar
|
|
746
|
+
* }
|
|
747
|
+
* `;
|
|
748
|
+
*
|
|
749
|
+
* const client = new ApolloClient({
|
|
750
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
751
|
+
* cache: new InMemoryCache(),
|
|
752
|
+
* });
|
|
753
|
+
*
|
|
754
|
+
* function SuspenseFallback() {
|
|
755
|
+
* return <div>Loading...</div>;
|
|
756
|
+
* }
|
|
757
|
+
*
|
|
758
|
+
* function Child({ queryRef }) {
|
|
759
|
+
* const { data } = useReadQuery(queryRef);
|
|
760
|
+
*
|
|
761
|
+
* return <div>{data.foo.bar}</div>;
|
|
762
|
+
* }
|
|
763
|
+
*
|
|
764
|
+
* function Parent() {
|
|
765
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
766
|
+
*
|
|
767
|
+
* return (
|
|
768
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
769
|
+
* <Child queryRef={queryRef} />
|
|
770
|
+
* </Suspense>
|
|
771
|
+
* );
|
|
772
|
+
* }
|
|
773
|
+
*
|
|
774
|
+
* function App() {
|
|
775
|
+
* return (
|
|
776
|
+
* <ApolloProvider client={client}>
|
|
777
|
+
* <Parent />
|
|
778
|
+
* </ApolloProvider>
|
|
779
|
+
* );
|
|
780
|
+
* }
|
|
781
|
+
* ```
|
|
782
|
+
*
|
|
783
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
784
|
+
* @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.
|
|
785
|
+
*/
|
|
786
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
787
|
+
skip: boolean;
|
|
788
|
+
returnPartialData: boolean;
|
|
789
|
+
}): [
|
|
790
|
+
(QueryRef<TData, TVariables, "complete" | "streaming" | "partial"> | undefined),
|
|
791
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
792
|
+
];
|
|
793
|
+
/**
|
|
794
|
+
* @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
|
|
795
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
796
|
+
*
|
|
797
|
+
*
|
|
798
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
799
|
+
*
|
|
800
|
+
* @returns A tuple containing:
|
|
801
|
+
*
|
|
802
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
803
|
+
* 2. An object containing helper functions for the query:
|
|
804
|
+
* - `refetch`: A function to re-execute the query
|
|
805
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
806
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
807
|
+
*
|
|
808
|
+
* @example
|
|
809
|
+
*
|
|
810
|
+
* ```jsx
|
|
811
|
+
* import { Suspense } from "react";
|
|
812
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
813
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
814
|
+
*
|
|
815
|
+
* const query = gql`
|
|
816
|
+
* foo {
|
|
817
|
+
* bar
|
|
818
|
+
* }
|
|
819
|
+
* `;
|
|
820
|
+
*
|
|
821
|
+
* const client = new ApolloClient({
|
|
822
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
823
|
+
* cache: new InMemoryCache(),
|
|
824
|
+
* });
|
|
825
|
+
*
|
|
826
|
+
* function SuspenseFallback() {
|
|
827
|
+
* return <div>Loading...</div>;
|
|
828
|
+
* }
|
|
829
|
+
*
|
|
830
|
+
* function Child({ queryRef }) {
|
|
831
|
+
* const { data } = useReadQuery(queryRef);
|
|
832
|
+
*
|
|
833
|
+
* return <div>{data.foo.bar}</div>;
|
|
834
|
+
* }
|
|
835
|
+
*
|
|
836
|
+
* function Parent() {
|
|
837
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
838
|
+
*
|
|
839
|
+
* return (
|
|
840
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
841
|
+
* <Child queryRef={queryRef} />
|
|
842
|
+
* </Suspense>
|
|
843
|
+
* );
|
|
844
|
+
* }
|
|
845
|
+
*
|
|
846
|
+
* function App() {
|
|
847
|
+
* return (
|
|
848
|
+
* <ApolloProvider client={client}>
|
|
849
|
+
* <Parent />
|
|
850
|
+
* </ApolloProvider>
|
|
851
|
+
* );
|
|
852
|
+
* }
|
|
853
|
+
* ```
|
|
854
|
+
*
|
|
855
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
856
|
+
* @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.
|
|
857
|
+
*/
|
|
858
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
859
|
+
returnPartialData: false;
|
|
860
|
+
}): [
|
|
861
|
+
QueryRef<TData, TVariables, "complete" | "streaming">,
|
|
862
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
863
|
+
];
|
|
864
|
+
/**
|
|
865
|
+
* @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
|
|
866
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
867
|
+
*
|
|
868
|
+
*
|
|
869
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
870
|
+
*
|
|
871
|
+
* @returns A tuple containing:
|
|
872
|
+
*
|
|
873
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
874
|
+
* 2. An object containing helper functions for the query:
|
|
875
|
+
* - `refetch`: A function to re-execute the query
|
|
876
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
877
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
878
|
+
*
|
|
879
|
+
* @example
|
|
880
|
+
*
|
|
881
|
+
* ```jsx
|
|
882
|
+
* import { Suspense } from "react";
|
|
883
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
884
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
885
|
+
*
|
|
886
|
+
* const query = gql`
|
|
887
|
+
* foo {
|
|
888
|
+
* bar
|
|
889
|
+
* }
|
|
890
|
+
* `;
|
|
891
|
+
*
|
|
892
|
+
* const client = new ApolloClient({
|
|
893
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
894
|
+
* cache: new InMemoryCache(),
|
|
895
|
+
* });
|
|
896
|
+
*
|
|
897
|
+
* function SuspenseFallback() {
|
|
898
|
+
* return <div>Loading...</div>;
|
|
899
|
+
* }
|
|
900
|
+
*
|
|
901
|
+
* function Child({ queryRef }) {
|
|
902
|
+
* const { data } = useReadQuery(queryRef);
|
|
903
|
+
*
|
|
904
|
+
* return <div>{data.foo.bar}</div>;
|
|
905
|
+
* }
|
|
906
|
+
*
|
|
907
|
+
* function Parent() {
|
|
908
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
909
|
+
*
|
|
910
|
+
* return (
|
|
911
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
912
|
+
* <Child queryRef={queryRef} />
|
|
913
|
+
* </Suspense>
|
|
914
|
+
* );
|
|
915
|
+
* }
|
|
916
|
+
*
|
|
917
|
+
* function App() {
|
|
918
|
+
* return (
|
|
919
|
+
* <ApolloProvider client={client}>
|
|
920
|
+
* <Parent />
|
|
921
|
+
* </ApolloProvider>
|
|
922
|
+
* );
|
|
923
|
+
* }
|
|
924
|
+
* ```
|
|
925
|
+
*
|
|
926
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
927
|
+
* @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.
|
|
928
|
+
*/
|
|
929
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
930
|
+
returnPartialData: boolean;
|
|
931
|
+
}): [
|
|
932
|
+
QueryRef<TData, TVariables, "complete" | "streaming" | "partial">,
|
|
933
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
934
|
+
];
|
|
935
|
+
/**
|
|
936
|
+
* @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
|
|
937
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
938
|
+
*
|
|
939
|
+
*
|
|
940
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
941
|
+
*
|
|
942
|
+
* @returns A tuple containing:
|
|
943
|
+
*
|
|
944
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
945
|
+
* 2. An object containing helper functions for the query:
|
|
946
|
+
* - `refetch`: A function to re-execute the query
|
|
947
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
948
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
949
|
+
*
|
|
950
|
+
* @example
|
|
951
|
+
*
|
|
952
|
+
* ```jsx
|
|
953
|
+
* import { Suspense } from "react";
|
|
954
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
955
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
956
|
+
*
|
|
957
|
+
* const query = gql`
|
|
958
|
+
* foo {
|
|
959
|
+
* bar
|
|
960
|
+
* }
|
|
961
|
+
* `;
|
|
962
|
+
*
|
|
963
|
+
* const client = new ApolloClient({
|
|
964
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
965
|
+
* cache: new InMemoryCache(),
|
|
966
|
+
* });
|
|
967
|
+
*
|
|
968
|
+
* function SuspenseFallback() {
|
|
969
|
+
* return <div>Loading...</div>;
|
|
970
|
+
* }
|
|
971
|
+
*
|
|
972
|
+
* function Child({ queryRef }) {
|
|
973
|
+
* const { data } = useReadQuery(queryRef);
|
|
974
|
+
*
|
|
975
|
+
* return <div>{data.foo.bar}</div>;
|
|
976
|
+
* }
|
|
977
|
+
*
|
|
978
|
+
* function Parent() {
|
|
979
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
980
|
+
*
|
|
981
|
+
* return (
|
|
982
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
983
|
+
* <Child queryRef={queryRef} />
|
|
984
|
+
* </Suspense>
|
|
985
|
+
* );
|
|
986
|
+
* }
|
|
987
|
+
*
|
|
988
|
+
* function App() {
|
|
989
|
+
* return (
|
|
990
|
+
* <ApolloProvider client={client}>
|
|
991
|
+
* <Parent />
|
|
992
|
+
* </ApolloProvider>
|
|
993
|
+
* );
|
|
994
|
+
* }
|
|
995
|
+
* ```
|
|
996
|
+
*
|
|
997
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
998
|
+
* @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.
|
|
999
|
+
*/
|
|
1000
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
1001
|
+
skip: boolean;
|
|
1002
|
+
}): [
|
|
1003
|
+
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
1004
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
1005
|
+
];
|
|
1006
|
+
/**
|
|
1007
|
+
* @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
|
|
1008
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
1009
|
+
*
|
|
1010
|
+
*
|
|
1011
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
1012
|
+
*
|
|
1013
|
+
* @returns A tuple containing:
|
|
1014
|
+
*
|
|
1015
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
1016
|
+
* 2. An object containing helper functions for the query:
|
|
1017
|
+
* - `refetch`: A function to re-execute the query
|
|
1018
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
1019
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
1020
|
+
*
|
|
1021
|
+
* @example
|
|
1022
|
+
*
|
|
1023
|
+
* ```jsx
|
|
1024
|
+
* import { Suspense } from "react";
|
|
1025
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
1026
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
1027
|
+
*
|
|
1028
|
+
* const query = gql`
|
|
1029
|
+
* foo {
|
|
1030
|
+
* bar
|
|
1031
|
+
* }
|
|
1032
|
+
* `;
|
|
1033
|
+
*
|
|
1034
|
+
* const client = new ApolloClient({
|
|
1035
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
1036
|
+
* cache: new InMemoryCache(),
|
|
1037
|
+
* });
|
|
1038
|
+
*
|
|
1039
|
+
* function SuspenseFallback() {
|
|
1040
|
+
* return <div>Loading...</div>;
|
|
1041
|
+
* }
|
|
1042
|
+
*
|
|
1043
|
+
* function Child({ queryRef }) {
|
|
1044
|
+
* const { data } = useReadQuery(queryRef);
|
|
1045
|
+
*
|
|
1046
|
+
* return <div>{data.foo.bar}</div>;
|
|
1047
|
+
* }
|
|
1048
|
+
*
|
|
1049
|
+
* function Parent() {
|
|
1050
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
1051
|
+
*
|
|
1052
|
+
* return (
|
|
1053
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
1054
|
+
* <Child queryRef={queryRef} />
|
|
1055
|
+
* </Suspense>
|
|
1056
|
+
* );
|
|
1057
|
+
* }
|
|
1058
|
+
*
|
|
1059
|
+
* function App() {
|
|
1060
|
+
* return (
|
|
1061
|
+
* <ApolloProvider client={client}>
|
|
1062
|
+
* <Parent />
|
|
1063
|
+
* </ApolloProvider>
|
|
1064
|
+
* );
|
|
1065
|
+
* }
|
|
1066
|
+
* ```
|
|
1067
|
+
*
|
|
1068
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1069
|
+
* @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.
|
|
1070
|
+
*/
|
|
1071
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken): [undefined, useBackgroundQuery.Result<TData, TVariables>];
|
|
1072
|
+
/**
|
|
1073
|
+
* @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
|
|
1074
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
1075
|
+
*
|
|
1076
|
+
*
|
|
1077
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
1078
|
+
*
|
|
1079
|
+
* @returns A tuple containing:
|
|
1080
|
+
*
|
|
1081
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
1082
|
+
* 2. An object containing helper functions for the query:
|
|
1083
|
+
* - `refetch`: A function to re-execute the query
|
|
1084
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
1085
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
1086
|
+
*
|
|
1087
|
+
* @example
|
|
1088
|
+
*
|
|
1089
|
+
* ```jsx
|
|
1090
|
+
* import { Suspense } from "react";
|
|
1091
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
1092
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
1093
|
+
*
|
|
1094
|
+
* const query = gql`
|
|
1095
|
+
* foo {
|
|
1096
|
+
* bar
|
|
1097
|
+
* }
|
|
1098
|
+
* `;
|
|
1099
|
+
*
|
|
1100
|
+
* const client = new ApolloClient({
|
|
1101
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
1102
|
+
* cache: new InMemoryCache(),
|
|
1103
|
+
* });
|
|
1104
|
+
*
|
|
1105
|
+
* function SuspenseFallback() {
|
|
1106
|
+
* return <div>Loading...</div>;
|
|
1107
|
+
* }
|
|
1108
|
+
*
|
|
1109
|
+
* function Child({ queryRef }) {
|
|
1110
|
+
* const { data } = useReadQuery(queryRef);
|
|
1111
|
+
*
|
|
1112
|
+
* return <div>{data.foo.bar}</div>;
|
|
1113
|
+
* }
|
|
1114
|
+
*
|
|
1115
|
+
* function Parent() {
|
|
1116
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
1117
|
+
*
|
|
1118
|
+
* return (
|
|
1119
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
1120
|
+
* <Child queryRef={queryRef} />
|
|
1121
|
+
* </Suspense>
|
|
1122
|
+
* );
|
|
1123
|
+
* }
|
|
1124
|
+
*
|
|
1125
|
+
* function App() {
|
|
1126
|
+
* return (
|
|
1127
|
+
* <ApolloProvider client={client}>
|
|
1128
|
+
* <Parent />
|
|
1129
|
+
* </ApolloProvider>
|
|
1130
|
+
* );
|
|
1131
|
+
* }
|
|
1132
|
+
* ```
|
|
1133
|
+
*
|
|
1134
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1135
|
+
* @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.
|
|
1136
|
+
*/
|
|
1137
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
1138
|
+
returnPartialData: false;
|
|
1139
|
+
})): [
|
|
1140
|
+
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
1141
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
1142
|
+
];
|
|
1143
|
+
/**
|
|
1144
|
+
* @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
|
|
1145
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
1146
|
+
*
|
|
1147
|
+
*
|
|
1148
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
1149
|
+
*
|
|
1150
|
+
* @returns A tuple containing:
|
|
1151
|
+
*
|
|
1152
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
1153
|
+
* 2. An object containing helper functions for the query:
|
|
1154
|
+
* - `refetch`: A function to re-execute the query
|
|
1155
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
1156
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
1157
|
+
*
|
|
1158
|
+
* @example
|
|
1159
|
+
*
|
|
1160
|
+
* ```jsx
|
|
1161
|
+
* import { Suspense } from "react";
|
|
1162
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
1163
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
1164
|
+
*
|
|
1165
|
+
* const query = gql`
|
|
1166
|
+
* foo {
|
|
1167
|
+
* bar
|
|
1168
|
+
* }
|
|
1169
|
+
* `;
|
|
1170
|
+
*
|
|
1171
|
+
* const client = new ApolloClient({
|
|
1172
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
1173
|
+
* cache: new InMemoryCache(),
|
|
1174
|
+
* });
|
|
1175
|
+
*
|
|
1176
|
+
* function SuspenseFallback() {
|
|
1177
|
+
* return <div>Loading...</div>;
|
|
1178
|
+
* }
|
|
1179
|
+
*
|
|
1180
|
+
* function Child({ queryRef }) {
|
|
1181
|
+
* const { data } = useReadQuery(queryRef);
|
|
1182
|
+
*
|
|
1183
|
+
* return <div>{data.foo.bar}</div>;
|
|
1184
|
+
* }
|
|
1185
|
+
*
|
|
1186
|
+
* function Parent() {
|
|
1187
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
1188
|
+
*
|
|
1189
|
+
* return (
|
|
1190
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
1191
|
+
* <Child queryRef={queryRef} />
|
|
1192
|
+
* </Suspense>
|
|
1193
|
+
* );
|
|
1194
|
+
* }
|
|
1195
|
+
*
|
|
1196
|
+
* function App() {
|
|
1197
|
+
* return (
|
|
1198
|
+
* <ApolloProvider client={client}>
|
|
1199
|
+
* <Parent />
|
|
1200
|
+
* </ApolloProvider>
|
|
1201
|
+
* );
|
|
1202
|
+
* }
|
|
1203
|
+
* ```
|
|
1204
|
+
*
|
|
1205
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1206
|
+
* @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.
|
|
1207
|
+
*/
|
|
1208
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
1209
|
+
returnPartialData: boolean;
|
|
1210
|
+
})): [
|
|
1211
|
+
(QueryRef<TData, TVariables, "complete" | "streaming" | "partial"> | undefined),
|
|
1212
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
1213
|
+
];
|
|
1214
|
+
/**
|
|
1215
|
+
* @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
|
|
1216
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
1217
|
+
*
|
|
1218
|
+
*
|
|
1219
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
1220
|
+
*
|
|
1221
|
+
* @returns A tuple containing:
|
|
1222
|
+
*
|
|
1223
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
1224
|
+
* 2. An object containing helper functions for the query:
|
|
1225
|
+
* - `refetch`: A function to re-execute the query
|
|
1226
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
1227
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
1228
|
+
*
|
|
1229
|
+
* @example
|
|
1230
|
+
*
|
|
1231
|
+
* ```jsx
|
|
1232
|
+
* import { Suspense } from "react";
|
|
1233
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
1234
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
1235
|
+
*
|
|
1236
|
+
* const query = gql`
|
|
1237
|
+
* foo {
|
|
1238
|
+
* bar
|
|
1239
|
+
* }
|
|
1240
|
+
* `;
|
|
1241
|
+
*
|
|
1242
|
+
* const client = new ApolloClient({
|
|
1243
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
1244
|
+
* cache: new InMemoryCache(),
|
|
1245
|
+
* });
|
|
1246
|
+
*
|
|
1247
|
+
* function SuspenseFallback() {
|
|
1248
|
+
* return <div>Loading...</div>;
|
|
1249
|
+
* }
|
|
1250
|
+
*
|
|
1251
|
+
* function Child({ queryRef }) {
|
|
1252
|
+
* const { data } = useReadQuery(queryRef);
|
|
1253
|
+
*
|
|
1254
|
+
* return <div>{data.foo.bar}</div>;
|
|
1255
|
+
* }
|
|
1256
|
+
*
|
|
1257
|
+
* function Parent() {
|
|
1258
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
1259
|
+
*
|
|
1260
|
+
* return (
|
|
1261
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
1262
|
+
* <Child queryRef={queryRef} />
|
|
1263
|
+
* </Suspense>
|
|
1264
|
+
* );
|
|
1265
|
+
* }
|
|
1266
|
+
*
|
|
1267
|
+
* function App() {
|
|
1268
|
+
* return (
|
|
1269
|
+
* <ApolloProvider client={client}>
|
|
1270
|
+
* <Parent />
|
|
1271
|
+
* </ApolloProvider>
|
|
1272
|
+
* );
|
|
1273
|
+
* }
|
|
1274
|
+
* ```
|
|
1275
|
+
*
|
|
1276
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1277
|
+
* @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.
|
|
1278
|
+
*/
|
|
1279
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
|
|
1280
|
+
options?: useBackgroundQuery.Options<NoInfer<TVariables>>
|
|
1281
|
+
] : [options: useBackgroundQuery.Options<NoInfer<TVariables>>]): [
|
|
1282
|
+
QueryRef<TData, TVariables, "complete" | "streaming">,
|
|
1283
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
1284
|
+
];
|
|
1285
|
+
/**
|
|
1286
|
+
* @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
|
|
1287
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
1288
|
+
*
|
|
1289
|
+
*
|
|
1290
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
1291
|
+
*
|
|
1292
|
+
* @returns A tuple containing:
|
|
1293
|
+
*
|
|
1294
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
1295
|
+
* 2. An object containing helper functions for the query:
|
|
1296
|
+
* - `refetch`: A function to re-execute the query
|
|
1297
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
1298
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
1299
|
+
*
|
|
1300
|
+
* @example
|
|
1301
|
+
*
|
|
1302
|
+
* ```jsx
|
|
1303
|
+
* import { Suspense } from "react";
|
|
1304
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
1305
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
1306
|
+
*
|
|
1307
|
+
* const query = gql`
|
|
1308
|
+
* foo {
|
|
1309
|
+
* bar
|
|
1310
|
+
* }
|
|
1311
|
+
* `;
|
|
1312
|
+
*
|
|
1313
|
+
* const client = new ApolloClient({
|
|
1314
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
1315
|
+
* cache: new InMemoryCache(),
|
|
1316
|
+
* });
|
|
1317
|
+
*
|
|
1318
|
+
* function SuspenseFallback() {
|
|
1319
|
+
* return <div>Loading...</div>;
|
|
1320
|
+
* }
|
|
1321
|
+
*
|
|
1322
|
+
* function Child({ queryRef }) {
|
|
1323
|
+
* const { data } = useReadQuery(queryRef);
|
|
1324
|
+
*
|
|
1325
|
+
* return <div>{data.foo.bar}</div>;
|
|
1326
|
+
* }
|
|
1327
|
+
*
|
|
1328
|
+
* function Parent() {
|
|
1329
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
1330
|
+
*
|
|
1331
|
+
* return (
|
|
1332
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
1333
|
+
* <Child queryRef={queryRef} />
|
|
1334
|
+
* </Suspense>
|
|
1335
|
+
* );
|
|
1336
|
+
* }
|
|
1337
|
+
*
|
|
1338
|
+
* function App() {
|
|
1339
|
+
* return (
|
|
1340
|
+
* <ApolloProvider client={client}>
|
|
1341
|
+
* <Parent />
|
|
1342
|
+
* </ApolloProvider>
|
|
1343
|
+
* );
|
|
1344
|
+
* }
|
|
1345
|
+
* ```
|
|
1346
|
+
*
|
|
1347
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1348
|
+
* @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.
|
|
1349
|
+
*/
|
|
1350
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
|
|
1351
|
+
options?: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>
|
|
1352
|
+
] : [options: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>]): [
|
|
1353
|
+
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
1354
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
1355
|
+
];
|
|
1356
|
+
/**
|
|
1357
|
+
* @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
|
|
1358
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
1359
|
+
*
|
|
1360
|
+
*
|
|
1361
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
1362
|
+
*
|
|
1363
|
+
* @returns A tuple containing:
|
|
1364
|
+
*
|
|
1365
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
1366
|
+
* 2. An object containing helper functions for the query:
|
|
1367
|
+
* - `refetch`: A function to re-execute the query
|
|
1368
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
1369
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
1370
|
+
*
|
|
1371
|
+
* @example
|
|
1372
|
+
*
|
|
1373
|
+
* ```jsx
|
|
1374
|
+
* import { Suspense } from "react";
|
|
1375
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
1376
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
1377
|
+
*
|
|
1378
|
+
* const query = gql`
|
|
1379
|
+
* foo {
|
|
1380
|
+
* bar
|
|
1381
|
+
* }
|
|
1382
|
+
* `;
|
|
1383
|
+
*
|
|
1384
|
+
* const client = new ApolloClient({
|
|
1385
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
1386
|
+
* cache: new InMemoryCache(),
|
|
1387
|
+
* });
|
|
1388
|
+
*
|
|
1389
|
+
* function SuspenseFallback() {
|
|
1390
|
+
* return <div>Loading...</div>;
|
|
1391
|
+
* }
|
|
1392
|
+
*
|
|
1393
|
+
* function Child({ queryRef }) {
|
|
1394
|
+
* const { data } = useReadQuery(queryRef);
|
|
1395
|
+
*
|
|
1396
|
+
* return <div>{data.foo.bar}</div>;
|
|
1397
|
+
* }
|
|
1398
|
+
*
|
|
1399
|
+
* function Parent() {
|
|
1400
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
1401
|
+
*
|
|
1402
|
+
* return (
|
|
1403
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
1404
|
+
* <Child queryRef={queryRef} />
|
|
1405
|
+
* </Suspense>
|
|
1406
|
+
* );
|
|
1407
|
+
* }
|
|
1408
|
+
*
|
|
1409
|
+
* function App() {
|
|
1410
|
+
* return (
|
|
1411
|
+
* <ApolloProvider client={client}>
|
|
1412
|
+
* <Parent />
|
|
1413
|
+
* </ApolloProvider>
|
|
1414
|
+
* );
|
|
1415
|
+
* }
|
|
1416
|
+
* ```
|
|
1417
|
+
*
|
|
1418
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1419
|
+
* @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.
|
|
1420
|
+
*/
|
|
1421
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>): [
|
|
1422
|
+
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
1423
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
1424
|
+
];
|
|
1425
|
+
}
|
|
1426
|
+
/**
|
|
1427
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
1428
|
+
*
|
|
1429
|
+
* @returns A tuple containing:
|
|
1430
|
+
*
|
|
1431
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
1432
|
+
* 2. An object containing helper functions for the query:
|
|
1433
|
+
* - `refetch`: A function to re-execute the query
|
|
1434
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
1435
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
1436
|
+
*
|
|
1437
|
+
* @example
|
|
1438
|
+
*
|
|
1439
|
+
* ```jsx
|
|
1440
|
+
* import { Suspense } from "react";
|
|
1441
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
1442
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
1443
|
+
*
|
|
1444
|
+
* const query = gql`
|
|
1445
|
+
* foo {
|
|
1446
|
+
* bar
|
|
1447
|
+
* }
|
|
1448
|
+
* `;
|
|
1449
|
+
*
|
|
1450
|
+
* const client = new ApolloClient({
|
|
1451
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
1452
|
+
* cache: new InMemoryCache(),
|
|
1453
|
+
* });
|
|
1454
|
+
*
|
|
1455
|
+
* function SuspenseFallback() {
|
|
1456
|
+
* return <div>Loading...</div>;
|
|
1457
|
+
* }
|
|
1458
|
+
*
|
|
1459
|
+
* function Child({ queryRef }) {
|
|
1460
|
+
* const { data } = useReadQuery(queryRef);
|
|
1461
|
+
*
|
|
1462
|
+
* return <div>{data.foo.bar}</div>;
|
|
1463
|
+
* }
|
|
1464
|
+
*
|
|
1465
|
+
* function Parent() {
|
|
1466
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
1467
|
+
*
|
|
1468
|
+
* return (
|
|
1469
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
1470
|
+
* <Child queryRef={queryRef} />
|
|
1471
|
+
* </Suspense>
|
|
1472
|
+
* );
|
|
1473
|
+
* }
|
|
1474
|
+
*
|
|
1475
|
+
* function App() {
|
|
1476
|
+
* return (
|
|
1477
|
+
* <ApolloProvider client={client}>
|
|
1478
|
+
* <Parent />
|
|
1479
|
+
* </ApolloProvider>
|
|
1480
|
+
* );
|
|
1481
|
+
* }
|
|
1482
|
+
* ```
|
|
1483
|
+
*
|
|
1484
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1485
|
+
* @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.
|
|
1486
|
+
*/
|
|
1487
|
+
interface Modern {
|
|
1488
|
+
/**
|
|
1489
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
1490
|
+
*
|
|
1491
|
+
* @returns A tuple containing:
|
|
1492
|
+
*
|
|
1493
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
1494
|
+
* 2. An object containing helper functions for the query:
|
|
1495
|
+
* - `refetch`: A function to re-execute the query
|
|
1496
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
1497
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
1498
|
+
*
|
|
1499
|
+
* @example
|
|
1500
|
+
*
|
|
1501
|
+
* ```jsx
|
|
1502
|
+
* import { Suspense } from "react";
|
|
1503
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
1504
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
1505
|
+
*
|
|
1506
|
+
* const query = gql`
|
|
1507
|
+
* foo {
|
|
1508
|
+
* bar
|
|
1509
|
+
* }
|
|
1510
|
+
* `;
|
|
1511
|
+
*
|
|
1512
|
+
* const client = new ApolloClient({
|
|
1513
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
1514
|
+
* cache: new InMemoryCache(),
|
|
1515
|
+
* });
|
|
1516
|
+
*
|
|
1517
|
+
* function SuspenseFallback() {
|
|
1518
|
+
* return <div>Loading...</div>;
|
|
1519
|
+
* }
|
|
1520
|
+
*
|
|
1521
|
+
* function Child({ queryRef }) {
|
|
1522
|
+
* const { data } = useReadQuery(queryRef);
|
|
1523
|
+
*
|
|
1524
|
+
* return <div>{data.foo.bar}</div>;
|
|
1525
|
+
* }
|
|
1526
|
+
*
|
|
1527
|
+
* function Parent() {
|
|
1528
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
1529
|
+
*
|
|
1530
|
+
* return (
|
|
1531
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
1532
|
+
* <Child queryRef={queryRef} />
|
|
1533
|
+
* </Suspense>
|
|
1534
|
+
* );
|
|
1535
|
+
* }
|
|
1536
|
+
*
|
|
1537
|
+
* function App() {
|
|
1538
|
+
* return (
|
|
1539
|
+
* <ApolloProvider client={client}>
|
|
1540
|
+
* <Parent />
|
|
1541
|
+
* </ApolloProvider>
|
|
1542
|
+
* );
|
|
1543
|
+
* }
|
|
1544
|
+
* ```
|
|
1545
|
+
*
|
|
1546
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1547
|
+
* @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.
|
|
1548
|
+
*/
|
|
1549
|
+
<TData, TVariables extends OperationVariables, TOptions extends never>(query: {} extends TVariables ? DocumentNode | TypedDocumentNode<TData, TVariables> : never): useBackgroundQuery.ResultForOptions<TData, TVariables, Record<string, never>>;
|
|
1550
|
+
/**
|
|
1551
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
1552
|
+
*
|
|
1553
|
+
* @returns A tuple containing:
|
|
1554
|
+
*
|
|
1555
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
1556
|
+
* 2. An object containing helper functions for the query:
|
|
1557
|
+
* - `refetch`: A function to re-execute the query
|
|
1558
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
1559
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
1560
|
+
*
|
|
1561
|
+
* @example
|
|
1562
|
+
*
|
|
1563
|
+
* ```jsx
|
|
1564
|
+
* import { Suspense } from "react";
|
|
1565
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
1566
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
1567
|
+
*
|
|
1568
|
+
* const query = gql`
|
|
1569
|
+
* foo {
|
|
1570
|
+
* bar
|
|
1571
|
+
* }
|
|
1572
|
+
* `;
|
|
1573
|
+
*
|
|
1574
|
+
* const client = new ApolloClient({
|
|
1575
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
1576
|
+
* cache: new InMemoryCache(),
|
|
1577
|
+
* });
|
|
1578
|
+
*
|
|
1579
|
+
* function SuspenseFallback() {
|
|
1580
|
+
* return <div>Loading...</div>;
|
|
1581
|
+
* }
|
|
1582
|
+
*
|
|
1583
|
+
* function Child({ queryRef }) {
|
|
1584
|
+
* const { data } = useReadQuery(queryRef);
|
|
1585
|
+
*
|
|
1586
|
+
* return <div>{data.foo.bar}</div>;
|
|
1587
|
+
* }
|
|
1588
|
+
*
|
|
1589
|
+
* function Parent() {
|
|
1590
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
1591
|
+
*
|
|
1592
|
+
* return (
|
|
1593
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
1594
|
+
* <Child queryRef={queryRef} />
|
|
1595
|
+
* </Suspense>
|
|
1596
|
+
* );
|
|
1597
|
+
* }
|
|
1598
|
+
*
|
|
1599
|
+
* function App() {
|
|
1600
|
+
* return (
|
|
1601
|
+
* <ApolloProvider client={client}>
|
|
1602
|
+
* <Parent />
|
|
1603
|
+
* </ApolloProvider>
|
|
1604
|
+
* );
|
|
1605
|
+
* }
|
|
1606
|
+
* ```
|
|
1607
|
+
*
|
|
1608
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1609
|
+
* @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.
|
|
1610
|
+
*/
|
|
1611
|
+
<TData, TVariables extends OperationVariables, TOptions extends never>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, skipToken: SkipToken): useBackgroundQuery.ResultForOptions<TData, TVariables, SkipToken>;
|
|
1612
|
+
/**
|
|
1613
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
1614
|
+
*
|
|
1615
|
+
* @returns A tuple containing:
|
|
1616
|
+
*
|
|
1617
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
1618
|
+
* 2. An object containing helper functions for the query:
|
|
1619
|
+
* - `refetch`: A function to re-execute the query
|
|
1620
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
1621
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
1622
|
+
*
|
|
1623
|
+
* @example
|
|
1624
|
+
*
|
|
1625
|
+
* ```jsx
|
|
1626
|
+
* import { Suspense } from "react";
|
|
1627
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
1628
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
1629
|
+
*
|
|
1630
|
+
* const query = gql`
|
|
1631
|
+
* foo {
|
|
1632
|
+
* bar
|
|
1633
|
+
* }
|
|
1634
|
+
* `;
|
|
1635
|
+
*
|
|
1636
|
+
* const client = new ApolloClient({
|
|
1637
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
1638
|
+
* cache: new InMemoryCache(),
|
|
1639
|
+
* });
|
|
1640
|
+
*
|
|
1641
|
+
* function SuspenseFallback() {
|
|
1642
|
+
* return <div>Loading...</div>;
|
|
1643
|
+
* }
|
|
1644
|
+
*
|
|
1645
|
+
* function Child({ queryRef }) {
|
|
1646
|
+
* const { data } = useReadQuery(queryRef);
|
|
1647
|
+
*
|
|
1648
|
+
* return <div>{data.foo.bar}</div>;
|
|
1649
|
+
* }
|
|
1650
|
+
*
|
|
1651
|
+
* function Parent() {
|
|
1652
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
1653
|
+
*
|
|
1654
|
+
* return (
|
|
1655
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
1656
|
+
* <Child queryRef={queryRef} />
|
|
1657
|
+
* </Suspense>
|
|
1658
|
+
* );
|
|
1659
|
+
* }
|
|
1660
|
+
*
|
|
1661
|
+
* function App() {
|
|
1662
|
+
* return (
|
|
1663
|
+
* <ApolloProvider client={client}>
|
|
1664
|
+
* <Parent />
|
|
1665
|
+
* </ApolloProvider>
|
|
1666
|
+
* );
|
|
1667
|
+
* }
|
|
1668
|
+
* ```
|
|
1669
|
+
*
|
|
1670
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1671
|
+
* @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.
|
|
1672
|
+
*/
|
|
1673
|
+
<TData, TVariables extends OperationVariables, TOptions extends useBackgroundQuery.Options<NoInfer<TVariables>> & VariablesOption<TVariables & {
|
|
1674
|
+
[K in Exclude<keyof TOptions["variables"], keyof TVariables>]?: never;
|
|
1675
|
+
}>>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [options?: TOptions] : [options: TOptions]): useBackgroundQuery.ResultForOptions<TData, TVariables, TOptions>;
|
|
1676
|
+
/**
|
|
1677
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
1678
|
+
*
|
|
1679
|
+
* @returns A tuple containing:
|
|
1680
|
+
*
|
|
1681
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
1682
|
+
* 2. An object containing helper functions for the query:
|
|
1683
|
+
* - `refetch`: A function to re-execute the query
|
|
1684
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
1685
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
1686
|
+
*
|
|
1687
|
+
* @example
|
|
1688
|
+
*
|
|
1689
|
+
* ```jsx
|
|
1690
|
+
* import { Suspense } from "react";
|
|
1691
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
1692
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
1693
|
+
*
|
|
1694
|
+
* const query = gql`
|
|
1695
|
+
* foo {
|
|
1696
|
+
* bar
|
|
1697
|
+
* }
|
|
1698
|
+
* `;
|
|
1699
|
+
*
|
|
1700
|
+
* const client = new ApolloClient({
|
|
1701
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
1702
|
+
* cache: new InMemoryCache(),
|
|
1703
|
+
* });
|
|
1704
|
+
*
|
|
1705
|
+
* function SuspenseFallback() {
|
|
1706
|
+
* return <div>Loading...</div>;
|
|
1707
|
+
* }
|
|
1708
|
+
*
|
|
1709
|
+
* function Child({ queryRef }) {
|
|
1710
|
+
* const { data } = useReadQuery(queryRef);
|
|
1711
|
+
*
|
|
1712
|
+
* return <div>{data.foo.bar}</div>;
|
|
1713
|
+
* }
|
|
1714
|
+
*
|
|
1715
|
+
* function Parent() {
|
|
1716
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
1717
|
+
*
|
|
1718
|
+
* return (
|
|
1719
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
1720
|
+
* <Child queryRef={queryRef} />
|
|
1721
|
+
* </Suspense>
|
|
1722
|
+
* );
|
|
1723
|
+
* }
|
|
1724
|
+
*
|
|
1725
|
+
* function App() {
|
|
1726
|
+
* return (
|
|
1727
|
+
* <ApolloProvider client={client}>
|
|
1728
|
+
* <Parent />
|
|
1729
|
+
* </ApolloProvider>
|
|
1730
|
+
* );
|
|
1731
|
+
* }
|
|
1732
|
+
* ```
|
|
1733
|
+
*
|
|
1734
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1735
|
+
* @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.
|
|
1736
|
+
*/
|
|
1737
|
+
<TData, TVariables extends OperationVariables, TOptions extends useBackgroundQuery.Options<NoInfer<TVariables>> & VariablesOption<TVariables & {
|
|
1738
|
+
[K in Exclude<keyof TOptions["variables"], keyof TVariables>]?: never;
|
|
1739
|
+
}>>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [options?: TOptions | SkipToken] : [options: TOptions | SkipToken]): useBackgroundQuery.ResultForOptions<TData, TVariables, TOptions | SkipToken>;
|
|
1740
|
+
}
|
|
1741
|
+
type Evaluated = SignatureStyle extends "classic" ? Classic : Modern;
|
|
1742
|
+
}
|
|
1743
|
+
/**
|
|
1744
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
1745
|
+
*
|
|
1746
|
+
* @returns A tuple containing:
|
|
1747
|
+
*
|
|
1748
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
1749
|
+
* 2. An object containing helper functions for the query:
|
|
1750
|
+
* - `refetch`: A function to re-execute the query
|
|
1751
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
1752
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
1753
|
+
*
|
|
1754
|
+
* @example
|
|
1755
|
+
*
|
|
1756
|
+
* ```jsx
|
|
1757
|
+
* import { Suspense } from "react";
|
|
1758
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
1759
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
1760
|
+
*
|
|
1761
|
+
* const query = gql`
|
|
1762
|
+
* foo {
|
|
1763
|
+
* bar
|
|
1764
|
+
* }
|
|
1765
|
+
* `;
|
|
1766
|
+
*
|
|
1767
|
+
* const client = new ApolloClient({
|
|
1768
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
1769
|
+
* cache: new InMemoryCache(),
|
|
1770
|
+
* });
|
|
1771
|
+
*
|
|
1772
|
+
* function SuspenseFallback() {
|
|
1773
|
+
* return <div>Loading...</div>;
|
|
1774
|
+
* }
|
|
1775
|
+
*
|
|
1776
|
+
* function Child({ queryRef }) {
|
|
1777
|
+
* const { data } = useReadQuery(queryRef);
|
|
1778
|
+
*
|
|
1779
|
+
* return <div>{data.foo.bar}</div>;
|
|
1780
|
+
* }
|
|
1781
|
+
*
|
|
1782
|
+
* function Parent() {
|
|
1783
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
1784
|
+
*
|
|
1785
|
+
* return (
|
|
1786
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
1787
|
+
* <Child queryRef={queryRef} />
|
|
1788
|
+
* </Suspense>
|
|
1789
|
+
* );
|
|
1790
|
+
* }
|
|
1791
|
+
*
|
|
1792
|
+
* function App() {
|
|
1793
|
+
* return (
|
|
1794
|
+
* <ApolloProvider client={client}>
|
|
1795
|
+
* <Parent />
|
|
1796
|
+
* </ApolloProvider>
|
|
1797
|
+
* );
|
|
1798
|
+
* }
|
|
1799
|
+
* ```
|
|
1800
|
+
*
|
|
1801
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1802
|
+
* @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.
|
|
1803
|
+
*/
|
|
1804
|
+
interface Signature extends Signatures.Evaluated {
|
|
213
1805
|
}
|
|
214
1806
|
}
|
|
215
|
-
|
|
216
|
-
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
217
|
-
*
|
|
218
|
-
* @returns A tuple containing:
|
|
219
|
-
*
|
|
220
|
-
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
221
|
-
* 2. An object containing helper functions for the query:
|
|
222
|
-
* - `refetch`: A function to re-execute the query
|
|
223
|
-
* - `fetchMore`: A function to fetch more results for pagination
|
|
224
|
-
* - `subscribeToMore`: A function to subscribe to updates
|
|
225
|
-
*
|
|
226
|
-
* @example
|
|
227
|
-
*
|
|
228
|
-
* ```jsx
|
|
229
|
-
* import { Suspense } from "react";
|
|
230
|
-
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
231
|
-
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
232
|
-
*
|
|
233
|
-
* const query = gql`
|
|
234
|
-
* foo {
|
|
235
|
-
* bar
|
|
236
|
-
* }
|
|
237
|
-
* `;
|
|
238
|
-
*
|
|
239
|
-
* const client = new ApolloClient({
|
|
240
|
-
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
241
|
-
* cache: new InMemoryCache(),
|
|
242
|
-
* });
|
|
243
|
-
*
|
|
244
|
-
* function SuspenseFallback() {
|
|
245
|
-
* return <div>Loading...</div>;
|
|
246
|
-
* }
|
|
247
|
-
*
|
|
248
|
-
* function Child({ queryRef }) {
|
|
249
|
-
* const { data } = useReadQuery(queryRef);
|
|
250
|
-
*
|
|
251
|
-
* return <div>{data.foo.bar}</div>;
|
|
252
|
-
* }
|
|
253
|
-
*
|
|
254
|
-
* function Parent() {
|
|
255
|
-
* const [queryRef] = useBackgroundQuery(query);
|
|
256
|
-
*
|
|
257
|
-
* return (
|
|
258
|
-
* <Suspense fallback={<SuspenseFallback />}>
|
|
259
|
-
* <Child queryRef={queryRef} />
|
|
260
|
-
* </Suspense>
|
|
261
|
-
* );
|
|
262
|
-
* }
|
|
263
|
-
*
|
|
264
|
-
* function App() {
|
|
265
|
-
* return (
|
|
266
|
-
* <ApolloProvider client={client}>
|
|
267
|
-
* <Parent />
|
|
268
|
-
* </ApolloProvider>
|
|
269
|
-
* );
|
|
270
|
-
* }
|
|
271
|
-
* ```
|
|
272
|
-
*
|
|
273
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
274
|
-
* @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.
|
|
275
|
-
*/
|
|
276
|
-
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
277
|
-
/** @deprecated `returnPartialData` has no effect on `no-cache` queries */
|
|
278
|
-
returnPartialData: boolean;
|
|
279
|
-
fetchPolicy: "no-cache";
|
|
280
|
-
}): [
|
|
281
|
-
QueryRef<TData, TVariables, "complete" | "streaming">,
|
|
282
|
-
useBackgroundQuery.Result<TData, TVariables>
|
|
283
|
-
];
|
|
284
|
-
/**
|
|
285
|
-
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
286
|
-
*
|
|
287
|
-
* @returns A tuple containing:
|
|
288
|
-
*
|
|
289
|
-
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
290
|
-
* 2. An object containing helper functions for the query:
|
|
291
|
-
* - `refetch`: A function to re-execute the query
|
|
292
|
-
* - `fetchMore`: A function to fetch more results for pagination
|
|
293
|
-
* - `subscribeToMore`: A function to subscribe to updates
|
|
294
|
-
*
|
|
295
|
-
* @example
|
|
296
|
-
*
|
|
297
|
-
* ```jsx
|
|
298
|
-
* import { Suspense } from "react";
|
|
299
|
-
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
300
|
-
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
301
|
-
*
|
|
302
|
-
* const query = gql`
|
|
303
|
-
* foo {
|
|
304
|
-
* bar
|
|
305
|
-
* }
|
|
306
|
-
* `;
|
|
307
|
-
*
|
|
308
|
-
* const client = new ApolloClient({
|
|
309
|
-
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
310
|
-
* cache: new InMemoryCache(),
|
|
311
|
-
* });
|
|
312
|
-
*
|
|
313
|
-
* function SuspenseFallback() {
|
|
314
|
-
* return <div>Loading...</div>;
|
|
315
|
-
* }
|
|
316
|
-
*
|
|
317
|
-
* function Child({ queryRef }) {
|
|
318
|
-
* const { data } = useReadQuery(queryRef);
|
|
319
|
-
*
|
|
320
|
-
* return <div>{data.foo.bar}</div>;
|
|
321
|
-
* }
|
|
322
|
-
*
|
|
323
|
-
* function Parent() {
|
|
324
|
-
* const [queryRef] = useBackgroundQuery(query);
|
|
325
|
-
*
|
|
326
|
-
* return (
|
|
327
|
-
* <Suspense fallback={<SuspenseFallback />}>
|
|
328
|
-
* <Child queryRef={queryRef} />
|
|
329
|
-
* </Suspense>
|
|
330
|
-
* );
|
|
331
|
-
* }
|
|
332
|
-
*
|
|
333
|
-
* function App() {
|
|
334
|
-
* return (
|
|
335
|
-
* <ApolloProvider client={client}>
|
|
336
|
-
* <Parent />
|
|
337
|
-
* </ApolloProvider>
|
|
338
|
-
* );
|
|
339
|
-
* }
|
|
340
|
-
* ```
|
|
341
|
-
*
|
|
342
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
343
|
-
* @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.
|
|
344
|
-
*/
|
|
345
|
-
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
346
|
-
returnPartialData: false;
|
|
347
|
-
errorPolicy: "ignore" | "all";
|
|
348
|
-
}): [
|
|
349
|
-
QueryRef<TData, TVariables, "complete" | "streaming" | "empty">,
|
|
350
|
-
useBackgroundQuery.Result<TData, TVariables>
|
|
351
|
-
];
|
|
352
|
-
/**
|
|
353
|
-
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
354
|
-
*
|
|
355
|
-
* @returns A tuple containing:
|
|
356
|
-
*
|
|
357
|
-
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
358
|
-
* 2. An object containing helper functions for the query:
|
|
359
|
-
* - `refetch`: A function to re-execute the query
|
|
360
|
-
* - `fetchMore`: A function to fetch more results for pagination
|
|
361
|
-
* - `subscribeToMore`: A function to subscribe to updates
|
|
362
|
-
*
|
|
363
|
-
* @example
|
|
364
|
-
*
|
|
365
|
-
* ```jsx
|
|
366
|
-
* import { Suspense } from "react";
|
|
367
|
-
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
368
|
-
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
369
|
-
*
|
|
370
|
-
* const query = gql`
|
|
371
|
-
* foo {
|
|
372
|
-
* bar
|
|
373
|
-
* }
|
|
374
|
-
* `;
|
|
375
|
-
*
|
|
376
|
-
* const client = new ApolloClient({
|
|
377
|
-
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
378
|
-
* cache: new InMemoryCache(),
|
|
379
|
-
* });
|
|
380
|
-
*
|
|
381
|
-
* function SuspenseFallback() {
|
|
382
|
-
* return <div>Loading...</div>;
|
|
383
|
-
* }
|
|
384
|
-
*
|
|
385
|
-
* function Child({ queryRef }) {
|
|
386
|
-
* const { data } = useReadQuery(queryRef);
|
|
387
|
-
*
|
|
388
|
-
* return <div>{data.foo.bar}</div>;
|
|
389
|
-
* }
|
|
390
|
-
*
|
|
391
|
-
* function Parent() {
|
|
392
|
-
* const [queryRef] = useBackgroundQuery(query);
|
|
393
|
-
*
|
|
394
|
-
* return (
|
|
395
|
-
* <Suspense fallback={<SuspenseFallback />}>
|
|
396
|
-
* <Child queryRef={queryRef} />
|
|
397
|
-
* </Suspense>
|
|
398
|
-
* );
|
|
399
|
-
* }
|
|
400
|
-
*
|
|
401
|
-
* function App() {
|
|
402
|
-
* return (
|
|
403
|
-
* <ApolloProvider client={client}>
|
|
404
|
-
* <Parent />
|
|
405
|
-
* </ApolloProvider>
|
|
406
|
-
* );
|
|
407
|
-
* }
|
|
408
|
-
* ```
|
|
409
|
-
*
|
|
410
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
411
|
-
* @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.
|
|
412
|
-
*/
|
|
413
|
-
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
414
|
-
returnPartialData: boolean;
|
|
415
|
-
errorPolicy: "ignore" | "all";
|
|
416
|
-
}): [
|
|
417
|
-
QueryRef<TData, TVariables, "complete" | "streaming" | "partial" | "empty">,
|
|
418
|
-
useBackgroundQuery.Result<TData, TVariables>
|
|
419
|
-
];
|
|
420
|
-
/**
|
|
421
|
-
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
422
|
-
*
|
|
423
|
-
* @returns A tuple containing:
|
|
424
|
-
*
|
|
425
|
-
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
426
|
-
* 2. An object containing helper functions for the query:
|
|
427
|
-
* - `refetch`: A function to re-execute the query
|
|
428
|
-
* - `fetchMore`: A function to fetch more results for pagination
|
|
429
|
-
* - `subscribeToMore`: A function to subscribe to updates
|
|
430
|
-
*
|
|
431
|
-
* @example
|
|
432
|
-
*
|
|
433
|
-
* ```jsx
|
|
434
|
-
* import { Suspense } from "react";
|
|
435
|
-
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
436
|
-
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
437
|
-
*
|
|
438
|
-
* const query = gql`
|
|
439
|
-
* foo {
|
|
440
|
-
* bar
|
|
441
|
-
* }
|
|
442
|
-
* `;
|
|
443
|
-
*
|
|
444
|
-
* const client = new ApolloClient({
|
|
445
|
-
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
446
|
-
* cache: new InMemoryCache(),
|
|
447
|
-
* });
|
|
448
|
-
*
|
|
449
|
-
* function SuspenseFallback() {
|
|
450
|
-
* return <div>Loading...</div>;
|
|
451
|
-
* }
|
|
452
|
-
*
|
|
453
|
-
* function Child({ queryRef }) {
|
|
454
|
-
* const { data } = useReadQuery(queryRef);
|
|
455
|
-
*
|
|
456
|
-
* return <div>{data.foo.bar}</div>;
|
|
457
|
-
* }
|
|
458
|
-
*
|
|
459
|
-
* function Parent() {
|
|
460
|
-
* const [queryRef] = useBackgroundQuery(query);
|
|
461
|
-
*
|
|
462
|
-
* return (
|
|
463
|
-
* <Suspense fallback={<SuspenseFallback />}>
|
|
464
|
-
* <Child queryRef={queryRef} />
|
|
465
|
-
* </Suspense>
|
|
466
|
-
* );
|
|
467
|
-
* }
|
|
468
|
-
*
|
|
469
|
-
* function App() {
|
|
470
|
-
* return (
|
|
471
|
-
* <ApolloProvider client={client}>
|
|
472
|
-
* <Parent />
|
|
473
|
-
* </ApolloProvider>
|
|
474
|
-
* );
|
|
475
|
-
* }
|
|
476
|
-
* ```
|
|
477
|
-
*
|
|
478
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
479
|
-
* @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.
|
|
480
|
-
*/
|
|
481
|
-
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
482
|
-
errorPolicy: "ignore" | "all";
|
|
483
|
-
}): [
|
|
484
|
-
QueryRef<TData, TVariables, "complete" | "streaming" | "empty">,
|
|
485
|
-
useBackgroundQuery.Result<TData, TVariables>
|
|
486
|
-
];
|
|
487
|
-
/**
|
|
488
|
-
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
489
|
-
*
|
|
490
|
-
* @returns A tuple containing:
|
|
491
|
-
*
|
|
492
|
-
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
493
|
-
* 2. An object containing helper functions for the query:
|
|
494
|
-
* - `refetch`: A function to re-execute the query
|
|
495
|
-
* - `fetchMore`: A function to fetch more results for pagination
|
|
496
|
-
* - `subscribeToMore`: A function to subscribe to updates
|
|
497
|
-
*
|
|
498
|
-
* @example
|
|
499
|
-
*
|
|
500
|
-
* ```jsx
|
|
501
|
-
* import { Suspense } from "react";
|
|
502
|
-
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
503
|
-
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
504
|
-
*
|
|
505
|
-
* const query = gql`
|
|
506
|
-
* foo {
|
|
507
|
-
* bar
|
|
508
|
-
* }
|
|
509
|
-
* `;
|
|
510
|
-
*
|
|
511
|
-
* const client = new ApolloClient({
|
|
512
|
-
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
513
|
-
* cache: new InMemoryCache(),
|
|
514
|
-
* });
|
|
515
|
-
*
|
|
516
|
-
* function SuspenseFallback() {
|
|
517
|
-
* return <div>Loading...</div>;
|
|
518
|
-
* }
|
|
519
|
-
*
|
|
520
|
-
* function Child({ queryRef }) {
|
|
521
|
-
* const { data } = useReadQuery(queryRef);
|
|
522
|
-
*
|
|
523
|
-
* return <div>{data.foo.bar}</div>;
|
|
524
|
-
* }
|
|
525
|
-
*
|
|
526
|
-
* function Parent() {
|
|
527
|
-
* const [queryRef] = useBackgroundQuery(query);
|
|
528
|
-
*
|
|
529
|
-
* return (
|
|
530
|
-
* <Suspense fallback={<SuspenseFallback />}>
|
|
531
|
-
* <Child queryRef={queryRef} />
|
|
532
|
-
* </Suspense>
|
|
533
|
-
* );
|
|
534
|
-
* }
|
|
535
|
-
*
|
|
536
|
-
* function App() {
|
|
537
|
-
* return (
|
|
538
|
-
* <ApolloProvider client={client}>
|
|
539
|
-
* <Parent />
|
|
540
|
-
* </ApolloProvider>
|
|
541
|
-
* );
|
|
542
|
-
* }
|
|
543
|
-
* ```
|
|
544
|
-
*
|
|
545
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
546
|
-
* @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.
|
|
547
|
-
*/
|
|
548
|
-
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
549
|
-
skip: boolean;
|
|
550
|
-
returnPartialData: false;
|
|
551
|
-
}): [
|
|
552
|
-
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
553
|
-
useBackgroundQuery.Result<TData, TVariables>
|
|
554
|
-
];
|
|
555
|
-
/**
|
|
556
|
-
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
557
|
-
*
|
|
558
|
-
* @returns A tuple containing:
|
|
559
|
-
*
|
|
560
|
-
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
561
|
-
* 2. An object containing helper functions for the query:
|
|
562
|
-
* - `refetch`: A function to re-execute the query
|
|
563
|
-
* - `fetchMore`: A function to fetch more results for pagination
|
|
564
|
-
* - `subscribeToMore`: A function to subscribe to updates
|
|
565
|
-
*
|
|
566
|
-
* @example
|
|
567
|
-
*
|
|
568
|
-
* ```jsx
|
|
569
|
-
* import { Suspense } from "react";
|
|
570
|
-
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
571
|
-
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
572
|
-
*
|
|
573
|
-
* const query = gql`
|
|
574
|
-
* foo {
|
|
575
|
-
* bar
|
|
576
|
-
* }
|
|
577
|
-
* `;
|
|
578
|
-
*
|
|
579
|
-
* const client = new ApolloClient({
|
|
580
|
-
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
581
|
-
* cache: new InMemoryCache(),
|
|
582
|
-
* });
|
|
583
|
-
*
|
|
584
|
-
* function SuspenseFallback() {
|
|
585
|
-
* return <div>Loading...</div>;
|
|
586
|
-
* }
|
|
587
|
-
*
|
|
588
|
-
* function Child({ queryRef }) {
|
|
589
|
-
* const { data } = useReadQuery(queryRef);
|
|
590
|
-
*
|
|
591
|
-
* return <div>{data.foo.bar}</div>;
|
|
592
|
-
* }
|
|
593
|
-
*
|
|
594
|
-
* function Parent() {
|
|
595
|
-
* const [queryRef] = useBackgroundQuery(query);
|
|
596
|
-
*
|
|
597
|
-
* return (
|
|
598
|
-
* <Suspense fallback={<SuspenseFallback />}>
|
|
599
|
-
* <Child queryRef={queryRef} />
|
|
600
|
-
* </Suspense>
|
|
601
|
-
* );
|
|
602
|
-
* }
|
|
603
|
-
*
|
|
604
|
-
* function App() {
|
|
605
|
-
* return (
|
|
606
|
-
* <ApolloProvider client={client}>
|
|
607
|
-
* <Parent />
|
|
608
|
-
* </ApolloProvider>
|
|
609
|
-
* );
|
|
610
|
-
* }
|
|
611
|
-
* ```
|
|
612
|
-
*
|
|
613
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
614
|
-
* @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.
|
|
615
|
-
*/
|
|
616
|
-
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
617
|
-
skip: boolean;
|
|
618
|
-
returnPartialData: boolean;
|
|
619
|
-
}): [
|
|
620
|
-
QueryRef<TData, TVariables, "complete" | "streaming" | "partial"> | undefined,
|
|
621
|
-
useBackgroundQuery.Result<TData, TVariables>
|
|
622
|
-
];
|
|
623
|
-
/**
|
|
624
|
-
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
625
|
-
*
|
|
626
|
-
* @returns A tuple containing:
|
|
627
|
-
*
|
|
628
|
-
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
629
|
-
* 2. An object containing helper functions for the query:
|
|
630
|
-
* - `refetch`: A function to re-execute the query
|
|
631
|
-
* - `fetchMore`: A function to fetch more results for pagination
|
|
632
|
-
* - `subscribeToMore`: A function to subscribe to updates
|
|
633
|
-
*
|
|
634
|
-
* @example
|
|
635
|
-
*
|
|
636
|
-
* ```jsx
|
|
637
|
-
* import { Suspense } from "react";
|
|
638
|
-
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
639
|
-
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
640
|
-
*
|
|
641
|
-
* const query = gql`
|
|
642
|
-
* foo {
|
|
643
|
-
* bar
|
|
644
|
-
* }
|
|
645
|
-
* `;
|
|
646
|
-
*
|
|
647
|
-
* const client = new ApolloClient({
|
|
648
|
-
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
649
|
-
* cache: new InMemoryCache(),
|
|
650
|
-
* });
|
|
651
|
-
*
|
|
652
|
-
* function SuspenseFallback() {
|
|
653
|
-
* return <div>Loading...</div>;
|
|
654
|
-
* }
|
|
655
|
-
*
|
|
656
|
-
* function Child({ queryRef }) {
|
|
657
|
-
* const { data } = useReadQuery(queryRef);
|
|
658
|
-
*
|
|
659
|
-
* return <div>{data.foo.bar}</div>;
|
|
660
|
-
* }
|
|
661
|
-
*
|
|
662
|
-
* function Parent() {
|
|
663
|
-
* const [queryRef] = useBackgroundQuery(query);
|
|
664
|
-
*
|
|
665
|
-
* return (
|
|
666
|
-
* <Suspense fallback={<SuspenseFallback />}>
|
|
667
|
-
* <Child queryRef={queryRef} />
|
|
668
|
-
* </Suspense>
|
|
669
|
-
* );
|
|
670
|
-
* }
|
|
671
|
-
*
|
|
672
|
-
* function App() {
|
|
673
|
-
* return (
|
|
674
|
-
* <ApolloProvider client={client}>
|
|
675
|
-
* <Parent />
|
|
676
|
-
* </ApolloProvider>
|
|
677
|
-
* );
|
|
678
|
-
* }
|
|
679
|
-
* ```
|
|
680
|
-
*
|
|
681
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
682
|
-
* @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.
|
|
683
|
-
*/
|
|
684
|
-
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
685
|
-
returnPartialData: false;
|
|
686
|
-
}): [
|
|
687
|
-
QueryRef<TData, TVariables, "complete" | "streaming">,
|
|
688
|
-
useBackgroundQuery.Result<TData, TVariables>
|
|
689
|
-
];
|
|
690
|
-
/**
|
|
691
|
-
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
692
|
-
*
|
|
693
|
-
* @returns A tuple containing:
|
|
694
|
-
*
|
|
695
|
-
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
696
|
-
* 2. An object containing helper functions for the query:
|
|
697
|
-
* - `refetch`: A function to re-execute the query
|
|
698
|
-
* - `fetchMore`: A function to fetch more results for pagination
|
|
699
|
-
* - `subscribeToMore`: A function to subscribe to updates
|
|
700
|
-
*
|
|
701
|
-
* @example
|
|
702
|
-
*
|
|
703
|
-
* ```jsx
|
|
704
|
-
* import { Suspense } from "react";
|
|
705
|
-
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
706
|
-
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
707
|
-
*
|
|
708
|
-
* const query = gql`
|
|
709
|
-
* foo {
|
|
710
|
-
* bar
|
|
711
|
-
* }
|
|
712
|
-
* `;
|
|
713
|
-
*
|
|
714
|
-
* const client = new ApolloClient({
|
|
715
|
-
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
716
|
-
* cache: new InMemoryCache(),
|
|
717
|
-
* });
|
|
718
|
-
*
|
|
719
|
-
* function SuspenseFallback() {
|
|
720
|
-
* return <div>Loading...</div>;
|
|
721
|
-
* }
|
|
722
|
-
*
|
|
723
|
-
* function Child({ queryRef }) {
|
|
724
|
-
* const { data } = useReadQuery(queryRef);
|
|
725
|
-
*
|
|
726
|
-
* return <div>{data.foo.bar}</div>;
|
|
727
|
-
* }
|
|
728
|
-
*
|
|
729
|
-
* function Parent() {
|
|
730
|
-
* const [queryRef] = useBackgroundQuery(query);
|
|
731
|
-
*
|
|
732
|
-
* return (
|
|
733
|
-
* <Suspense fallback={<SuspenseFallback />}>
|
|
734
|
-
* <Child queryRef={queryRef} />
|
|
735
|
-
* </Suspense>
|
|
736
|
-
* );
|
|
737
|
-
* }
|
|
738
|
-
*
|
|
739
|
-
* function App() {
|
|
740
|
-
* return (
|
|
741
|
-
* <ApolloProvider client={client}>
|
|
742
|
-
* <Parent />
|
|
743
|
-
* </ApolloProvider>
|
|
744
|
-
* );
|
|
745
|
-
* }
|
|
746
|
-
* ```
|
|
747
|
-
*
|
|
748
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
749
|
-
* @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.
|
|
750
|
-
*/
|
|
751
|
-
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
752
|
-
returnPartialData: boolean;
|
|
753
|
-
}): [
|
|
754
|
-
QueryRef<TData, TVariables, "complete" | "streaming" | "partial">,
|
|
755
|
-
useBackgroundQuery.Result<TData, TVariables>
|
|
756
|
-
];
|
|
757
|
-
/**
|
|
758
|
-
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
759
|
-
*
|
|
760
|
-
* @returns A tuple containing:
|
|
761
|
-
*
|
|
762
|
-
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
763
|
-
* 2. An object containing helper functions for the query:
|
|
764
|
-
* - `refetch`: A function to re-execute the query
|
|
765
|
-
* - `fetchMore`: A function to fetch more results for pagination
|
|
766
|
-
* - `subscribeToMore`: A function to subscribe to updates
|
|
767
|
-
*
|
|
768
|
-
* @example
|
|
769
|
-
*
|
|
770
|
-
* ```jsx
|
|
771
|
-
* import { Suspense } from "react";
|
|
772
|
-
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
773
|
-
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
774
|
-
*
|
|
775
|
-
* const query = gql`
|
|
776
|
-
* foo {
|
|
777
|
-
* bar
|
|
778
|
-
* }
|
|
779
|
-
* `;
|
|
780
|
-
*
|
|
781
|
-
* const client = new ApolloClient({
|
|
782
|
-
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
783
|
-
* cache: new InMemoryCache(),
|
|
784
|
-
* });
|
|
785
|
-
*
|
|
786
|
-
* function SuspenseFallback() {
|
|
787
|
-
* return <div>Loading...</div>;
|
|
788
|
-
* }
|
|
789
|
-
*
|
|
790
|
-
* function Child({ queryRef }) {
|
|
791
|
-
* const { data } = useReadQuery(queryRef);
|
|
792
|
-
*
|
|
793
|
-
* return <div>{data.foo.bar}</div>;
|
|
794
|
-
* }
|
|
795
|
-
*
|
|
796
|
-
* function Parent() {
|
|
797
|
-
* const [queryRef] = useBackgroundQuery(query);
|
|
798
|
-
*
|
|
799
|
-
* return (
|
|
800
|
-
* <Suspense fallback={<SuspenseFallback />}>
|
|
801
|
-
* <Child queryRef={queryRef} />
|
|
802
|
-
* </Suspense>
|
|
803
|
-
* );
|
|
804
|
-
* }
|
|
805
|
-
*
|
|
806
|
-
* function App() {
|
|
807
|
-
* return (
|
|
808
|
-
* <ApolloProvider client={client}>
|
|
809
|
-
* <Parent />
|
|
810
|
-
* </ApolloProvider>
|
|
811
|
-
* );
|
|
812
|
-
* }
|
|
813
|
-
* ```
|
|
814
|
-
*
|
|
815
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
816
|
-
* @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.
|
|
817
|
-
*/
|
|
818
|
-
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
819
|
-
skip: boolean;
|
|
820
|
-
}): [
|
|
821
|
-
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
822
|
-
useBackgroundQuery.Result<TData, TVariables>
|
|
823
|
-
];
|
|
824
|
-
/**
|
|
825
|
-
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
826
|
-
*
|
|
827
|
-
* @returns A tuple containing:
|
|
828
|
-
*
|
|
829
|
-
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
830
|
-
* 2. An object containing helper functions for the query:
|
|
831
|
-
* - `refetch`: A function to re-execute the query
|
|
832
|
-
* - `fetchMore`: A function to fetch more results for pagination
|
|
833
|
-
* - `subscribeToMore`: A function to subscribe to updates
|
|
834
|
-
*
|
|
835
|
-
* @example
|
|
836
|
-
*
|
|
837
|
-
* ```jsx
|
|
838
|
-
* import { Suspense } from "react";
|
|
839
|
-
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
840
|
-
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
841
|
-
*
|
|
842
|
-
* const query = gql`
|
|
843
|
-
* foo {
|
|
844
|
-
* bar
|
|
845
|
-
* }
|
|
846
|
-
* `;
|
|
847
|
-
*
|
|
848
|
-
* const client = new ApolloClient({
|
|
849
|
-
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
850
|
-
* cache: new InMemoryCache(),
|
|
851
|
-
* });
|
|
852
|
-
*
|
|
853
|
-
* function SuspenseFallback() {
|
|
854
|
-
* return <div>Loading...</div>;
|
|
855
|
-
* }
|
|
856
|
-
*
|
|
857
|
-
* function Child({ queryRef }) {
|
|
858
|
-
* const { data } = useReadQuery(queryRef);
|
|
859
|
-
*
|
|
860
|
-
* return <div>{data.foo.bar}</div>;
|
|
861
|
-
* }
|
|
862
|
-
*
|
|
863
|
-
* function Parent() {
|
|
864
|
-
* const [queryRef] = useBackgroundQuery(query);
|
|
865
|
-
*
|
|
866
|
-
* return (
|
|
867
|
-
* <Suspense fallback={<SuspenseFallback />}>
|
|
868
|
-
* <Child queryRef={queryRef} />
|
|
869
|
-
* </Suspense>
|
|
870
|
-
* );
|
|
871
|
-
* }
|
|
872
|
-
*
|
|
873
|
-
* function App() {
|
|
874
|
-
* return (
|
|
875
|
-
* <ApolloProvider client={client}>
|
|
876
|
-
* <Parent />
|
|
877
|
-
* </ApolloProvider>
|
|
878
|
-
* );
|
|
879
|
-
* }
|
|
880
|
-
* ```
|
|
881
|
-
*
|
|
882
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
883
|
-
* @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.
|
|
884
|
-
*/
|
|
885
|
-
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken): [undefined, useBackgroundQuery.Result<TData, TVariables>];
|
|
886
|
-
/**
|
|
887
|
-
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
888
|
-
*
|
|
889
|
-
* @returns A tuple containing:
|
|
890
|
-
*
|
|
891
|
-
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
892
|
-
* 2. An object containing helper functions for the query:
|
|
893
|
-
* - `refetch`: A function to re-execute the query
|
|
894
|
-
* - `fetchMore`: A function to fetch more results for pagination
|
|
895
|
-
* - `subscribeToMore`: A function to subscribe to updates
|
|
896
|
-
*
|
|
897
|
-
* @example
|
|
898
|
-
*
|
|
899
|
-
* ```jsx
|
|
900
|
-
* import { Suspense } from "react";
|
|
901
|
-
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
902
|
-
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
903
|
-
*
|
|
904
|
-
* const query = gql`
|
|
905
|
-
* foo {
|
|
906
|
-
* bar
|
|
907
|
-
* }
|
|
908
|
-
* `;
|
|
909
|
-
*
|
|
910
|
-
* const client = new ApolloClient({
|
|
911
|
-
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
912
|
-
* cache: new InMemoryCache(),
|
|
913
|
-
* });
|
|
914
|
-
*
|
|
915
|
-
* function SuspenseFallback() {
|
|
916
|
-
* return <div>Loading...</div>;
|
|
917
|
-
* }
|
|
918
|
-
*
|
|
919
|
-
* function Child({ queryRef }) {
|
|
920
|
-
* const { data } = useReadQuery(queryRef);
|
|
921
|
-
*
|
|
922
|
-
* return <div>{data.foo.bar}</div>;
|
|
923
|
-
* }
|
|
924
|
-
*
|
|
925
|
-
* function Parent() {
|
|
926
|
-
* const [queryRef] = useBackgroundQuery(query);
|
|
927
|
-
*
|
|
928
|
-
* return (
|
|
929
|
-
* <Suspense fallback={<SuspenseFallback />}>
|
|
930
|
-
* <Child queryRef={queryRef} />
|
|
931
|
-
* </Suspense>
|
|
932
|
-
* );
|
|
933
|
-
* }
|
|
934
|
-
*
|
|
935
|
-
* function App() {
|
|
936
|
-
* return (
|
|
937
|
-
* <ApolloProvider client={client}>
|
|
938
|
-
* <Parent />
|
|
939
|
-
* </ApolloProvider>
|
|
940
|
-
* );
|
|
941
|
-
* }
|
|
942
|
-
* ```
|
|
943
|
-
*
|
|
944
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
945
|
-
* @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.
|
|
946
|
-
*/
|
|
947
|
-
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
948
|
-
returnPartialData: false;
|
|
949
|
-
})): [
|
|
950
|
-
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
951
|
-
useBackgroundQuery.Result<TData, TVariables>
|
|
952
|
-
];
|
|
953
|
-
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
954
|
-
returnPartialData: boolean;
|
|
955
|
-
})): [
|
|
956
|
-
QueryRef<TData, TVariables, "complete" | "streaming" | "partial"> | undefined,
|
|
957
|
-
useBackgroundQuery.Result<TData, TVariables>
|
|
958
|
-
];
|
|
959
|
-
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
|
|
960
|
-
options?: useBackgroundQuery.Options<NoInfer<TVariables>>
|
|
961
|
-
] : [options: useBackgroundQuery.Options<NoInfer<TVariables>>]): [
|
|
962
|
-
QueryRef<TData, TVariables, "complete" | "streaming">,
|
|
963
|
-
useBackgroundQuery.Result<TData, TVariables>
|
|
964
|
-
];
|
|
965
|
-
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
|
|
966
|
-
options?: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>
|
|
967
|
-
] : [options: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>]): [
|
|
968
|
-
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
969
|
-
useBackgroundQuery.Result<TData, TVariables>
|
|
970
|
-
];
|
|
971
|
-
export declare function useBackgroundQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>): [
|
|
972
|
-
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
973
|
-
useBackgroundQuery.Result<TData, TVariables>
|
|
974
|
-
];
|
|
1807
|
+
export declare const useBackgroundQuery: useBackgroundQuery.Signature;
|
|
975
1808
|
//# sourceMappingURL=useBackgroundQuery.d.cts.map
|