@apollo/client 4.2.0-alpha.1 → 4.2.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +209 -0
- package/__cjs/core/ApolloClient.cjs +25 -12
- package/__cjs/core/ApolloClient.cjs.map +1 -1
- package/__cjs/core/ApolloClient.d.cts +305 -146
- package/__cjs/core/QueryManager.cjs.map +1 -1
- package/__cjs/core/defaultOptions.cjs +3 -0
- package/__cjs/core/defaultOptions.cjs.map +1 -0
- package/__cjs/core/defaultOptions.d.cts +90 -0
- package/__cjs/core/index.cjs.map +1 -1
- package/__cjs/core/index.d.cts +2 -1
- package/__cjs/link/ws/index.cjs +9 -1
- package/__cjs/link/ws/index.cjs.map +1 -1
- package/__cjs/link/ws/index.d.cts +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.cjs +3 -3
- package/__cjs/react/hooks/useBackgroundQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useBackgroundQuery.d.cts +1598 -765
- package/__cjs/react/hooks/useLazyQuery.cjs +3 -5
- package/__cjs/react/hooks/useLazyQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLazyQuery.d.cts +369 -115
- package/__cjs/react/hooks/useLoadableQuery.cjs +8 -4
- package/__cjs/react/hooks/useLoadableQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useLoadableQuery.d.cts +507 -192
- package/__cjs/react/hooks/useMutation.cjs +5 -48
- package/__cjs/react/hooks/useMutation.cjs.map +1 -1
- package/__cjs/react/hooks/useMutation.d.cts +239 -130
- package/__cjs/react/hooks/useQuery.cjs +5 -5
- package/__cjs/react/hooks/useQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useQuery.d.cts +636 -276
- package/__cjs/react/hooks/useSubscription.cjs +1 -1
- package/__cjs/react/hooks/useSubscription.cjs.map +1 -1
- package/__cjs/react/hooks/useSubscription.d.cts +2 -2
- package/__cjs/react/hooks/useSuspenseQuery.cjs +3 -3
- package/__cjs/react/hooks/useSuspenseQuery.cjs.map +1 -1
- package/__cjs/react/hooks/useSuspenseQuery.d.cts +799 -399
- package/__cjs/react/internal/cache/getSuspenseCache.cjs.map +1 -1
- package/__cjs/react/internal/cache/getSuspenseCache.d.cts +7 -0
- package/__cjs/utilities/internal/LazyType.cjs +3 -0
- package/__cjs/utilities/internal/LazyType.cjs.map +1 -0
- package/__cjs/utilities/internal/LazyType.d.cts +10 -0
- package/__cjs/utilities/internal/index.cjs.map +1 -1
- package/__cjs/utilities/internal/index.d.cts +3 -0
- package/__cjs/utilities/internal/types/OptionWithFallback.cjs +3 -0
- package/__cjs/utilities/internal/types/OptionWithFallback.cjs.map +1 -0
- package/__cjs/utilities/internal/types/OptionWithFallback.d.cts +5 -0
- package/__cjs/utilities/internal/types/SignatureStyle.cjs +3 -0
- package/__cjs/utilities/internal/types/SignatureStyle.cjs.map +1 -0
- package/__cjs/utilities/internal/types/SignatureStyle.d.cts +24 -0
- package/__cjs/version.cjs +1 -1
- package/core/ApolloClient.d.ts +305 -146
- package/core/ApolloClient.js +25 -12
- package/core/ApolloClient.js.map +1 -1
- package/core/QueryManager.js.map +1 -1
- package/core/defaultOptions.d.ts +90 -0
- package/core/defaultOptions.js +2 -0
- package/core/defaultOptions.js.map +1 -0
- package/core/index.d.ts +2 -1
- package/core/index.js.map +1 -1
- package/link/ws/index.d.ts +1 -1
- package/link/ws/index.js +9 -1
- package/link/ws/index.js.map +1 -1
- package/package.json +3 -7
- package/react/hooks/useBackgroundQuery.d.ts +1598 -765
- package/react/hooks/useBackgroundQuery.js +2 -2
- package/react/hooks/useBackgroundQuery.js.map +1 -1
- package/react/hooks/useLazyQuery.d.ts +369 -115
- package/react/hooks/useLazyQuery.js +2 -4
- package/react/hooks/useLazyQuery.js.map +1 -1
- package/react/hooks/useLoadableQuery.d.ts +507 -192
- package/react/hooks/useLoadableQuery.js +7 -3
- package/react/hooks/useLoadableQuery.js.map +1 -1
- package/react/hooks/useMutation.d.ts +239 -130
- package/react/hooks/useMutation.js +5 -48
- package/react/hooks/useMutation.js.map +1 -1
- package/react/hooks/useQuery.d.ts +636 -276
- package/react/hooks/useQuery.js +2 -2
- package/react/hooks/useQuery.js.map +1 -1
- package/react/hooks/useSubscription.d.ts +2 -2
- package/react/hooks/useSubscription.js +1 -1
- package/react/hooks/useSubscription.js.map +1 -1
- package/react/hooks/useSuspenseQuery.d.ts +799 -399
- package/react/hooks/useSuspenseQuery.js +2 -2
- package/react/hooks/useSuspenseQuery.js.map +1 -1
- package/react/hooks-compiled/useBackgroundQuery.d.ts +1598 -765
- package/react/hooks-compiled/useBackgroundQuery.js +2 -2
- package/react/hooks-compiled/useBackgroundQuery.js.map +1 -1
- package/react/hooks-compiled/useLazyQuery.d.ts +369 -115
- package/react/hooks-compiled/useLazyQuery.js +2 -4
- package/react/hooks-compiled/useLazyQuery.js.map +1 -1
- package/react/hooks-compiled/useLoadableQuery.d.ts +507 -192
- package/react/hooks-compiled/useLoadableQuery.js +2 -2
- package/react/hooks-compiled/useLoadableQuery.js.map +1 -1
- package/react/hooks-compiled/useMutation.d.ts +239 -130
- package/react/hooks-compiled/useMutation.js +4 -47
- package/react/hooks-compiled/useMutation.js.map +1 -1
- package/react/hooks-compiled/useQuery.d.ts +636 -276
- package/react/hooks-compiled/useQuery.js +2 -2
- package/react/hooks-compiled/useQuery.js.map +1 -1
- package/react/hooks-compiled/useSubscription.d.ts +2 -2
- package/react/hooks-compiled/useSubscription.js +1 -1
- package/react/hooks-compiled/useSubscription.js.map +1 -1
- package/react/hooks-compiled/useSuspenseQuery.d.ts +799 -399
- package/react/hooks-compiled/useSuspenseQuery.js +2 -2
- package/react/hooks-compiled/useSuspenseQuery.js.map +1 -1
- package/react/internal/cache/getSuspenseCache.d.ts +7 -0
- package/react/internal/cache/getSuspenseCache.js.map +1 -1
- package/skills/apollo-client/SKILL.md +168 -0
- package/skills/apollo-client/references/caching.md +560 -0
- package/skills/apollo-client/references/error-handling.md +350 -0
- package/skills/apollo-client/references/fragments.md +804 -0
- package/skills/apollo-client/references/integration-client.md +336 -0
- package/skills/apollo-client/references/integration-nextjs.md +325 -0
- package/skills/apollo-client/references/integration-react-router.md +256 -0
- package/skills/apollo-client/references/integration-tanstack-start.md +378 -0
- package/skills/apollo-client/references/mutations.md +549 -0
- package/skills/apollo-client/references/queries.md +416 -0
- package/skills/apollo-client/references/state-management.md +428 -0
- package/skills/apollo-client/references/suspense-hooks.md +773 -0
- package/skills/apollo-client/references/troubleshooting.md +487 -0
- package/skills/apollo-client/references/typescript-codegen.md +133 -0
- package/utilities/internal/LazyType.d.ts +10 -0
- package/utilities/internal/LazyType.js +2 -0
- package/utilities/internal/LazyType.js.map +1 -0
- package/utilities/internal/index.d.ts +3 -0
- package/utilities/internal/index.js.map +1 -1
- package/utilities/internal/types/OptionWithFallback.d.ts +5 -0
- package/utilities/internal/types/OptionWithFallback.js +2 -0
- package/utilities/internal/types/OptionWithFallback.js.map +1 -0
- package/utilities/internal/types/SignatureStyle.d.ts +24 -0
- package/utilities/internal/types/SignatureStyle.js +2 -0
- package/utilities/internal/types/SignatureStyle.js.map +1 -0
- package/version.js +1 -1
|
@@ -2,7 +2,7 @@ import type { DataState, DefaultContext, DocumentNode, ErrorLike, ErrorPolicy, G
|
|
|
2
2
|
import type { ApolloClient } from "@apollo/client";
|
|
3
3
|
import { NetworkStatus } from "@apollo/client";
|
|
4
4
|
import type { MaybeMasked } from "@apollo/client/masking";
|
|
5
|
-
import type { DocumentationTypes as UtilityDocumentationTypes, NoInfer, VariablesOption } from "@apollo/client/utilities/internal";
|
|
5
|
+
import type { DocumentationTypes as UtilityDocumentationTypes, LazyType, NoInfer, OptionWithFallback, SignatureStyle, VariablesOption } from "@apollo/client/utilities/internal";
|
|
6
6
|
import type { SkipToken } from "./constants.cjs";
|
|
7
7
|
export declare namespace useQuery {
|
|
8
8
|
namespace Base {
|
|
@@ -226,6 +226,10 @@ export declare namespace useQuery {
|
|
|
226
226
|
}
|
|
227
227
|
}
|
|
228
228
|
type Result<TData = unknown, TVariables extends OperationVariables = OperationVariables, TStates extends DataState<TData>["dataState"] = DataState<TData>["dataState"], TReturnVariables extends OperationVariables = TVariables> = Base.Result<TData, TVariables, TReturnVariables> & GetDataState<MaybeMasked<TData>, TStates>;
|
|
229
|
+
interface DefaultOptions extends ApolloClient.DefaultOptions.WatchQuery.Calculated {
|
|
230
|
+
skip: false;
|
|
231
|
+
}
|
|
232
|
+
type ResultForOptions<TData, TVariables extends OperationVariables, TOptions extends Record<string, never> | Options<TData, TVariables> | SkipToken> = LazyType<Result<TData, TVariables, "complete" | "streaming" | "empty" | (TOptions extends any ? TOptions extends SkipToken ? never : OptionWithFallback<TOptions, DefaultOptions, "returnPartialData"> extends false ? never : "partial" : never)>>;
|
|
229
233
|
namespace DocumentationTypes {
|
|
230
234
|
namespace useQuery {
|
|
231
235
|
interface Result<TData = unknown, TVariables extends OperationVariables = OperationVariables> extends Base.Result<TData, TVariables>, UtilityDocumentationTypes.DataState<TData> {
|
|
@@ -233,6 +237,434 @@ export declare namespace useQuery {
|
|
|
233
237
|
}
|
|
234
238
|
}
|
|
235
239
|
namespace DocumentationTypes {
|
|
240
|
+
interface useQuery {
|
|
241
|
+
/**
|
|
242
|
+
* A hook for executing queries in an Apollo application.
|
|
243
|
+
*
|
|
244
|
+
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
245
|
+
*
|
|
246
|
+
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
247
|
+
*
|
|
248
|
+
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
*
|
|
252
|
+
* ```jsx
|
|
253
|
+
* import { gql } from "@apollo/client";
|
|
254
|
+
* import { useQuery } from "@apollo/client/react";
|
|
255
|
+
*
|
|
256
|
+
* const GET_GREETING = gql`
|
|
257
|
+
* query GetGreeting($language: String!) {
|
|
258
|
+
* greeting(language: $language) {
|
|
259
|
+
* message
|
|
260
|
+
* }
|
|
261
|
+
* }
|
|
262
|
+
* `;
|
|
263
|
+
*
|
|
264
|
+
* function Hello() {
|
|
265
|
+
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
266
|
+
* variables: { language: "english" },
|
|
267
|
+
* });
|
|
268
|
+
* if (loading) return <p>Loading ...</p>;
|
|
269
|
+
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
270
|
+
* }
|
|
271
|
+
* ```
|
|
272
|
+
*
|
|
273
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
274
|
+
* @param options - Options to control how the query is executed.
|
|
275
|
+
* @returns Query result object
|
|
276
|
+
*/
|
|
277
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useQuery.Options<TData, TVariables>): useQuery.Result<TData, TVariables>;
|
|
278
|
+
}
|
|
279
|
+
interface useQuery_Deprecated {
|
|
280
|
+
/**
|
|
281
|
+
* @deprecated Avoid manually specifying generics on `useQuery`.
|
|
282
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
283
|
+
*
|
|
284
|
+
*
|
|
285
|
+
* A hook for executing queries in an Apollo application.
|
|
286
|
+
*
|
|
287
|
+
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
288
|
+
*
|
|
289
|
+
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
290
|
+
*
|
|
291
|
+
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
*
|
|
295
|
+
* ```jsx
|
|
296
|
+
* import { gql } from "@apollo/client";
|
|
297
|
+
* import { useQuery } from "@apollo/client/react";
|
|
298
|
+
*
|
|
299
|
+
* const GET_GREETING = gql`
|
|
300
|
+
* query GetGreeting($language: String!) {
|
|
301
|
+
* greeting(language: $language) {
|
|
302
|
+
* message
|
|
303
|
+
* }
|
|
304
|
+
* }
|
|
305
|
+
* `;
|
|
306
|
+
*
|
|
307
|
+
* function Hello() {
|
|
308
|
+
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
309
|
+
* variables: { language: "english" },
|
|
310
|
+
* });
|
|
311
|
+
* if (loading) return <p>Loading ...</p>;
|
|
312
|
+
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
313
|
+
* }
|
|
314
|
+
* ```
|
|
315
|
+
*
|
|
316
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
317
|
+
* @param options - Options to control how the query is executed.
|
|
318
|
+
* @returns Query result object
|
|
319
|
+
*/
|
|
320
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useQuery.Options<TData, TVariables>): useQuery.Result<TData, TVariables>;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
namespace Signatures {
|
|
324
|
+
/**
|
|
325
|
+
* @deprecated Avoid manually specifying generics on `useQuery`.
|
|
326
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
327
|
+
*
|
|
328
|
+
*
|
|
329
|
+
* A hook for executing queries in an Apollo application.
|
|
330
|
+
*
|
|
331
|
+
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
332
|
+
*
|
|
333
|
+
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
334
|
+
*
|
|
335
|
+
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
336
|
+
*
|
|
337
|
+
* @example
|
|
338
|
+
*
|
|
339
|
+
* ```jsx
|
|
340
|
+
* import { gql } from "@apollo/client";
|
|
341
|
+
* import { useQuery } from "@apollo/client/react";
|
|
342
|
+
*
|
|
343
|
+
* const GET_GREETING = gql`
|
|
344
|
+
* query GetGreeting($language: String!) {
|
|
345
|
+
* greeting(language: $language) {
|
|
346
|
+
* message
|
|
347
|
+
* }
|
|
348
|
+
* }
|
|
349
|
+
* `;
|
|
350
|
+
*
|
|
351
|
+
* function Hello() {
|
|
352
|
+
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
353
|
+
* variables: { language: "english" },
|
|
354
|
+
* });
|
|
355
|
+
* if (loading) return <p>Loading ...</p>;
|
|
356
|
+
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
357
|
+
* }
|
|
358
|
+
* ```
|
|
359
|
+
*
|
|
360
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
361
|
+
* @param options - Options to control how the query is executed.
|
|
362
|
+
* @returns Query result object
|
|
363
|
+
*/
|
|
364
|
+
interface Classic {
|
|
365
|
+
/**
|
|
366
|
+
* @deprecated Avoid manually specifying generics on `useQuery`.
|
|
367
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
368
|
+
*
|
|
369
|
+
*
|
|
370
|
+
* A hook for executing queries in an Apollo application.
|
|
371
|
+
*
|
|
372
|
+
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
373
|
+
*
|
|
374
|
+
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
375
|
+
*
|
|
376
|
+
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
377
|
+
*
|
|
378
|
+
* @example
|
|
379
|
+
*
|
|
380
|
+
* ```jsx
|
|
381
|
+
* import { gql } from "@apollo/client";
|
|
382
|
+
* import { useQuery } from "@apollo/client/react";
|
|
383
|
+
*
|
|
384
|
+
* const GET_GREETING = gql`
|
|
385
|
+
* query GetGreeting($language: String!) {
|
|
386
|
+
* greeting(language: $language) {
|
|
387
|
+
* message
|
|
388
|
+
* }
|
|
389
|
+
* }
|
|
390
|
+
* `;
|
|
391
|
+
*
|
|
392
|
+
* function Hello() {
|
|
393
|
+
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
394
|
+
* variables: { language: "english" },
|
|
395
|
+
* });
|
|
396
|
+
* if (loading) return <p>Loading ...</p>;
|
|
397
|
+
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
398
|
+
* }
|
|
399
|
+
* ```
|
|
400
|
+
*
|
|
401
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
402
|
+
* @param options - Options to control how the query is executed.
|
|
403
|
+
* @returns Query result object
|
|
404
|
+
*/
|
|
405
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useQuery.Options<NoInfer<TData>, NoInfer<TVariables>> & {
|
|
406
|
+
returnPartialData: true;
|
|
407
|
+
}): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming" | "partial">;
|
|
408
|
+
/**
|
|
409
|
+
* @deprecated Avoid manually specifying generics on `useQuery`.
|
|
410
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
411
|
+
*
|
|
412
|
+
*
|
|
413
|
+
* A hook for executing queries in an Apollo application.
|
|
414
|
+
*
|
|
415
|
+
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
416
|
+
*
|
|
417
|
+
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
418
|
+
*
|
|
419
|
+
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
420
|
+
*
|
|
421
|
+
* @example
|
|
422
|
+
*
|
|
423
|
+
* ```jsx
|
|
424
|
+
* import { gql } from "@apollo/client";
|
|
425
|
+
* import { useQuery } from "@apollo/client/react";
|
|
426
|
+
*
|
|
427
|
+
* const GET_GREETING = gql`
|
|
428
|
+
* query GetGreeting($language: String!) {
|
|
429
|
+
* greeting(language: $language) {
|
|
430
|
+
* message
|
|
431
|
+
* }
|
|
432
|
+
* }
|
|
433
|
+
* `;
|
|
434
|
+
*
|
|
435
|
+
* function Hello() {
|
|
436
|
+
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
437
|
+
* variables: { language: "english" },
|
|
438
|
+
* });
|
|
439
|
+
* if (loading) return <p>Loading ...</p>;
|
|
440
|
+
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
441
|
+
* }
|
|
442
|
+
* ```
|
|
443
|
+
*
|
|
444
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
445
|
+
* @param options - Options to control how the query is executed.
|
|
446
|
+
* @returns Query result object
|
|
447
|
+
*/
|
|
448
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken): useQuery.Result<TData, TVariables, "empty", Record<string, never>>;
|
|
449
|
+
/**
|
|
450
|
+
* @deprecated Avoid manually specifying generics on `useQuery`.
|
|
451
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
452
|
+
*
|
|
453
|
+
*
|
|
454
|
+
* A hook for executing queries in an Apollo application.
|
|
455
|
+
*
|
|
456
|
+
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
457
|
+
*
|
|
458
|
+
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
459
|
+
*
|
|
460
|
+
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
461
|
+
*
|
|
462
|
+
* @example
|
|
463
|
+
*
|
|
464
|
+
* ```jsx
|
|
465
|
+
* import { gql } from "@apollo/client";
|
|
466
|
+
* import { useQuery } from "@apollo/client/react";
|
|
467
|
+
*
|
|
468
|
+
* const GET_GREETING = gql`
|
|
469
|
+
* query GetGreeting($language: String!) {
|
|
470
|
+
* greeting(language: $language) {
|
|
471
|
+
* message
|
|
472
|
+
* }
|
|
473
|
+
* }
|
|
474
|
+
* `;
|
|
475
|
+
*
|
|
476
|
+
* function Hello() {
|
|
477
|
+
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
478
|
+
* variables: { language: "english" },
|
|
479
|
+
* });
|
|
480
|
+
* if (loading) return <p>Loading ...</p>;
|
|
481
|
+
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
482
|
+
* }
|
|
483
|
+
* ```
|
|
484
|
+
*
|
|
485
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
486
|
+
* @param options - Options to control how the query is executed.
|
|
487
|
+
* @returns Query result object
|
|
488
|
+
*/
|
|
489
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (useQuery.Options<NoInfer<TData>, NoInfer<TVariables>> & {
|
|
490
|
+
returnPartialData: true;
|
|
491
|
+
})): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming" | "partial", Partial<TVariables>>;
|
|
492
|
+
/**
|
|
493
|
+
* @deprecated Avoid manually specifying generics on `useQuery`.
|
|
494
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
495
|
+
*
|
|
496
|
+
*
|
|
497
|
+
* A hook for executing queries in an Apollo application.
|
|
498
|
+
*
|
|
499
|
+
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
500
|
+
*
|
|
501
|
+
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
502
|
+
*
|
|
503
|
+
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
504
|
+
*
|
|
505
|
+
* @example
|
|
506
|
+
*
|
|
507
|
+
* ```jsx
|
|
508
|
+
* import { gql } from "@apollo/client";
|
|
509
|
+
* import { useQuery } from "@apollo/client/react";
|
|
510
|
+
*
|
|
511
|
+
* const GET_GREETING = gql`
|
|
512
|
+
* query GetGreeting($language: String!) {
|
|
513
|
+
* greeting(language: $language) {
|
|
514
|
+
* message
|
|
515
|
+
* }
|
|
516
|
+
* }
|
|
517
|
+
* `;
|
|
518
|
+
*
|
|
519
|
+
* function Hello() {
|
|
520
|
+
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
521
|
+
* variables: { language: "english" },
|
|
522
|
+
* });
|
|
523
|
+
* if (loading) return <p>Loading ...</p>;
|
|
524
|
+
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
525
|
+
* }
|
|
526
|
+
* ```
|
|
527
|
+
*
|
|
528
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
529
|
+
* @param options - Options to control how the query is executed.
|
|
530
|
+
* @returns Query result object
|
|
531
|
+
*/
|
|
532
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useQuery.Options<NoInfer<TData>, NoInfer<TVariables>> & {
|
|
533
|
+
returnPartialData: boolean;
|
|
534
|
+
}): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming" | "partial">;
|
|
535
|
+
/**
|
|
536
|
+
* @deprecated Avoid manually specifying generics on `useQuery`.
|
|
537
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
538
|
+
*
|
|
539
|
+
*
|
|
540
|
+
* A hook for executing queries in an Apollo application.
|
|
541
|
+
*
|
|
542
|
+
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
543
|
+
*
|
|
544
|
+
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
545
|
+
*
|
|
546
|
+
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
547
|
+
*
|
|
548
|
+
* @example
|
|
549
|
+
*
|
|
550
|
+
* ```jsx
|
|
551
|
+
* import { gql } from "@apollo/client";
|
|
552
|
+
* import { useQuery } from "@apollo/client/react";
|
|
553
|
+
*
|
|
554
|
+
* const GET_GREETING = gql`
|
|
555
|
+
* query GetGreeting($language: String!) {
|
|
556
|
+
* greeting(language: $language) {
|
|
557
|
+
* message
|
|
558
|
+
* }
|
|
559
|
+
* }
|
|
560
|
+
* `;
|
|
561
|
+
*
|
|
562
|
+
* function Hello() {
|
|
563
|
+
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
564
|
+
* variables: { language: "english" },
|
|
565
|
+
* });
|
|
566
|
+
* if (loading) return <p>Loading ...</p>;
|
|
567
|
+
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
568
|
+
* }
|
|
569
|
+
* ```
|
|
570
|
+
*
|
|
571
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
572
|
+
* @param options - Options to control how the query is executed.
|
|
573
|
+
* @returns Query result object
|
|
574
|
+
*/
|
|
575
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (useQuery.Options<NoInfer<TData>, NoInfer<TVariables>> & {
|
|
576
|
+
returnPartialData: boolean;
|
|
577
|
+
})): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming" | "partial", Partial<TVariables>>;
|
|
578
|
+
/**
|
|
579
|
+
* @deprecated Avoid manually specifying generics on `useQuery`.
|
|
580
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
581
|
+
*
|
|
582
|
+
*
|
|
583
|
+
* A hook for executing queries in an Apollo application.
|
|
584
|
+
*
|
|
585
|
+
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
586
|
+
*
|
|
587
|
+
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
588
|
+
*
|
|
589
|
+
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
590
|
+
*
|
|
591
|
+
* @example
|
|
592
|
+
*
|
|
593
|
+
* ```jsx
|
|
594
|
+
* import { gql } from "@apollo/client";
|
|
595
|
+
* import { useQuery } from "@apollo/client/react";
|
|
596
|
+
*
|
|
597
|
+
* const GET_GREETING = gql`
|
|
598
|
+
* query GetGreeting($language: String!) {
|
|
599
|
+
* greeting(language: $language) {
|
|
600
|
+
* message
|
|
601
|
+
* }
|
|
602
|
+
* }
|
|
603
|
+
* `;
|
|
604
|
+
*
|
|
605
|
+
* function Hello() {
|
|
606
|
+
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
607
|
+
* variables: { language: "english" },
|
|
608
|
+
* });
|
|
609
|
+
* if (loading) return <p>Loading ...</p>;
|
|
610
|
+
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
611
|
+
* }
|
|
612
|
+
* ```
|
|
613
|
+
*
|
|
614
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
615
|
+
* @param options - Options to control how the query is executed.
|
|
616
|
+
* @returns Query result object
|
|
617
|
+
*/
|
|
618
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
|
|
619
|
+
options?: useQuery.Options<NoInfer<TData>, NoInfer<TVariables>>
|
|
620
|
+
] : [options: useQuery.Options<NoInfer<TData>, NoInfer<TVariables>>]): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming">;
|
|
621
|
+
/**
|
|
622
|
+
* @deprecated Avoid manually specifying generics on `useQuery`.
|
|
623
|
+
* Instead, rely on TypeScript's type inference along with a correctly typed `TypedDocumentNode` to get accurate types for your query results.
|
|
624
|
+
*
|
|
625
|
+
*
|
|
626
|
+
* A hook for executing queries in an Apollo application.
|
|
627
|
+
*
|
|
628
|
+
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
629
|
+
*
|
|
630
|
+
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
631
|
+
*
|
|
632
|
+
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
633
|
+
*
|
|
634
|
+
* @example
|
|
635
|
+
*
|
|
636
|
+
* ```jsx
|
|
637
|
+
* import { gql } from "@apollo/client";
|
|
638
|
+
* import { useQuery } from "@apollo/client/react";
|
|
639
|
+
*
|
|
640
|
+
* const GET_GREETING = gql`
|
|
641
|
+
* query GetGreeting($language: String!) {
|
|
642
|
+
* greeting(language: $language) {
|
|
643
|
+
* message
|
|
644
|
+
* }
|
|
645
|
+
* }
|
|
646
|
+
* `;
|
|
647
|
+
*
|
|
648
|
+
* function Hello() {
|
|
649
|
+
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
650
|
+
* variables: { language: "english" },
|
|
651
|
+
* });
|
|
652
|
+
* if (loading) return <p>Loading ...</p>;
|
|
653
|
+
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
654
|
+
* }
|
|
655
|
+
* ```
|
|
656
|
+
*
|
|
657
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
658
|
+
* @param options - Options to control how the query is executed.
|
|
659
|
+
* @returns Query result object
|
|
660
|
+
*/
|
|
661
|
+
<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
|
|
662
|
+
options?: SkipToken | useQuery.Options<NoInfer<TData>, NoInfer<TVariables>>
|
|
663
|
+
] : [
|
|
664
|
+
options: SkipToken | useQuery.Options<NoInfer<TData>, NoInfer<TVariables>>
|
|
665
|
+
]): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming", Partial<TVariables>>;
|
|
666
|
+
ssrDisabledResult: ObservableQuery.Result<any>;
|
|
667
|
+
}
|
|
236
668
|
/**
|
|
237
669
|
* A hook for executing queries in an Apollo application.
|
|
238
670
|
*
|
|
@@ -269,281 +701,209 @@ export declare namespace useQuery {
|
|
|
269
701
|
* @param options - Options to control how the query is executed.
|
|
270
702
|
* @returns Query result object
|
|
271
703
|
*/
|
|
272
|
-
|
|
704
|
+
interface Modern {
|
|
705
|
+
/**
|
|
706
|
+
* A hook for executing queries in an Apollo application.
|
|
707
|
+
*
|
|
708
|
+
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
709
|
+
*
|
|
710
|
+
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
711
|
+
*
|
|
712
|
+
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
713
|
+
*
|
|
714
|
+
* @example
|
|
715
|
+
*
|
|
716
|
+
* ```jsx
|
|
717
|
+
* import { gql } from "@apollo/client";
|
|
718
|
+
* import { useQuery } from "@apollo/client/react";
|
|
719
|
+
*
|
|
720
|
+
* const GET_GREETING = gql`
|
|
721
|
+
* query GetGreeting($language: String!) {
|
|
722
|
+
* greeting(language: $language) {
|
|
723
|
+
* message
|
|
724
|
+
* }
|
|
725
|
+
* }
|
|
726
|
+
* `;
|
|
727
|
+
*
|
|
728
|
+
* function Hello() {
|
|
729
|
+
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
730
|
+
* variables: { language: "english" },
|
|
731
|
+
* });
|
|
732
|
+
* if (loading) return <p>Loading ...</p>;
|
|
733
|
+
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
734
|
+
* }
|
|
735
|
+
* ```
|
|
736
|
+
*
|
|
737
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
738
|
+
* @param options - Options to control how the query is executed.
|
|
739
|
+
* @returns Query result object
|
|
740
|
+
*/
|
|
741
|
+
<TData, TVariables extends OperationVariables, Options extends never>(query: {} extends TVariables ? DocumentNode | TypedDocumentNode<TData, TVariables> : never): useQuery.ResultForOptions<TData, TVariables, Record<string, never>>;
|
|
742
|
+
/**
|
|
743
|
+
* A hook for executing queries in an Apollo application.
|
|
744
|
+
*
|
|
745
|
+
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
746
|
+
*
|
|
747
|
+
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
748
|
+
*
|
|
749
|
+
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
750
|
+
*
|
|
751
|
+
* @example
|
|
752
|
+
*
|
|
753
|
+
* ```jsx
|
|
754
|
+
* import { gql } from "@apollo/client";
|
|
755
|
+
* import { useQuery } from "@apollo/client/react";
|
|
756
|
+
*
|
|
757
|
+
* const GET_GREETING = gql`
|
|
758
|
+
* query GetGreeting($language: String!) {
|
|
759
|
+
* greeting(language: $language) {
|
|
760
|
+
* message
|
|
761
|
+
* }
|
|
762
|
+
* }
|
|
763
|
+
* `;
|
|
764
|
+
*
|
|
765
|
+
* function Hello() {
|
|
766
|
+
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
767
|
+
* variables: { language: "english" },
|
|
768
|
+
* });
|
|
769
|
+
* if (loading) return <p>Loading ...</p>;
|
|
770
|
+
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
771
|
+
* }
|
|
772
|
+
* ```
|
|
773
|
+
*
|
|
774
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
775
|
+
* @param options - Options to control how the query is executed.
|
|
776
|
+
* @returns Query result object
|
|
777
|
+
*/
|
|
778
|
+
<TData, TVariables extends OperationVariables, TOptions extends SkipToken>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken): useQuery.Result<TData, TVariables, "empty", Record<string, never>>;
|
|
779
|
+
/**
|
|
780
|
+
* A hook for executing queries in an Apollo application.
|
|
781
|
+
*
|
|
782
|
+
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
783
|
+
*
|
|
784
|
+
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
785
|
+
*
|
|
786
|
+
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
787
|
+
*
|
|
788
|
+
* @example
|
|
789
|
+
*
|
|
790
|
+
* ```jsx
|
|
791
|
+
* import { gql } from "@apollo/client";
|
|
792
|
+
* import { useQuery } from "@apollo/client/react";
|
|
793
|
+
*
|
|
794
|
+
* const GET_GREETING = gql`
|
|
795
|
+
* query GetGreeting($language: String!) {
|
|
796
|
+
* greeting(language: $language) {
|
|
797
|
+
* message
|
|
798
|
+
* }
|
|
799
|
+
* }
|
|
800
|
+
* `;
|
|
801
|
+
*
|
|
802
|
+
* function Hello() {
|
|
803
|
+
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
804
|
+
* variables: { language: "english" },
|
|
805
|
+
* });
|
|
806
|
+
* if (loading) return <p>Loading ...</p>;
|
|
807
|
+
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
808
|
+
* }
|
|
809
|
+
* ```
|
|
810
|
+
*
|
|
811
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
812
|
+
* @param options - Options to control how the query is executed.
|
|
813
|
+
* @returns Query result object
|
|
814
|
+
*/
|
|
815
|
+
<TData, TVariables extends OperationVariables, TOptions extends useQuery.Options<TData, NoInfer<TVariables>> & VariablesOption<TVariables & {
|
|
816
|
+
[K in Exclude<keyof TOptions["variables"], keyof TVariables>]?: never;
|
|
817
|
+
}>>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: [
|
|
818
|
+
TVariables
|
|
819
|
+
] extends [never] ? [options: never] : {} extends TVariables ? [options?: TOptions] : [
|
|
820
|
+
options: TOptions
|
|
821
|
+
]): useQuery.ResultForOptions<TData, TVariables, TOptions>;
|
|
822
|
+
/**
|
|
823
|
+
* A hook for executing queries in an Apollo application.
|
|
824
|
+
*
|
|
825
|
+
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
826
|
+
*
|
|
827
|
+
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
828
|
+
*
|
|
829
|
+
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
830
|
+
*
|
|
831
|
+
* @example
|
|
832
|
+
*
|
|
833
|
+
* ```jsx
|
|
834
|
+
* import { gql } from "@apollo/client";
|
|
835
|
+
* import { useQuery } from "@apollo/client/react";
|
|
836
|
+
*
|
|
837
|
+
* const GET_GREETING = gql`
|
|
838
|
+
* query GetGreeting($language: String!) {
|
|
839
|
+
* greeting(language: $language) {
|
|
840
|
+
* message
|
|
841
|
+
* }
|
|
842
|
+
* }
|
|
843
|
+
* `;
|
|
844
|
+
*
|
|
845
|
+
* function Hello() {
|
|
846
|
+
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
847
|
+
* variables: { language: "english" },
|
|
848
|
+
* });
|
|
849
|
+
* if (loading) return <p>Loading ...</p>;
|
|
850
|
+
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
851
|
+
* }
|
|
852
|
+
* ```
|
|
853
|
+
*
|
|
854
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
855
|
+
* @param options - Options to control how the query is executed.
|
|
856
|
+
* @returns Query result object
|
|
857
|
+
*/
|
|
858
|
+
<TData, TVariables extends OperationVariables, TOptions extends useQuery.Options<TData, NoInfer<TVariables>> & VariablesOption<TVariables & {
|
|
859
|
+
[K in Exclude<keyof TOptions["variables"], keyof TVariables>]?: never;
|
|
860
|
+
}>>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: [
|
|
861
|
+
TVariables
|
|
862
|
+
] extends [never] ? [options: never] : {} extends TVariables ? [options?: TOptions | SkipToken] : [
|
|
863
|
+
options: TOptions | SkipToken
|
|
864
|
+
]): useQuery.ResultForOptions<TData, TVariables, TOptions | SkipToken>;
|
|
865
|
+
ssrDisabledResult: ObservableQuery.Result<any>;
|
|
866
|
+
}
|
|
867
|
+
type Evaluated = SignatureStyle extends "classic" ? Classic : Modern;
|
|
868
|
+
}
|
|
869
|
+
/**
|
|
870
|
+
* A hook for executing queries in an Apollo application.
|
|
871
|
+
*
|
|
872
|
+
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
873
|
+
*
|
|
874
|
+
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
875
|
+
*
|
|
876
|
+
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
877
|
+
*
|
|
878
|
+
* @example
|
|
879
|
+
*
|
|
880
|
+
* ```jsx
|
|
881
|
+
* import { gql } from "@apollo/client";
|
|
882
|
+
* import { useQuery } from "@apollo/client/react";
|
|
883
|
+
*
|
|
884
|
+
* const GET_GREETING = gql`
|
|
885
|
+
* query GetGreeting($language: String!) {
|
|
886
|
+
* greeting(language: $language) {
|
|
887
|
+
* message
|
|
888
|
+
* }
|
|
889
|
+
* }
|
|
890
|
+
* `;
|
|
891
|
+
*
|
|
892
|
+
* function Hello() {
|
|
893
|
+
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
894
|
+
* variables: { language: "english" },
|
|
895
|
+
* });
|
|
896
|
+
* if (loading) return <p>Loading ...</p>;
|
|
897
|
+
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
898
|
+
* }
|
|
899
|
+
* ```
|
|
900
|
+
*
|
|
901
|
+
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
902
|
+
* @param options - Options to control how the query is executed.
|
|
903
|
+
* @returns Query result object
|
|
904
|
+
*/
|
|
905
|
+
interface Signature extends Signatures.Evaluated {
|
|
273
906
|
}
|
|
274
907
|
}
|
|
275
|
-
|
|
276
|
-
* A hook for executing queries in an Apollo application.
|
|
277
|
-
*
|
|
278
|
-
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
279
|
-
*
|
|
280
|
-
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
281
|
-
*
|
|
282
|
-
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
283
|
-
*
|
|
284
|
-
* @example
|
|
285
|
-
*
|
|
286
|
-
* ```jsx
|
|
287
|
-
* import { gql } from "@apollo/client";
|
|
288
|
-
* import { useQuery } from "@apollo/client/react";
|
|
289
|
-
*
|
|
290
|
-
* const GET_GREETING = gql`
|
|
291
|
-
* query GetGreeting($language: String!) {
|
|
292
|
-
* greeting(language: $language) {
|
|
293
|
-
* message
|
|
294
|
-
* }
|
|
295
|
-
* }
|
|
296
|
-
* `;
|
|
297
|
-
*
|
|
298
|
-
* function Hello() {
|
|
299
|
-
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
300
|
-
* variables: { language: "english" },
|
|
301
|
-
* });
|
|
302
|
-
* if (loading) return <p>Loading ...</p>;
|
|
303
|
-
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
304
|
-
* }
|
|
305
|
-
* ```
|
|
306
|
-
*
|
|
307
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
308
|
-
* @param options - Options to control how the query is executed.
|
|
309
|
-
* @returns Query result object
|
|
310
|
-
*/
|
|
311
|
-
export declare function useQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useQuery.Options<NoInfer<TData>, NoInfer<TVariables>> & {
|
|
312
|
-
returnPartialData: true;
|
|
313
|
-
}): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming" | "partial">;
|
|
314
|
-
/**
|
|
315
|
-
* A hook for executing queries in an Apollo application.
|
|
316
|
-
*
|
|
317
|
-
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
318
|
-
*
|
|
319
|
-
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
320
|
-
*
|
|
321
|
-
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
322
|
-
*
|
|
323
|
-
* @example
|
|
324
|
-
*
|
|
325
|
-
* ```jsx
|
|
326
|
-
* import { gql } from "@apollo/client";
|
|
327
|
-
* import { useQuery } from "@apollo/client/react";
|
|
328
|
-
*
|
|
329
|
-
* const GET_GREETING = gql`
|
|
330
|
-
* query GetGreeting($language: String!) {
|
|
331
|
-
* greeting(language: $language) {
|
|
332
|
-
* message
|
|
333
|
-
* }
|
|
334
|
-
* }
|
|
335
|
-
* `;
|
|
336
|
-
*
|
|
337
|
-
* function Hello() {
|
|
338
|
-
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
339
|
-
* variables: { language: "english" },
|
|
340
|
-
* });
|
|
341
|
-
* if (loading) return <p>Loading ...</p>;
|
|
342
|
-
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
343
|
-
* }
|
|
344
|
-
* ```
|
|
345
|
-
*
|
|
346
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
347
|
-
* @param options - Options to control how the query is executed.
|
|
348
|
-
* @returns Query result object
|
|
349
|
-
*/
|
|
350
|
-
export declare function useQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken): useQuery.Result<TData, TVariables, "empty", Record<string, never>>;
|
|
351
|
-
/**
|
|
352
|
-
* A hook for executing queries in an Apollo application.
|
|
353
|
-
*
|
|
354
|
-
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
355
|
-
*
|
|
356
|
-
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
357
|
-
*
|
|
358
|
-
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
359
|
-
*
|
|
360
|
-
* @example
|
|
361
|
-
*
|
|
362
|
-
* ```jsx
|
|
363
|
-
* import { gql } from "@apollo/client";
|
|
364
|
-
* import { useQuery } from "@apollo/client/react";
|
|
365
|
-
*
|
|
366
|
-
* const GET_GREETING = gql`
|
|
367
|
-
* query GetGreeting($language: String!) {
|
|
368
|
-
* greeting(language: $language) {
|
|
369
|
-
* message
|
|
370
|
-
* }
|
|
371
|
-
* }
|
|
372
|
-
* `;
|
|
373
|
-
*
|
|
374
|
-
* function Hello() {
|
|
375
|
-
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
376
|
-
* variables: { language: "english" },
|
|
377
|
-
* });
|
|
378
|
-
* if (loading) return <p>Loading ...</p>;
|
|
379
|
-
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
380
|
-
* }
|
|
381
|
-
* ```
|
|
382
|
-
*
|
|
383
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
384
|
-
* @param options - Options to control how the query is executed.
|
|
385
|
-
* @returns Query result object
|
|
386
|
-
*/
|
|
387
|
-
export declare function useQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (useQuery.Options<NoInfer<TData>, NoInfer<TVariables>> & {
|
|
388
|
-
returnPartialData: true;
|
|
389
|
-
})): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming" | "partial", Partial<TVariables>>;
|
|
390
|
-
/**
|
|
391
|
-
* A hook for executing queries in an Apollo application.
|
|
392
|
-
*
|
|
393
|
-
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
394
|
-
*
|
|
395
|
-
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
396
|
-
*
|
|
397
|
-
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
398
|
-
*
|
|
399
|
-
* @example
|
|
400
|
-
*
|
|
401
|
-
* ```jsx
|
|
402
|
-
* import { gql } from "@apollo/client";
|
|
403
|
-
* import { useQuery } from "@apollo/client/react";
|
|
404
|
-
*
|
|
405
|
-
* const GET_GREETING = gql`
|
|
406
|
-
* query GetGreeting($language: String!) {
|
|
407
|
-
* greeting(language: $language) {
|
|
408
|
-
* message
|
|
409
|
-
* }
|
|
410
|
-
* }
|
|
411
|
-
* `;
|
|
412
|
-
*
|
|
413
|
-
* function Hello() {
|
|
414
|
-
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
415
|
-
* variables: { language: "english" },
|
|
416
|
-
* });
|
|
417
|
-
* if (loading) return <p>Loading ...</p>;
|
|
418
|
-
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
419
|
-
* }
|
|
420
|
-
* ```
|
|
421
|
-
*
|
|
422
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
423
|
-
* @param options - Options to control how the query is executed.
|
|
424
|
-
* @returns Query result object
|
|
425
|
-
*/
|
|
426
|
-
export declare function useQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: useQuery.Options<NoInfer<TData>, NoInfer<TVariables>> & {
|
|
427
|
-
returnPartialData: boolean;
|
|
428
|
-
}): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming" | "partial">;
|
|
429
|
-
/**
|
|
430
|
-
* A hook for executing queries in an Apollo application.
|
|
431
|
-
*
|
|
432
|
-
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
433
|
-
*
|
|
434
|
-
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
435
|
-
*
|
|
436
|
-
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
437
|
-
*
|
|
438
|
-
* @example
|
|
439
|
-
*
|
|
440
|
-
* ```jsx
|
|
441
|
-
* import { gql } from "@apollo/client";
|
|
442
|
-
* import { useQuery } from "@apollo/client/react";
|
|
443
|
-
*
|
|
444
|
-
* const GET_GREETING = gql`
|
|
445
|
-
* query GetGreeting($language: String!) {
|
|
446
|
-
* greeting(language: $language) {
|
|
447
|
-
* message
|
|
448
|
-
* }
|
|
449
|
-
* }
|
|
450
|
-
* `;
|
|
451
|
-
*
|
|
452
|
-
* function Hello() {
|
|
453
|
-
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
454
|
-
* variables: { language: "english" },
|
|
455
|
-
* });
|
|
456
|
-
* if (loading) return <p>Loading ...</p>;
|
|
457
|
-
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
458
|
-
* }
|
|
459
|
-
* ```
|
|
460
|
-
*
|
|
461
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
462
|
-
* @param options - Options to control how the query is executed.
|
|
463
|
-
* @returns Query result object
|
|
464
|
-
*/
|
|
465
|
-
export declare function useQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options: SkipToken | (useQuery.Options<NoInfer<TData>, NoInfer<TVariables>> & {
|
|
466
|
-
returnPartialData: boolean;
|
|
467
|
-
})): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming" | "partial", Partial<TVariables>>;
|
|
468
|
-
/**
|
|
469
|
-
* A hook for executing queries in an Apollo application.
|
|
470
|
-
*
|
|
471
|
-
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
472
|
-
*
|
|
473
|
-
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
474
|
-
*
|
|
475
|
-
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
476
|
-
*
|
|
477
|
-
* @example
|
|
478
|
-
*
|
|
479
|
-
* ```jsx
|
|
480
|
-
* import { gql } from "@apollo/client";
|
|
481
|
-
* import { useQuery } from "@apollo/client/react";
|
|
482
|
-
*
|
|
483
|
-
* const GET_GREETING = gql`
|
|
484
|
-
* query GetGreeting($language: String!) {
|
|
485
|
-
* greeting(language: $language) {
|
|
486
|
-
* message
|
|
487
|
-
* }
|
|
488
|
-
* }
|
|
489
|
-
* `;
|
|
490
|
-
*
|
|
491
|
-
* function Hello() {
|
|
492
|
-
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
493
|
-
* variables: { language: "english" },
|
|
494
|
-
* });
|
|
495
|
-
* if (loading) return <p>Loading ...</p>;
|
|
496
|
-
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
497
|
-
* }
|
|
498
|
-
* ```
|
|
499
|
-
*
|
|
500
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
501
|
-
* @param options - Options to control how the query is executed.
|
|
502
|
-
* @returns Query result object
|
|
503
|
-
*/
|
|
504
|
-
export declare function useQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
|
|
505
|
-
options?: useQuery.Options<NoInfer<TData>, NoInfer<TVariables>>
|
|
506
|
-
] : [options: useQuery.Options<NoInfer<TData>, NoInfer<TVariables>>]): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming">;
|
|
507
|
-
/**
|
|
508
|
-
* A hook for executing queries in an Apollo application.
|
|
509
|
-
*
|
|
510
|
-
* To run a query within a React component, call `useQuery` and pass it a GraphQL query document.
|
|
511
|
-
*
|
|
512
|
-
* When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, `dataState`, and `data` properties you can use to render your UI.
|
|
513
|
-
*
|
|
514
|
-
* > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`.
|
|
515
|
-
*
|
|
516
|
-
* @example
|
|
517
|
-
*
|
|
518
|
-
* ```jsx
|
|
519
|
-
* import { gql } from "@apollo/client";
|
|
520
|
-
* import { useQuery } from "@apollo/client/react";
|
|
521
|
-
*
|
|
522
|
-
* const GET_GREETING = gql`
|
|
523
|
-
* query GetGreeting($language: String!) {
|
|
524
|
-
* greeting(language: $language) {
|
|
525
|
-
* message
|
|
526
|
-
* }
|
|
527
|
-
* }
|
|
528
|
-
* `;
|
|
529
|
-
*
|
|
530
|
-
* function Hello() {
|
|
531
|
-
* const { loading, error, data } = useQuery(GET_GREETING, {
|
|
532
|
-
* variables: { language: "english" },
|
|
533
|
-
* });
|
|
534
|
-
* if (loading) return <p>Loading ...</p>;
|
|
535
|
-
* return <h1>Hello {data.greeting.message}!</h1>;
|
|
536
|
-
* }
|
|
537
|
-
* ```
|
|
538
|
-
*
|
|
539
|
-
* @param query - A GraphQL query document parsed into an AST by `gql`.
|
|
540
|
-
* @param options - Options to control how the query is executed.
|
|
541
|
-
* @returns Query result object
|
|
542
|
-
*/
|
|
543
|
-
export declare function useQuery<TData = unknown, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, ...[options]: {} extends TVariables ? [
|
|
544
|
-
options?: SkipToken | useQuery.Options<NoInfer<TData>, NoInfer<TVariables>>
|
|
545
|
-
] : [options: SkipToken | useQuery.Options<NoInfer<TData>, NoInfer<TVariables>>]): useQuery.Result<TData, TVariables, "empty" | "complete" | "streaming", Partial<TVariables>>;
|
|
546
|
-
export declare namespace useQuery {
|
|
547
|
-
var ssrDisabledResult: ObservableQuery.Result<any, "complete" | "empty" | "streaming" | "partial">;
|
|
548
|
-
}
|
|
908
|
+
export declare const useQuery: useQuery.Signature;
|
|
549
909
|
//# sourceMappingURL=useQuery.d.cts.map
|