import type { DocumentNode, OperationVariables, TypedDocumentNode } from "../../core/index.js"; import type { QueryReference } from "../internal/index.js"; import type { LoadableQueryHookOptions } from "../types/types.js"; import type { FetchMoreFunction, RefetchFunction } from "./useSuspenseQuery.js"; import type { DeepPartial, OnlyRequiredProperties } from "../../utilities/index.js"; export type LoadQueryFunction = (...args: [TVariables] extends [never] ? [] : {} extends OnlyRequiredProperties ? [variables?: TVariables] : [variables: TVariables]) => void; type ResetFunction = () => void; export type UseLoadableQueryResult = [ loadQuery: LoadQueryFunction, queryRef: QueryReference | null, { /** * A function that helps you fetch the next set of results for a [paginated list field](https://www.apollographql.com/docs/react/pagination/core-api/). * * * @docGroup * * 3. Helper functions */ fetchMore: FetchMoreFunction; /** * A function that enables you to re-execute the query, optionally passing in new `variables`. * * To guarantee that the refetch performs a network request, its `fetchPolicy` is set to `network-only` (unless the original query's `fetchPolicy` is `no-cache` or `cache-and-network`, which also guarantee a network request). * * See also [Refetching](https://www.apollographql.com/docs/react/data/queries/#refetching). * * @docGroup * * 3. Helper functions */ refetch: RefetchFunction; /** * A function that resets the `queryRef` back to `null`. */ reset: ResetFunction; } ]; export declare function useLoadableQuery(query: DocumentNode | TypedDocumentNode, options?: LoadableQueryHookOptions & TOptions): UseLoadableQueryResult | undefined : TData | undefined : TOptions["returnPartialData"] extends true ? DeepPartial : TData, TVariables>; export declare function useLoadableQuery(query: DocumentNode | TypedDocumentNode, options: LoadableQueryHookOptions & { returnPartialData: true; errorPolicy: "ignore" | "all"; }): UseLoadableQueryResult | undefined, TVariables>; export declare function useLoadableQuery(query: DocumentNode | TypedDocumentNode, options: LoadableQueryHookOptions & { errorPolicy: "ignore" | "all"; }): UseLoadableQueryResult; export declare function useLoadableQuery(query: DocumentNode | TypedDocumentNode, options: LoadableQueryHookOptions & { returnPartialData: true; }): UseLoadableQueryResult, TVariables>; /** * A hook for imperatively loading a query, such as responding to a user * interaction. * * > Refer to the [Suspense - Fetching in response to user interaction](https://www.apollographql.com/docs/react/data/suspense#fetching-in-response-to-user-interaction) section for a more in-depth overview of `useLoadableQuery`. * * @example * ```jsx * import { gql, useLoadableQuery } from "@apollo/client"; * * const GET_GREETING = gql` * query GetGreeting($language: String!) { * greeting(language: $language) { * message * } * } * `; * * function App() { * const [loadGreeting, queryRef] = useLoadableQuery(GET_GREETING); * * return ( * <> * * Loading...}> * {queryRef && } * * * ); * } * * function Hello({ queryRef }) { * const { data } = useReadQuery(queryRef); * * return
{data.greeting.message}
; * } * ``` * * @since 3.9.0 * @param query - A GraphQL query document parsed into an AST by `gql`. * @param options - Options to control how the query is executed. * @returns A tuple in the form of `[loadQuery, queryRef, handlers]` */ export declare function useLoadableQuery(query: DocumentNode | TypedDocumentNode, options?: LoadableQueryHookOptions): UseLoadableQueryResult; export {}; //# sourceMappingURL=useLoadableQuery.d.ts.map