import type { ApolloClient, DefaultOptions, OperationVariables, WatchQueryFetchPolicy } from "../../core/index.js"; import { ApolloError } from "../../errors/index.js"; import type { ApolloQueryResult, ObservableQuery, DocumentNode, TypedDocumentNode, WatchQueryOptions } from "../../core/index.js"; import type { QueryHookOptions, QueryResult, ObservableQueryFields, NoInfer } from "../types/types.js"; import { useApolloClient } from "./useApolloClient.js"; type InternalQueryResult = Omit, Exclude, "variables">>; export declare const lastWatchOptions: unique symbol; export interface ObsQueryWithMeta extends ObservableQuery { [lastWatchOptions]?: WatchQueryOptions; } export interface InternalResult { current?: undefined | InternalQueryResult; previousData?: undefined | TData; } interface InternalState { client: ReturnType; query: DocumentNode | TypedDocumentNode; observable: ObsQueryWithMeta; resultData: InternalResult; } export type UpdateInternalState = (state: InternalState) => void; /** * 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 useQueryInternals(query: DocumentNode | TypedDocumentNode, options: QueryHookOptions, NoInfer>): { result: InternalQueryResult | InternalQueryResult; obsQueryFields: Omit, "variables">; observable: ObsQueryWithMeta; resultData: InternalResult; client: ApolloClient; onQueryExecuted: (watchQueryOptions: WatchQueryOptions) => void; }; export declare function createMakeWatchQueryOptions(client: ApolloClient, query: DocumentNode | TypedDocumentNode, { skip, ssr, onCompleted, onError, defaultOptions, ...otherOptions }: QueryHookOptions | undefined, isSyncSSR: boolean): (observable?: ObservableQuery) => WatchQueryOptions; export declare function getObsQueryOptions(observable: ObservableQuery | undefined, client: ApolloClient, queryHookOptions: QueryHookOptions, watchQueryOptions: Partial>): WatchQueryOptions; export declare function getDefaultFetchPolicy(queryHookDefaultOptions?: Partial>, clientDefaultOptions?: DefaultOptions): WatchQueryFetchPolicy; export declare function toApolloError(result: Pick, "errors" | "error">): ApolloError | undefined; export declare function toQueryResult(result: ApolloQueryResult, previousData: TData | undefined, observable: ObservableQuery, client: ApolloClient): InternalQueryResult; export {}; //# sourceMappingURL=useQuery.d.ts.map