@apollo/client 4.2.0-alpha.0 → 4.2.0-alpha.2
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 +170 -0
- package/__cjs/core/ApolloClient.cjs +16 -3
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +180 -131
- package/__cjs/core/ObservableQuery.cjs +13 -1
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/QueryManager.cjs +2 -3
- 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/react/hooks/useBackgroundQuery.cjs +3 -3
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +254 -822
- package/__cjs/react/hooks/useLazyQuery.cjs +3 -5
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +93 -146
- package/__cjs/react/hooks/useLoadableQuery.cjs +8 -4
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +105 -233
- package/__cjs/react/hooks/useQuery.cjs +9 -5
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +138 -308
- package/__cjs/react/hooks/useSuspenseQuery.cjs +3 -3
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +147 -436
- 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 +180 -131
- package/core/ApolloClient.js +16 -3
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.js +13 -1
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryManager.js +3 -4
- 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/package.json +1 -1
- package/react/hooks/useBackgroundQuery.d.ts +254 -822
- package/react/hooks/useBackgroundQuery.js +2 -2
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +93 -146
- package/react/hooks/useLazyQuery.js +2 -4
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +105 -233
- package/react/hooks/useLoadableQuery.js +7 -3
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useQuery.d.ts +138 -308
- package/react/hooks/useQuery.js +7 -3
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +147 -436
- package/react/hooks/useSuspenseQuery.js +2 -2
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/useBackgroundQuery.d.ts +254 -822
- package/react/hooks-compiled/useBackgroundQuery.js +2 -2
- package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.d.ts +93 -146
- package/react/hooks-compiled/useLazyQuery.js +2 -4
- package/react/hooks-compiled/useLazyQuery.js.map +1 -1
- package/react/hooks-compiled/useLoadableQuery.d.ts +105 -233
- package/react/hooks-compiled/useLoadableQuery.js +2 -2
- package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
- package/react/hooks-compiled/useQuery.d.ts +138 -308
- package/react/hooks-compiled/useQuery.js +7 -3
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/hooks-compiled/useSuspenseQuery.d.ts +147 -436
- 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/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,832 +144,264 @@ 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 {
|
|
148
155
|
/**
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
156
|
+
* For a detailed explanation of useBackgroundQuery, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
157
|
+
*
|
|
158
|
+
* @returns A tuple containing:
|
|
159
|
+
*
|
|
160
|
+
* 1. A `QueryRef` that can be passed to `useReadQuery` to read the query result. The `queryRef` is `undefined` if the query is skipped.
|
|
161
|
+
* 2. An object containing helper functions for the query:
|
|
162
|
+
* - `refetch`: A function to re-execute the query
|
|
163
|
+
* - `fetchMore`: A function to fetch more results for pagination
|
|
164
|
+
* - `subscribeToMore`: A function to subscribe to updates
|
|
165
|
+
*
|
|
166
|
+
* @example
|
|
167
|
+
*
|
|
168
|
+
* ```jsx
|
|
169
|
+
* import { Suspense } from "react";
|
|
170
|
+
* import { ApolloClient, InMemoryCache, HttpLink } from "@apollo/client";
|
|
171
|
+
* import { useBackgroundQuery, useReadQuery } from "@apollo/client/react";
|
|
172
|
+
*
|
|
173
|
+
* const query = gql`
|
|
174
|
+
* foo {
|
|
175
|
+
* bar
|
|
176
|
+
* }
|
|
177
|
+
* `;
|
|
178
|
+
*
|
|
179
|
+
* const client = new ApolloClient({
|
|
180
|
+
* link: new HttpLink({ uri: "http://localhost:4000/graphql" }),
|
|
181
|
+
* cache: new InMemoryCache(),
|
|
182
|
+
* });
|
|
183
|
+
*
|
|
184
|
+
* function SuspenseFallback() {
|
|
185
|
+
* return <div>Loading...</div>;
|
|
186
|
+
* }
|
|
187
|
+
*
|
|
188
|
+
* function Child({ queryRef }) {
|
|
189
|
+
* const { data } = useReadQuery(queryRef);
|
|
190
|
+
*
|
|
191
|
+
* return <div>{data.foo.bar}</div>;
|
|
192
|
+
* }
|
|
193
|
+
*
|
|
194
|
+
* function Parent() {
|
|
195
|
+
* const [queryRef] = useBackgroundQuery(query);
|
|
196
|
+
*
|
|
197
|
+
* return (
|
|
198
|
+
* <Suspense fallback={<SuspenseFallback />}>
|
|
199
|
+
* <Child queryRef={queryRef} />
|
|
200
|
+
* </Suspense>
|
|
201
|
+
* );
|
|
202
|
+
* }
|
|
203
|
+
*
|
|
204
|
+
* function App() {
|
|
205
|
+
* return (
|
|
206
|
+
* <ApolloProvider client={client}>
|
|
207
|
+
* <Parent />
|
|
208
|
+
* </ApolloProvider>
|
|
209
|
+
* );
|
|
210
|
+
* }
|
|
211
|
+
* ```
|
|
212
|
+
*
|
|
213
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
214
|
+
* @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.
|
|
215
|
+
*/
|
|
216
|
+
interface useBackgroundQuery {
|
|
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
|
+
/**
|
|
223
|
+
* @deprecated Avoid manually specifying generics on `useBackgroundQuery`.
|
|
224
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
225
|
+
*/
|
|
226
|
+
interface useBackgroundQuery_Deprecated {
|
|
227
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | useBackgroundQuery.Options<TVariables>): [
|
|
228
|
+
QueryRef<TData, TVariables> | undefined,
|
|
229
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
230
|
+
];
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
namespace Signatures {
|
|
234
|
+
/**
|
|
196
235
|
*
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
236
|
+
*/
|
|
237
|
+
interface Classic {
|
|
238
|
+
/**
|
|
239
|
+
*
|
|
240
|
+
*/
|
|
241
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
242
|
+
/** @deprecated `returnPartialData` has no effect on `no-cache` queries */
|
|
243
|
+
returnPartialData: boolean;
|
|
244
|
+
fetchPolicy: "no-cache";
|
|
245
|
+
}): [
|
|
246
|
+
QueryRef<TData, TVariables, "complete" | "streaming">,
|
|
247
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
248
|
+
];
|
|
249
|
+
/**
|
|
250
|
+
*
|
|
251
|
+
*/
|
|
252
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
253
|
+
returnPartialData: false;
|
|
254
|
+
errorPolicy: "ignore" | "all";
|
|
255
|
+
}): [
|
|
256
|
+
QueryRef<TData, TVariables, "complete" | "streaming" | "empty">,
|
|
257
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
258
|
+
];
|
|
259
|
+
/**
|
|
260
|
+
*
|
|
261
|
+
*/
|
|
262
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
263
|
+
returnPartialData: boolean;
|
|
264
|
+
errorPolicy: "ignore" | "all";
|
|
265
|
+
}): [
|
|
266
|
+
QueryRef<TData, TVariables, "complete" | "streaming" | "partial" | "empty">,
|
|
267
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
268
|
+
];
|
|
269
|
+
/**
|
|
270
|
+
*
|
|
271
|
+
*/
|
|
272
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
273
|
+
errorPolicy: "ignore" | "all";
|
|
274
|
+
}): [
|
|
275
|
+
QueryRef<TData, TVariables, "complete" | "streaming" | "empty">,
|
|
276
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
277
|
+
];
|
|
278
|
+
/**
|
|
279
|
+
*
|
|
280
|
+
*/
|
|
281
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
282
|
+
skip: boolean;
|
|
283
|
+
returnPartialData: false;
|
|
284
|
+
}): [
|
|
285
|
+
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
286
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
287
|
+
];
|
|
288
|
+
/**
|
|
289
|
+
*
|
|
290
|
+
*/
|
|
291
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
292
|
+
skip: boolean;
|
|
293
|
+
returnPartialData: boolean;
|
|
294
|
+
}): [
|
|
295
|
+
(QueryRef<TData, TVariables, "complete" | "streaming" | "partial"> | undefined),
|
|
296
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
297
|
+
];
|
|
298
|
+
/**
|
|
299
|
+
*
|
|
300
|
+
*/
|
|
301
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
302
|
+
returnPartialData: false;
|
|
303
|
+
}): [
|
|
304
|
+
QueryRef<TData, TVariables, "complete" | "streaming">,
|
|
305
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
306
|
+
];
|
|
307
|
+
/**
|
|
308
|
+
*
|
|
309
|
+
*/
|
|
310
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
311
|
+
returnPartialData: boolean;
|
|
312
|
+
}): [
|
|
313
|
+
QueryRef<TData, TVariables, "complete" | "streaming" | "partial">,
|
|
314
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
315
|
+
];
|
|
316
|
+
/**
|
|
317
|
+
*
|
|
318
|
+
*/
|
|
319
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
320
|
+
skip: boolean;
|
|
321
|
+
}): [
|
|
322
|
+
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
323
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
324
|
+
];
|
|
325
|
+
/**
|
|
326
|
+
*
|
|
327
|
+
*/
|
|
328
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken): [undefined, useBackgroundQuery.Result<TData, TVariables>];
|
|
329
|
+
/**
|
|
330
|
+
*
|
|
331
|
+
*/
|
|
332
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
333
|
+
returnPartialData: false;
|
|
334
|
+
})): [
|
|
335
|
+
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
336
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
337
|
+
];
|
|
338
|
+
/**
|
|
339
|
+
*
|
|
340
|
+
*/
|
|
341
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (useBackgroundQuery.Options<NoInfer<TVariables>> & {
|
|
342
|
+
returnPartialData: boolean;
|
|
343
|
+
})): [
|
|
344
|
+
(QueryRef<TData, TVariables, "complete" | "streaming" | "partial"> | undefined),
|
|
345
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
346
|
+
];
|
|
347
|
+
/**
|
|
348
|
+
*
|
|
349
|
+
*/
|
|
350
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
|
|
351
|
+
options?: useBackgroundQuery.Options<NoInfer<TVariables>>
|
|
352
|
+
] : [options: useBackgroundQuery.Options<NoInfer<TVariables>>]): [
|
|
353
|
+
QueryRef<TData, TVariables, "complete" | "streaming">,
|
|
354
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
355
|
+
];
|
|
356
|
+
/**
|
|
357
|
+
*
|
|
358
|
+
*/
|
|
359
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
|
|
360
|
+
options?: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>
|
|
361
|
+
] : [options: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>]): [
|
|
362
|
+
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
363
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
364
|
+
];
|
|
365
|
+
/**
|
|
366
|
+
*
|
|
367
|
+
*/
|
|
368
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | useBackgroundQuery.Options<NoInfer<TVariables>>): [
|
|
369
|
+
QueryRef<TData, TVariables, "complete" | "streaming"> | undefined,
|
|
370
|
+
useBackgroundQuery.Result<TData, TVariables>
|
|
371
|
+
];
|
|
372
|
+
}
|
|
373
|
+
/**
|
|
205
374
|
*
|
|
206
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
207
|
-
* @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
375
|
*/
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
376
|
+
interface Modern {
|
|
377
|
+
/**
|
|
378
|
+
*
|
|
379
|
+
*/
|
|
380
|
+
<TData, TVariables extends OperationVariables, TOptions extends never>(query: {} extends TVariables ? DocumentNode | TypedDocumentNode<TData, TVariables> : never): useBackgroundQuery.ResultForOptions<TData, TVariables, Record<string, never>>;
|
|
381
|
+
/**
|
|
382
|
+
*
|
|
383
|
+
*/
|
|
384
|
+
<TData, TVariables extends OperationVariables, TOptions extends never>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, skipToken: SkipToken): useBackgroundQuery.ResultForOptions<TData, TVariables, SkipToken>;
|
|
385
|
+
/**
|
|
386
|
+
*
|
|
387
|
+
*/
|
|
388
|
+
<TData, TVariables extends OperationVariables, TOptions extends useBackgroundQuery.Options<NoInfer<TVariables>> & VariablesOption<TVariables & {
|
|
389
|
+
[K in Exclude<keyof TOptions["variables"], keyof TVariables>]?: never;
|
|
390
|
+
}>>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [options?: TOptions] : [options: TOptions]): useBackgroundQuery.ResultForOptions<TData, TVariables, TOptions>;
|
|
391
|
+
/**
|
|
392
|
+
*
|
|
393
|
+
*/
|
|
394
|
+
<TData, TVariables extends OperationVariables, TOptions extends useBackgroundQuery.Options<NoInfer<TVariables>> & VariablesOption<TVariables & {
|
|
395
|
+
[K in Exclude<keyof TOptions["variables"], keyof TVariables>]?: never;
|
|
396
|
+
}>>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [options?: TOptions | SkipToken] : [options: TOptions | SkipToken]): useBackgroundQuery.ResultForOptions<TData, TVariables, TOptions | SkipToken>;
|
|
397
|
+
}
|
|
398
|
+
type Evaluated = SignatureStyle extends "classic" ? Classic : Modern;
|
|
399
|
+
}
|
|
400
|
+
/**
|
|
401
|
+
*
|
|
402
|
+
*/
|
|
403
|
+
interface Signature extends Signatures.Evaluated {
|
|
213
404
|
}
|
|
214
405
|
}
|
|
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
|
-
];
|
|
406
|
+
export declare const useBackgroundQuery: useBackgroundQuery.Signature;
|
|
975
407
|
//# sourceMappingURL=useBackgroundQuery.d.cts.map
|