@apollo/client 4.2.0-alpha.2 → 4.2.0-alpha.4
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 +240 -0
- package/__cjs/cache/core/cache.cjs +1 -1
- package/__cjs/cache/inmemory/entityStore.cjs +3 -3
- package/__cjs/cache/inmemory/entityStore.cjs.map +1 -1
- package/__cjs/cache/inmemory/key-extractor.cjs +1 -1
- package/__cjs/cache/inmemory/policies.cjs +4 -4
- package/__cjs/cache/inmemory/readFromStore.cjs +2 -2
- package/__cjs/cache/inmemory/writeToStore.cjs +4 -4
- package/__cjs/core/ApolloClient.cjs +52 -20
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +159 -22
- package/__cjs/core/ObservableQuery.cjs +7 -7
- package/__cjs/core/ObservableQuery.cjs.map +1 -1
- package/__cjs/core/ObservableQuery.d.cts +20 -1
- package/__cjs/core/QueryManager.cjs +12 -12
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/RefetchEventManager.cjs +134 -0
- package/__cjs/core/RefetchEventManager.cjs.map +1 -0
- package/__cjs/core/RefetchEventManager.d.cts +130 -0
- package/__cjs/core/index.cjs +7 -1
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +4 -1
- package/__cjs/core/refetchSources/onlineSource.cjs +10 -0
- package/__cjs/core/refetchSources/onlineSource.cjs.map +1 -0
- package/__cjs/core/refetchSources/onlineSource.d.cts +3 -0
- package/__cjs/core/refetchSources/windowFocusSource.cjs +13 -0
- package/__cjs/core/refetchSources/windowFocusSource.cjs.map +1 -0
- package/__cjs/core/refetchSources/windowFocusSource.d.cts +3 -0
- package/__cjs/core/types.d.cts +20 -0
- package/__cjs/invariantErrorCodes.cjs +69 -44
- 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.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +1486 -66
- package/__cjs/react/hooks/useLazyQuery.cjs +1 -0
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +366 -40
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +512 -50
- 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.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +590 -41
- 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.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +754 -46
- package/__cjs/react/internal/cache/QueryReference.cjs +1 -0
- package/__cjs/react/internal/cache/QueryReference.cjs.map +1 -1
- package/__cjs/react/internal/cache/QueryReference.d.cts +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.cjs.map +1 -1
- package/__cjs/react/query-preloader/createQueryPreloader.d.cts +20 -1
- package/__cjs/react/types/types.documentation.d.cts +19 -0
- package/__cjs/version.cjs +1 -1
- package/cache/core/cache.js +1 -1
- package/cache/inmemory/entityStore.js +3 -3
- package/cache/inmemory/entityStore.js.map +1 -1
- package/cache/inmemory/key-extractor.js +1 -1
- package/cache/inmemory/policies.js +4 -4
- package/cache/inmemory/readFromStore.js +2 -2
- package/cache/inmemory/writeToStore.js +4 -4
- package/core/ApolloClient.d.ts +159 -22
- package/core/ApolloClient.js +53 -21
- package/core/ApolloClient.js.map +1 -1
- package/core/ObservableQuery.d.ts +20 -1
- package/core/ObservableQuery.js +7 -7
- package/core/ObservableQuery.js.map +1 -1
- package/core/QueryManager.js +12 -12
- package/core/QueryManager.js.map +1 -1
- package/core/RefetchEventManager.d.ts +130 -0
- package/core/RefetchEventManager.js +126 -0
- package/core/RefetchEventManager.js.map +1 -0
- package/core/index.d.ts +4 -1
- package/core/index.js +3 -0
- package/core/index.js.map +1 -1
- package/core/refetchSources/onlineSource.d.ts +3 -0
- package/core/refetchSources/onlineSource.js +6 -0
- package/core/refetchSources/onlineSource.js.map +1 -0
- package/core/refetchSources/windowFocusSource.d.ts +3 -0
- package/core/refetchSources/windowFocusSource.js +9 -0
- package/core/refetchSources/windowFocusSource.js.map +1 -0
- package/core/types.d.ts +20 -0
- package/core/types.js.map +1 -1
- package/invariantErrorCodes.js +69 -44
- 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 +1486 -66
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +366 -40
- package/react/hooks/useLazyQuery.js +1 -0
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +512 -50
- 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 +590 -41
- 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 +754 -46
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/useBackgroundQuery.d.ts +1486 -66
- package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.d.ts +366 -40
- package/react/hooks-compiled/useLazyQuery.js +1 -0
- package/react/hooks-compiled/useLazyQuery.js.map +1 -1
- package/react/hooks-compiled/useLoadableQuery.d.ts +512 -50
- 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 +590 -41
- 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 +754 -46
- package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
- package/react/internal/cache/QueryReference.d.ts +1 -1
- package/react/internal/cache/QueryReference.js +1 -0
- package/react/internal/cache/QueryReference.js.map +1 -1
- package/react/query-preloader/createQueryPreloader.d.ts +20 -1
- package/react/query-preloader/createQueryPreloader.js.map +1 -1
- package/react/types/types.documentation.d.ts +19 -0
- package/react/types/types.documentation.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/version.js +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ApolloClient, DataState, DefaultContext, DocumentNode, ErrorLike, ErrorPolicy, GetDataState, MaybeMasked, OperationVariables, RefetchWritePolicy, TypedDocumentNode, WatchQueryFetchPolicy } from "@apollo/client";
|
|
1
|
+
import type { ApolloClient, DataState, DefaultContext, DocumentNode, ErrorLike, ErrorPolicy, GetDataState, MaybeMasked, OperationVariables, RefetchOn, RefetchWritePolicy, TypedDocumentNode, WatchQueryFetchPolicy } from "@apollo/client";
|
|
2
2
|
import type { SubscribeToMoreFunction } from "@apollo/client";
|
|
3
3
|
import { NetworkStatus } from "@apollo/client";
|
|
4
4
|
import type { FetchMoreFunction, RefetchFunction } from "@apollo/client/react/internal";
|
|
@@ -71,6 +71,25 @@ export declare namespace useSuspenseQuery {
|
|
|
71
71
|
*/
|
|
72
72
|
queryKey?: string | number | any[];
|
|
73
73
|
/**
|
|
74
|
+
* Determines whether events trigger refetches for the query. Provide an
|
|
75
|
+
* object mapping each refetch event to `true` (enable), `false` (disable)
|
|
76
|
+
* or a callback function that returns `true`/`false` to control individual
|
|
77
|
+
* events. Provide `false` to disable all automatic refetch events for this
|
|
78
|
+
* query. Provide `true` to enable all automatic refetch events for this query.
|
|
79
|
+
* Provide a callback function to perform additional logic to determine
|
|
80
|
+
* whether to enable or disable a refetch for a query.
|
|
81
|
+
*
|
|
82
|
+
* `@remarks`
|
|
83
|
+
* `refetchOn` inherits from `defaultOptions.watchQuery.refetchOn`. If
|
|
84
|
+
* `defaultOptions.watchQuery.refetchOn` is not set, all refetch events are
|
|
85
|
+
* enabled by default.
|
|
86
|
+
*
|
|
87
|
+
* This option only has an effect when the client is configured with a
|
|
88
|
+
* `refetchEventManager`.
|
|
89
|
+
* @docGroup 1. Operation options
|
|
90
|
+
*/
|
|
91
|
+
refetchOn?: RefetchOn.Option;
|
|
92
|
+
/**
|
|
74
93
|
* If `true`, the query is not executed. The default value is `false`.
|
|
75
94
|
*
|
|
76
95
|
* @deprecated We recommend using `skipToken` in place of the `skip` option as
|
|
@@ -185,138 +204,789 @@ export declare namespace useSuspenseQuery {
|
|
|
185
204
|
}
|
|
186
205
|
}
|
|
187
206
|
namespace DocumentationTypes {
|
|
188
|
-
/**
|
|
189
|
-
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
190
|
-
*
|
|
191
|
-
* @example
|
|
192
|
-
*
|
|
193
|
-
* ```jsx
|
|
194
|
-
* import { Suspense } from "react";
|
|
195
|
-
* import { useSuspenseQuery } from "@apollo/client";
|
|
196
|
-
*
|
|
197
|
-
* const listQuery = gql`
|
|
198
|
-
* query {
|
|
199
|
-
* list {
|
|
200
|
-
* id
|
|
201
|
-
* }
|
|
202
|
-
* }
|
|
203
|
-
* `;
|
|
204
|
-
*
|
|
205
|
-
* function App() {
|
|
206
|
-
* return (
|
|
207
|
-
* <Suspense fallback={<Spinner />}>
|
|
208
|
-
* <List />
|
|
209
|
-
* </Suspense>
|
|
210
|
-
* );
|
|
211
|
-
* }
|
|
212
|
-
*
|
|
213
|
-
* function List() {
|
|
214
|
-
* const { data } = useSuspenseQuery(listQuery);
|
|
215
|
-
*
|
|
216
|
-
* return (
|
|
217
|
-
* <ol>
|
|
218
|
-
* {data.list.map((item) => (
|
|
219
|
-
* <Item key={item.id} id={item.id} />
|
|
220
|
-
* ))}
|
|
221
|
-
* </ol>
|
|
222
|
-
* );
|
|
223
|
-
* }
|
|
224
|
-
* ```
|
|
225
|
-
*
|
|
226
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
227
|
-
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
228
|
-
*/
|
|
229
207
|
interface useSuspenseQuery {
|
|
208
|
+
/**
|
|
209
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
*
|
|
213
|
+
* ```jsx
|
|
214
|
+
* import { Suspense } from "react";
|
|
215
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
216
|
+
*
|
|
217
|
+
* const listQuery = gql`
|
|
218
|
+
* query {
|
|
219
|
+
* list {
|
|
220
|
+
* id
|
|
221
|
+
* }
|
|
222
|
+
* }
|
|
223
|
+
* `;
|
|
224
|
+
*
|
|
225
|
+
* function App() {
|
|
226
|
+
* return (
|
|
227
|
+
* <Suspense fallback={<Spinner />}>
|
|
228
|
+
* <List />
|
|
229
|
+
* </Suspense>
|
|
230
|
+
* );
|
|
231
|
+
* }
|
|
232
|
+
*
|
|
233
|
+
* function List() {
|
|
234
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
235
|
+
*
|
|
236
|
+
* return (
|
|
237
|
+
* <ol>
|
|
238
|
+
* {data.list.map((item) => (
|
|
239
|
+
* <Item key={item.id} id={item.id} />
|
|
240
|
+
* ))}
|
|
241
|
+
* </ol>
|
|
242
|
+
* );
|
|
243
|
+
* }
|
|
244
|
+
* ```
|
|
245
|
+
*
|
|
246
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
247
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
248
|
+
*/
|
|
230
249
|
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: useSuspenseQuery.Options<TVariables>): useSuspenseQuery.Result<TData, TVariables>;
|
|
231
250
|
}
|
|
232
|
-
/**
|
|
233
|
-
* @deprecated Avoid manually specifying generic arguments on `useSuspenseQuery`.
|
|
234
|
-
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
235
|
-
*/
|
|
236
251
|
interface useSuspenseQuery_Deprecated {
|
|
252
|
+
/**
|
|
253
|
+
* @deprecated Avoid manually specifying generic arguments on `useSuspenseQuery`.
|
|
254
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
255
|
+
*
|
|
256
|
+
*
|
|
257
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
*
|
|
261
|
+
* ```jsx
|
|
262
|
+
* import { Suspense } from "react";
|
|
263
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
264
|
+
*
|
|
265
|
+
* const listQuery = gql`
|
|
266
|
+
* query {
|
|
267
|
+
* list {
|
|
268
|
+
* id
|
|
269
|
+
* }
|
|
270
|
+
* }
|
|
271
|
+
* `;
|
|
272
|
+
*
|
|
273
|
+
* function App() {
|
|
274
|
+
* return (
|
|
275
|
+
* <Suspense fallback={<Spinner />}>
|
|
276
|
+
* <List />
|
|
277
|
+
* </Suspense>
|
|
278
|
+
* );
|
|
279
|
+
* }
|
|
280
|
+
*
|
|
281
|
+
* function List() {
|
|
282
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
283
|
+
*
|
|
284
|
+
* return (
|
|
285
|
+
* <ol>
|
|
286
|
+
* {data.list.map((item) => (
|
|
287
|
+
* <Item key={item.id} id={item.id} />
|
|
288
|
+
* ))}
|
|
289
|
+
* </ol>
|
|
290
|
+
* );
|
|
291
|
+
* }
|
|
292
|
+
* ```
|
|
293
|
+
*
|
|
294
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
295
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
296
|
+
*/
|
|
237
297
|
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: useSuspenseQuery.Options<TVariables>): useSuspenseQuery.Result<TData, TVariables>;
|
|
238
298
|
}
|
|
239
299
|
}
|
|
240
300
|
namespace Signatures {
|
|
241
301
|
/**
|
|
302
|
+
* @deprecated Avoid manually specifying generic arguments on `useSuspenseQuery`.
|
|
303
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
304
|
+
*
|
|
305
|
+
*
|
|
306
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
*
|
|
310
|
+
* ```jsx
|
|
311
|
+
* import { Suspense } from "react";
|
|
312
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
313
|
+
*
|
|
314
|
+
* const listQuery = gql`
|
|
315
|
+
* query {
|
|
316
|
+
* list {
|
|
317
|
+
* id
|
|
318
|
+
* }
|
|
319
|
+
* }
|
|
320
|
+
* `;
|
|
242
321
|
*
|
|
322
|
+
* function App() {
|
|
323
|
+
* return (
|
|
324
|
+
* <Suspense fallback={<Spinner />}>
|
|
325
|
+
* <List />
|
|
326
|
+
* </Suspense>
|
|
327
|
+
* );
|
|
328
|
+
* }
|
|
329
|
+
*
|
|
330
|
+
* function List() {
|
|
331
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
332
|
+
*
|
|
333
|
+
* return (
|
|
334
|
+
* <ol>
|
|
335
|
+
* {data.list.map((item) => (
|
|
336
|
+
* <Item key={item.id} id={item.id} />
|
|
337
|
+
* ))}
|
|
338
|
+
* </ol>
|
|
339
|
+
* );
|
|
340
|
+
* }
|
|
341
|
+
* ```
|
|
342
|
+
*
|
|
343
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
344
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
243
345
|
*/
|
|
244
346
|
interface Classic {
|
|
245
347
|
/**
|
|
348
|
+
* @deprecated Avoid manually specifying generic arguments on `useSuspenseQuery`.
|
|
349
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
350
|
+
*
|
|
351
|
+
*
|
|
352
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
353
|
+
*
|
|
354
|
+
* @example
|
|
355
|
+
*
|
|
356
|
+
* ```jsx
|
|
357
|
+
* import { Suspense } from "react";
|
|
358
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
359
|
+
*
|
|
360
|
+
* const listQuery = gql`
|
|
361
|
+
* query {
|
|
362
|
+
* list {
|
|
363
|
+
* id
|
|
364
|
+
* }
|
|
365
|
+
* }
|
|
366
|
+
* `;
|
|
367
|
+
*
|
|
368
|
+
* function App() {
|
|
369
|
+
* return (
|
|
370
|
+
* <Suspense fallback={<Spinner />}>
|
|
371
|
+
* <List />
|
|
372
|
+
* </Suspense>
|
|
373
|
+
* );
|
|
374
|
+
* }
|
|
246
375
|
*
|
|
376
|
+
* function List() {
|
|
377
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
378
|
+
*
|
|
379
|
+
* return (
|
|
380
|
+
* <ol>
|
|
381
|
+
* {data.list.map((item) => (
|
|
382
|
+
* <Item key={item.id} id={item.id} />
|
|
383
|
+
* ))}
|
|
384
|
+
* </ol>
|
|
385
|
+
* );
|
|
386
|
+
* }
|
|
387
|
+
* ```
|
|
388
|
+
*
|
|
389
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
390
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
247
391
|
*/
|
|
248
392
|
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useSuspenseQuery.Options<NoInfer<TVariables>> & {
|
|
249
393
|
returnPartialData: true;
|
|
250
394
|
errorPolicy: "ignore" | "all";
|
|
251
395
|
}): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming" | "partial" | "empty">;
|
|
252
396
|
/**
|
|
397
|
+
* @deprecated Avoid manually specifying generic arguments on `useSuspenseQuery`.
|
|
398
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
399
|
+
*
|
|
400
|
+
*
|
|
401
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
402
|
+
*
|
|
403
|
+
* @example
|
|
404
|
+
*
|
|
405
|
+
* ```jsx
|
|
406
|
+
* import { Suspense } from "react";
|
|
407
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
408
|
+
*
|
|
409
|
+
* const listQuery = gql`
|
|
410
|
+
* query {
|
|
411
|
+
* list {
|
|
412
|
+
* id
|
|
413
|
+
* }
|
|
414
|
+
* }
|
|
415
|
+
* `;
|
|
416
|
+
*
|
|
417
|
+
* function App() {
|
|
418
|
+
* return (
|
|
419
|
+
* <Suspense fallback={<Spinner />}>
|
|
420
|
+
* <List />
|
|
421
|
+
* </Suspense>
|
|
422
|
+
* );
|
|
423
|
+
* }
|
|
424
|
+
*
|
|
425
|
+
* function List() {
|
|
426
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
253
427
|
*
|
|
428
|
+
* return (
|
|
429
|
+
* <ol>
|
|
430
|
+
* {data.list.map((item) => (
|
|
431
|
+
* <Item key={item.id} id={item.id} />
|
|
432
|
+
* ))}
|
|
433
|
+
* </ol>
|
|
434
|
+
* );
|
|
435
|
+
* }
|
|
436
|
+
* ```
|
|
437
|
+
*
|
|
438
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
439
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
254
440
|
*/
|
|
255
441
|
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useSuspenseQuery.Options<NoInfer<TVariables>> & {
|
|
256
442
|
errorPolicy: "ignore" | "all";
|
|
257
443
|
}): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming" | "empty">;
|
|
258
444
|
/**
|
|
445
|
+
* @deprecated Avoid manually specifying generic arguments on `useSuspenseQuery`.
|
|
446
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
447
|
+
*
|
|
448
|
+
*
|
|
449
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
450
|
+
*
|
|
451
|
+
* @example
|
|
452
|
+
*
|
|
453
|
+
* ```jsx
|
|
454
|
+
* import { Suspense } from "react";
|
|
455
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
456
|
+
*
|
|
457
|
+
* const listQuery = gql`
|
|
458
|
+
* query {
|
|
459
|
+
* list {
|
|
460
|
+
* id
|
|
461
|
+
* }
|
|
462
|
+
* }
|
|
463
|
+
* `;
|
|
464
|
+
*
|
|
465
|
+
* function App() {
|
|
466
|
+
* return (
|
|
467
|
+
* <Suspense fallback={<Spinner />}>
|
|
468
|
+
* <List />
|
|
469
|
+
* </Suspense>
|
|
470
|
+
* );
|
|
471
|
+
* }
|
|
472
|
+
*
|
|
473
|
+
* function List() {
|
|
474
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
259
475
|
*
|
|
476
|
+
* return (
|
|
477
|
+
* <ol>
|
|
478
|
+
* {data.list.map((item) => (
|
|
479
|
+
* <Item key={item.id} id={item.id} />
|
|
480
|
+
* ))}
|
|
481
|
+
* </ol>
|
|
482
|
+
* );
|
|
483
|
+
* }
|
|
484
|
+
* ```
|
|
485
|
+
*
|
|
486
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
487
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
260
488
|
*/
|
|
261
489
|
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useSuspenseQuery.Options<NoInfer<TVariables>> & {
|
|
262
490
|
skip: boolean;
|
|
263
491
|
returnPartialData: true;
|
|
264
492
|
}): useSuspenseQuery.Result<TData, TVariables, "complete" | "empty" | "streaming" | "partial">;
|
|
265
493
|
/**
|
|
494
|
+
* @deprecated Avoid manually specifying generic arguments on `useSuspenseQuery`.
|
|
495
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
496
|
+
*
|
|
497
|
+
*
|
|
498
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
499
|
+
*
|
|
500
|
+
* @example
|
|
266
501
|
*
|
|
502
|
+
* ```jsx
|
|
503
|
+
* import { Suspense } from "react";
|
|
504
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
505
|
+
*
|
|
506
|
+
* const listQuery = gql`
|
|
507
|
+
* query {
|
|
508
|
+
* list {
|
|
509
|
+
* id
|
|
510
|
+
* }
|
|
511
|
+
* }
|
|
512
|
+
* `;
|
|
513
|
+
*
|
|
514
|
+
* function App() {
|
|
515
|
+
* return (
|
|
516
|
+
* <Suspense fallback={<Spinner />}>
|
|
517
|
+
* <List />
|
|
518
|
+
* </Suspense>
|
|
519
|
+
* );
|
|
520
|
+
* }
|
|
521
|
+
*
|
|
522
|
+
* function List() {
|
|
523
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
524
|
+
*
|
|
525
|
+
* return (
|
|
526
|
+
* <ol>
|
|
527
|
+
* {data.list.map((item) => (
|
|
528
|
+
* <Item key={item.id} id={item.id} />
|
|
529
|
+
* ))}
|
|
530
|
+
* </ol>
|
|
531
|
+
* );
|
|
532
|
+
* }
|
|
533
|
+
* ```
|
|
534
|
+
*
|
|
535
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
536
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
267
537
|
*/
|
|
268
538
|
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useSuspenseQuery.Options<NoInfer<TVariables>> & {
|
|
269
539
|
returnPartialData: true;
|
|
270
540
|
}): useSuspenseQuery.Result<TData, TVariables, "partial" | "streaming" | "complete">;
|
|
271
541
|
/**
|
|
542
|
+
* @deprecated Avoid manually specifying generic arguments on `useSuspenseQuery`.
|
|
543
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
544
|
+
*
|
|
545
|
+
*
|
|
546
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
547
|
+
*
|
|
548
|
+
* @example
|
|
549
|
+
*
|
|
550
|
+
* ```jsx
|
|
551
|
+
* import { Suspense } from "react";
|
|
552
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
553
|
+
*
|
|
554
|
+
* const listQuery = gql`
|
|
555
|
+
* query {
|
|
556
|
+
* list {
|
|
557
|
+
* id
|
|
558
|
+
* }
|
|
559
|
+
* }
|
|
560
|
+
* `;
|
|
561
|
+
*
|
|
562
|
+
* function App() {
|
|
563
|
+
* return (
|
|
564
|
+
* <Suspense fallback={<Spinner />}>
|
|
565
|
+
* <List />
|
|
566
|
+
* </Suspense>
|
|
567
|
+
* );
|
|
568
|
+
* }
|
|
569
|
+
*
|
|
570
|
+
* function List() {
|
|
571
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
572
|
+
*
|
|
573
|
+
* return (
|
|
574
|
+
* <ol>
|
|
575
|
+
* {data.list.map((item) => (
|
|
576
|
+
* <Item key={item.id} id={item.id} />
|
|
577
|
+
* ))}
|
|
578
|
+
* </ol>
|
|
579
|
+
* );
|
|
580
|
+
* }
|
|
581
|
+
* ```
|
|
272
582
|
*
|
|
583
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
584
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
273
585
|
*/
|
|
274
586
|
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useSuspenseQuery.Options<NoInfer<TVariables>> & {
|
|
275
587
|
skip: boolean;
|
|
276
588
|
}): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming" | "empty">;
|
|
277
589
|
/**
|
|
590
|
+
* @deprecated Avoid manually specifying generic arguments on `useSuspenseQuery`.
|
|
591
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
592
|
+
*
|
|
593
|
+
*
|
|
594
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
595
|
+
*
|
|
596
|
+
* @example
|
|
597
|
+
*
|
|
598
|
+
* ```jsx
|
|
599
|
+
* import { Suspense } from "react";
|
|
600
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
601
|
+
*
|
|
602
|
+
* const listQuery = gql`
|
|
603
|
+
* query {
|
|
604
|
+
* list {
|
|
605
|
+
* id
|
|
606
|
+
* }
|
|
607
|
+
* }
|
|
608
|
+
* `;
|
|
609
|
+
*
|
|
610
|
+
* function App() {
|
|
611
|
+
* return (
|
|
612
|
+
* <Suspense fallback={<Spinner />}>
|
|
613
|
+
* <List />
|
|
614
|
+
* </Suspense>
|
|
615
|
+
* );
|
|
616
|
+
* }
|
|
617
|
+
*
|
|
618
|
+
* function List() {
|
|
619
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
620
|
+
*
|
|
621
|
+
* return (
|
|
622
|
+
* <ol>
|
|
623
|
+
* {data.list.map((item) => (
|
|
624
|
+
* <Item key={item.id} id={item.id} />
|
|
625
|
+
* ))}
|
|
626
|
+
* </ol>
|
|
627
|
+
* );
|
|
628
|
+
* }
|
|
629
|
+
* ```
|
|
278
630
|
*
|
|
631
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
632
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
279
633
|
*/
|
|
280
634
|
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (useSuspenseQuery.Options<NoInfer<TVariables>> & {
|
|
281
635
|
returnPartialData: true;
|
|
282
636
|
})): useSuspenseQuery.Result<TData, TVariables, "empty" | "streaming" | "complete" | "partial">;
|
|
283
637
|
/**
|
|
638
|
+
* @deprecated Avoid manually specifying generic arguments on `useSuspenseQuery`.
|
|
639
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
284
640
|
*
|
|
641
|
+
*
|
|
642
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
643
|
+
*
|
|
644
|
+
* @example
|
|
645
|
+
*
|
|
646
|
+
* ```jsx
|
|
647
|
+
* import { Suspense } from "react";
|
|
648
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
649
|
+
*
|
|
650
|
+
* const listQuery = gql`
|
|
651
|
+
* query {
|
|
652
|
+
* list {
|
|
653
|
+
* id
|
|
654
|
+
* }
|
|
655
|
+
* }
|
|
656
|
+
* `;
|
|
657
|
+
*
|
|
658
|
+
* function App() {
|
|
659
|
+
* return (
|
|
660
|
+
* <Suspense fallback={<Spinner />}>
|
|
661
|
+
* <List />
|
|
662
|
+
* </Suspense>
|
|
663
|
+
* );
|
|
664
|
+
* }
|
|
665
|
+
*
|
|
666
|
+
* function List() {
|
|
667
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
668
|
+
*
|
|
669
|
+
* return (
|
|
670
|
+
* <ol>
|
|
671
|
+
* {data.list.map((item) => (
|
|
672
|
+
* <Item key={item.id} id={item.id} />
|
|
673
|
+
* ))}
|
|
674
|
+
* </ol>
|
|
675
|
+
* );
|
|
676
|
+
* }
|
|
677
|
+
* ```
|
|
678
|
+
*
|
|
679
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
680
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
285
681
|
*/
|
|
286
682
|
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
|
|
287
683
|
options?: useSuspenseQuery.Options<NoInfer<TVariables>>
|
|
288
684
|
] : [options: useSuspenseQuery.Options<NoInfer<TVariables>>]): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming">;
|
|
289
685
|
/**
|
|
686
|
+
* @deprecated Avoid manually specifying generic arguments on `useSuspenseQuery`.
|
|
687
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
688
|
+
*
|
|
290
689
|
*
|
|
690
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
691
|
+
*
|
|
692
|
+
* @example
|
|
693
|
+
*
|
|
694
|
+
* ```jsx
|
|
695
|
+
* import { Suspense } from "react";
|
|
696
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
697
|
+
*
|
|
698
|
+
* const listQuery = gql`
|
|
699
|
+
* query {
|
|
700
|
+
* list {
|
|
701
|
+
* id
|
|
702
|
+
* }
|
|
703
|
+
* }
|
|
704
|
+
* `;
|
|
705
|
+
*
|
|
706
|
+
* function App() {
|
|
707
|
+
* return (
|
|
708
|
+
* <Suspense fallback={<Spinner />}>
|
|
709
|
+
* <List />
|
|
710
|
+
* </Suspense>
|
|
711
|
+
* );
|
|
712
|
+
* }
|
|
713
|
+
*
|
|
714
|
+
* function List() {
|
|
715
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
716
|
+
*
|
|
717
|
+
* return (
|
|
718
|
+
* <ol>
|
|
719
|
+
* {data.list.map((item) => (
|
|
720
|
+
* <Item key={item.id} id={item.id} />
|
|
721
|
+
* ))}
|
|
722
|
+
* </ol>
|
|
723
|
+
* );
|
|
724
|
+
* }
|
|
725
|
+
* ```
|
|
726
|
+
*
|
|
727
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
728
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
291
729
|
*/
|
|
292
730
|
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
|
|
293
731
|
options?: SkipToken | useSuspenseQuery.Options<NoInfer<TVariables>>
|
|
294
732
|
] : [options: SkipToken | useSuspenseQuery.Options<NoInfer<TVariables>>]): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming" | "empty">;
|
|
295
733
|
/**
|
|
734
|
+
* @deprecated Avoid manually specifying generic arguments on `useSuspenseQuery`.
|
|
735
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
736
|
+
*
|
|
737
|
+
*
|
|
738
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
296
739
|
*
|
|
740
|
+
* @example
|
|
741
|
+
*
|
|
742
|
+
* ```jsx
|
|
743
|
+
* import { Suspense } from "react";
|
|
744
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
745
|
+
*
|
|
746
|
+
* const listQuery = gql`
|
|
747
|
+
* query {
|
|
748
|
+
* list {
|
|
749
|
+
* id
|
|
750
|
+
* }
|
|
751
|
+
* }
|
|
752
|
+
* `;
|
|
753
|
+
*
|
|
754
|
+
* function App() {
|
|
755
|
+
* return (
|
|
756
|
+
* <Suspense fallback={<Spinner />}>
|
|
757
|
+
* <List />
|
|
758
|
+
* </Suspense>
|
|
759
|
+
* );
|
|
760
|
+
* }
|
|
761
|
+
*
|
|
762
|
+
* function List() {
|
|
763
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
764
|
+
*
|
|
765
|
+
* return (
|
|
766
|
+
* <ol>
|
|
767
|
+
* {data.list.map((item) => (
|
|
768
|
+
* <Item key={item.id} id={item.id} />
|
|
769
|
+
* ))}
|
|
770
|
+
* </ol>
|
|
771
|
+
* );
|
|
772
|
+
* }
|
|
773
|
+
* ```
|
|
774
|
+
*
|
|
775
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
776
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
297
777
|
*/
|
|
298
778
|
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | useSuspenseQuery.Options<NoInfer<TVariables>>): useSuspenseQuery.Result<TData, TVariables, "complete" | "streaming" | "empty">;
|
|
299
779
|
}
|
|
300
780
|
/**
|
|
781
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
782
|
+
*
|
|
783
|
+
* @example
|
|
784
|
+
*
|
|
785
|
+
* ```jsx
|
|
786
|
+
* import { Suspense } from "react";
|
|
787
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
301
788
|
*
|
|
789
|
+
* const listQuery = gql`
|
|
790
|
+
* query {
|
|
791
|
+
* list {
|
|
792
|
+
* id
|
|
793
|
+
* }
|
|
794
|
+
* }
|
|
795
|
+
* `;
|
|
796
|
+
*
|
|
797
|
+
* function App() {
|
|
798
|
+
* return (
|
|
799
|
+
* <Suspense fallback={<Spinner />}>
|
|
800
|
+
* <List />
|
|
801
|
+
* </Suspense>
|
|
802
|
+
* );
|
|
803
|
+
* }
|
|
804
|
+
*
|
|
805
|
+
* function List() {
|
|
806
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
807
|
+
*
|
|
808
|
+
* return (
|
|
809
|
+
* <ol>
|
|
810
|
+
* {data.list.map((item) => (
|
|
811
|
+
* <Item key={item.id} id={item.id} />
|
|
812
|
+
* ))}
|
|
813
|
+
* </ol>
|
|
814
|
+
* );
|
|
815
|
+
* }
|
|
816
|
+
* ```
|
|
817
|
+
*
|
|
818
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
819
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
302
820
|
*/
|
|
303
821
|
interface Modern {
|
|
304
822
|
/**
|
|
823
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
824
|
+
*
|
|
825
|
+
* @example
|
|
305
826
|
*
|
|
827
|
+
* ```jsx
|
|
828
|
+
* import { Suspense } from "react";
|
|
829
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
830
|
+
*
|
|
831
|
+
* const listQuery = gql`
|
|
832
|
+
* query {
|
|
833
|
+
* list {
|
|
834
|
+
* id
|
|
835
|
+
* }
|
|
836
|
+
* }
|
|
837
|
+
* `;
|
|
838
|
+
*
|
|
839
|
+
* function App() {
|
|
840
|
+
* return (
|
|
841
|
+
* <Suspense fallback={<Spinner />}>
|
|
842
|
+
* <List />
|
|
843
|
+
* </Suspense>
|
|
844
|
+
* );
|
|
845
|
+
* }
|
|
846
|
+
*
|
|
847
|
+
* function List() {
|
|
848
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
849
|
+
*
|
|
850
|
+
* return (
|
|
851
|
+
* <ol>
|
|
852
|
+
* {data.list.map((item) => (
|
|
853
|
+
* <Item key={item.id} id={item.id} />
|
|
854
|
+
* ))}
|
|
855
|
+
* </ol>
|
|
856
|
+
* );
|
|
857
|
+
* }
|
|
858
|
+
* ```
|
|
859
|
+
*
|
|
860
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
861
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
306
862
|
*/
|
|
307
863
|
<TData, TVariables extends OperationVariables, Options extends never>(query: {} extends TVariables ? DocumentNode | TypedDocumentNode<TData, TVariables> : never): useSuspenseQuery.ResultForOptions<TData, TVariables, Record<string, never>>;
|
|
308
864
|
/**
|
|
865
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
866
|
+
*
|
|
867
|
+
* @example
|
|
868
|
+
*
|
|
869
|
+
* ```jsx
|
|
870
|
+
* import { Suspense } from "react";
|
|
871
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
872
|
+
*
|
|
873
|
+
* const listQuery = gql`
|
|
874
|
+
* query {
|
|
875
|
+
* list {
|
|
876
|
+
* id
|
|
877
|
+
* }
|
|
878
|
+
* }
|
|
879
|
+
* `;
|
|
880
|
+
*
|
|
881
|
+
* function App() {
|
|
882
|
+
* return (
|
|
883
|
+
* <Suspense fallback={<Spinner />}>
|
|
884
|
+
* <List />
|
|
885
|
+
* </Suspense>
|
|
886
|
+
* );
|
|
887
|
+
* }
|
|
309
888
|
*
|
|
889
|
+
* function List() {
|
|
890
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
891
|
+
*
|
|
892
|
+
* return (
|
|
893
|
+
* <ol>
|
|
894
|
+
* {data.list.map((item) => (
|
|
895
|
+
* <Item key={item.id} id={item.id} />
|
|
896
|
+
* ))}
|
|
897
|
+
* </ol>
|
|
898
|
+
* );
|
|
899
|
+
* }
|
|
900
|
+
* ```
|
|
901
|
+
*
|
|
902
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
903
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
310
904
|
*/
|
|
311
905
|
<TData, TVariables extends OperationVariables, TOptions extends never>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, skipToken: SkipToken): useSuspenseQuery.ResultForOptions<TData, TVariables, SkipToken>;
|
|
312
906
|
/**
|
|
907
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
908
|
+
*
|
|
909
|
+
* @example
|
|
313
910
|
*
|
|
911
|
+
* ```jsx
|
|
912
|
+
* import { Suspense } from "react";
|
|
913
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
914
|
+
*
|
|
915
|
+
* const listQuery = gql`
|
|
916
|
+
* query {
|
|
917
|
+
* list {
|
|
918
|
+
* id
|
|
919
|
+
* }
|
|
920
|
+
* }
|
|
921
|
+
* `;
|
|
922
|
+
*
|
|
923
|
+
* function App() {
|
|
924
|
+
* return (
|
|
925
|
+
* <Suspense fallback={<Spinner />}>
|
|
926
|
+
* <List />
|
|
927
|
+
* </Suspense>
|
|
928
|
+
* );
|
|
929
|
+
* }
|
|
930
|
+
*
|
|
931
|
+
* function List() {
|
|
932
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
933
|
+
*
|
|
934
|
+
* return (
|
|
935
|
+
* <ol>
|
|
936
|
+
* {data.list.map((item) => (
|
|
937
|
+
* <Item key={item.id} id={item.id} />
|
|
938
|
+
* ))}
|
|
939
|
+
* </ol>
|
|
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 `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
314
946
|
*/
|
|
315
947
|
<TData, TVariables extends OperationVariables, TOptions extends useSuspenseQuery.Options<NoInfer<TVariables>> & VariablesOption<TVariables & {
|
|
316
948
|
[K in Exclude<keyof TOptions["variables"], keyof TVariables>]?: never;
|
|
317
949
|
}>>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [options?: TOptions] : [options: TOptions]): useSuspenseQuery.ResultForOptions<TData, TVariables, TOptions>;
|
|
318
950
|
/**
|
|
951
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
952
|
+
*
|
|
953
|
+
* @example
|
|
954
|
+
*
|
|
955
|
+
* ```jsx
|
|
956
|
+
* import { Suspense } from "react";
|
|
957
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
958
|
+
*
|
|
959
|
+
* const listQuery = gql`
|
|
960
|
+
* query {
|
|
961
|
+
* list {
|
|
962
|
+
* id
|
|
963
|
+
* }
|
|
964
|
+
* }
|
|
965
|
+
* `;
|
|
966
|
+
*
|
|
967
|
+
* function App() {
|
|
968
|
+
* return (
|
|
969
|
+
* <Suspense fallback={<Spinner />}>
|
|
970
|
+
* <List />
|
|
971
|
+
* </Suspense>
|
|
972
|
+
* );
|
|
973
|
+
* }
|
|
319
974
|
*
|
|
975
|
+
* function List() {
|
|
976
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
977
|
+
*
|
|
978
|
+
* return (
|
|
979
|
+
* <ol>
|
|
980
|
+
* {data.list.map((item) => (
|
|
981
|
+
* <Item key={item.id} id={item.id} />
|
|
982
|
+
* ))}
|
|
983
|
+
* </ol>
|
|
984
|
+
* );
|
|
985
|
+
* }
|
|
986
|
+
* ```
|
|
987
|
+
*
|
|
988
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
989
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
320
990
|
*/
|
|
321
991
|
<TData, TVariables extends OperationVariables, TOptions extends useSuspenseQuery.Options<NoInfer<TVariables>> & VariablesOption<TVariables & {
|
|
322
992
|
[K in Exclude<keyof TOptions["variables"], keyof TVariables>]?: never;
|
|
@@ -325,7 +995,45 @@ export declare namespace useSuspenseQuery {
|
|
|
325
995
|
type Evaluated = SignatureStyle extends "classic" ? Classic : Modern;
|
|
326
996
|
}
|
|
327
997
|
/**
|
|
998
|
+
* For a detailed explanation of `useSuspenseQuery`, see the [fetching with Suspense reference](https://www.apollographql.com/docs/react/data/suspense).
|
|
999
|
+
*
|
|
1000
|
+
* @example
|
|
1001
|
+
*
|
|
1002
|
+
* ```jsx
|
|
1003
|
+
* import { Suspense } from "react";
|
|
1004
|
+
* import { useSuspenseQuery } from "@apollo/client";
|
|
1005
|
+
*
|
|
1006
|
+
* const listQuery = gql`
|
|
1007
|
+
* query {
|
|
1008
|
+
* list {
|
|
1009
|
+
* id
|
|
1010
|
+
* }
|
|
1011
|
+
* }
|
|
1012
|
+
* `;
|
|
1013
|
+
*
|
|
1014
|
+
* function App() {
|
|
1015
|
+
* return (
|
|
1016
|
+
* <Suspense fallback={<Spinner />}>
|
|
1017
|
+
* <List />
|
|
1018
|
+
* </Suspense>
|
|
1019
|
+
* );
|
|
1020
|
+
* }
|
|
1021
|
+
*
|
|
1022
|
+
* function List() {
|
|
1023
|
+
* const { data } = useSuspenseQuery(listQuery);
|
|
1024
|
+
*
|
|
1025
|
+
* return (
|
|
1026
|
+
* <ol>
|
|
1027
|
+
* {data.list.map((item) => (
|
|
1028
|
+
* <Item key={item.id} id={item.id} />
|
|
1029
|
+
* ))}
|
|
1030
|
+
* </ol>
|
|
1031
|
+
* );
|
|
1032
|
+
* }
|
|
1033
|
+
* ```
|
|
328
1034
|
*
|
|
1035
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
1036
|
+
* @param options - An optional object containing options for the query. Instead of passing a `useSuspenseQuery.Options` object into the hook, you can also pass a [`skipToken`](#skiptoken) to prevent the `useSuspenseQuery` hook from executing the query or suspending.
|
|
329
1037
|
*/
|
|
330
1038
|
interface Signature extends Signatures.Evaluated {
|
|
331
1039
|
}
|