1 | import type { DocumentNode } from "graphql";
|
2 | import type { TypedDocumentNode } from "@graphql-typed-document-node/core";
|
3 | import type { OperationVariables } from "../../core/index.js";
|
4 | import type { LazyQueryHookOptions, LazyQueryResultTuple, NoInfer } from "../types/types.js";
|
5 | /**
|
6 | * A hook for imperatively executing queries in an Apollo application, e.g. in response to user interaction.
|
7 | *
|
8 | * > Refer to the [Queries - Manual execution with useLazyQuery](https://www.apollographql.com/docs/react/data/queries#manual-execution-with-uselazyquery) section for a more in-depth overview of `useLazyQuery`.
|
9 | *
|
10 | * @example
|
11 | * ```jsx
|
12 | * import { gql, useLazyQuery } from "@apollo/client";
|
13 | *
|
14 | * const GET_GREETING = gql`
|
15 | * query GetGreeting($language: String!) {
|
16 | * greeting(language: $language) {
|
17 | * message
|
18 | * }
|
19 | * }
|
20 | * `;
|
21 | *
|
22 | * function Hello() {
|
23 | * const [loadGreeting, { called, loading, data }] = useLazyQuery(
|
24 | * GET_GREETING,
|
25 | * { variables: { language: "english" } }
|
26 | * );
|
27 | * if (called && loading) return <p>Loading ...</p>
|
28 | * if (!called) {
|
29 | * return <button onClick={() => loadGreeting()}>Load greeting</button>
|
30 | * }
|
31 | * return <h1>Hello {data.greeting.message}!</h1>;
|
32 | * }
|
33 | * ```
|
34 | * @since 3.0.0
|
35 | *
|
36 | * @param query - A GraphQL query document parsed into an AST by `gql`.
|
37 | * @param options - Default options to control how the query is executed.
|
38 | * @returns A tuple in the form of `[execute, result]`
|
39 | */
|
40 | export declare function useLazyQuery<TData = any, TVariables extends OperationVariables = OperationVariables>(query: DocumentNode | TypedDocumentNode<TData, TVariables>, options?: LazyQueryHookOptions<NoInfer<TData>, NoInfer<TVariables>>): LazyQueryResultTuple<TData, TVariables>;
|
41 | //# sourceMappingURL=useLazyQuery.d.ts.map |
\ | No newline at end of file |