import type { OperationVariables, WatchQueryFetchPolicy } from "../../core/index.js"; import type { ApolloClient, ApolloQueryResult, DocumentNode, TypedDocumentNode } from "../../core/index.js"; import type { QueryHookOptions, QueryResult, NoInfer } from "../types/types.js"; import { useApolloClient } from "./useApolloClient.js"; /** * A hook for executing queries in an Apollo application. * * To run a query within a React component, call `useQuery` and pass it a GraphQL query document. * * When your component renders, `useQuery` returns an object from Apollo Client that contains `loading`, `error`, and `data` properties you can use to render your UI. * * > Refer to the [Queries](https://www.apollographql.com/docs/react/data/queries) section for a more in-depth overview of `useQuery`. * * @example * ```jsx * import { gql, useQuery } from '@apollo/client'; * * const GET_GREETING = gql` * query GetGreeting($language: String!) { * greeting(language: $language) { * message * } * } * `; * * function Hello() { * const { loading, error, data } = useQuery(GET_GREETING, { * variables: { language: 'english' }, * }); * if (loading) return

Loading ...

; * return

Hello {data.greeting.message}!

; * } * ``` * @since 3.0.0 * @param query - A GraphQL query document parsed into an AST by `gql`. * @param options - Options to control how the query is executed. * @returns Query result object */ export declare function useQuery(query: DocumentNode | TypedDocumentNode, options?: QueryHookOptions, NoInfer>): QueryResult; export declare function useInternalState(client: ApolloClient, query: DocumentNode | TypedDocumentNode): InternalState; declare class InternalState { readonly client: ReturnType; readonly query: DocumentNode | TypedDocumentNode; constructor(client: ReturnType, query: DocumentNode | TypedDocumentNode, previous?: InternalState); /** * Forces an update using local component state. * As this is not batched with `useSyncExternalStore` updates, * this is only used as a fallback if the `useSyncExternalStore` "force update" * method is not registered at the moment. * See https://github.com/facebook/react/issues/25191 * */ forceUpdateState(): void; /** * Will be overwritten by the `useSyncExternalStore` "force update" method * whenever it is available and reset to `forceUpdateState` when it isn't. */ forceUpdate: () => void; executeQuery(options: QueryHookOptions & { query?: DocumentNode; }): Promise>; useQuery(options: QueryHookOptions): QueryResult; private renderPromises; private queryHookOptions; private watchQueryOptions; private useOptions; private getObsQueryOptions; private ssrDisabledResult; private skipStandbyResult; private createWatchQueryOptions; getDefaultFetchPolicy(): WatchQueryFetchPolicy; private onCompleted; private onError; private observable; private obsQueryFields; private useObservableQuery; private result; private previousData; private setResult; private handleErrorOrCompleted; private toApolloError; private getCurrentResult; private toQueryResultCache; toQueryResult(result: ApolloQueryResult): QueryResult; private unsafeHandlePartialRefetch; } export {}; //# sourceMappingURL=useQuery.d.ts.map