import type { DocumentNode } from "graphql";
import type { ApolloCache } from "@apollo/client/cache";
import type { Cache } from "@apollo/client/cache";
import type { FetchResult } from "@apollo/client/link/core";
import type { Unmasked } from "@apollo/client/masking";
import type { IsStrictlyAny } from "@apollo/client/utilities";
import type { Resolver } from "./LocalState.js";
import type { NetworkStatus } from "./networkStatus.js";
import type { ObservableQuery } from "./ObservableQuery.js";
import type { QueryInfo } from "./QueryInfo.js";
import type { QueryOptions } from "./watchQueryOptions.js";
export type { TypedDocumentNode } from "@graphql-typed-document-node/core";
export type MethodKeys<T> = {
    [P in keyof T]: T[P] extends Function ? P : never;
}[keyof T];
export interface DefaultContext extends Record<string, any> {
}
export type QueryListener = (queryInfo: QueryInfo) => void;
/**
 * Represents an `Error` type, but used throughout Apollo Client to represent
 * errors that may otherwise fail `instanceof` checks if they are cross-realm
 * Error instances (see the [`Error.isError` proposal](https://github.com/tc39/proposal-is-error) for more details).
 *
 * Apollo Client uses several types of errors throughout the client which can be
 * narrowed using `instanceof`:
 * - `CombinedGraphQLErrors` - `errors` returned from a GraphQL result
 * - `CombinedProtocolErrors` - Transport-level errors from multipart subscriptions.
 * - `ServerParseError` - A JSON-parse error when parsing the server response.
 * - `ServerError` - A non-200 server response.
 *
 * @example
 * ```ts
 * import { CombinedGraphQLErrors } from "@apollo/client";
 *
 * try {
 *   await client.query({ query });
 * } catch (error) {
 *   // Use `instanceof` to check for more specific types of errors.
 *   if (error instanceof CombinedGraphQLErrors) {
 *     error.errors.map(graphQLError => console.log(graphQLError.message));
 *   } else {
 *     console.error(errors);
 *   }
 * }
 * ```
 */
export interface ErrorLike {
    message: string;
    name: string;
    stack?: string;
}
export type OnQueryUpdated<TResult> = (observableQuery: ObservableQuery<any>, diff: Cache.DiffResult<any>, lastDiff: Cache.DiffResult<any> | undefined) => boolean | TResult;
export type RefetchQueryDescriptor = string | DocumentNode;
export type InternalRefetchQueryDescriptor = RefetchQueryDescriptor | QueryOptions;
type RefetchQueriesIncludeShorthand = "all" | "active";
export type RefetchQueriesInclude = RefetchQueryDescriptor[] | RefetchQueriesIncludeShorthand;
export type InternalRefetchQueriesInclude = InternalRefetchQueryDescriptor[] | RefetchQueriesIncludeShorthand;
export interface RefetchQueriesOptions<TCache extends ApolloCache, TResult> {
    updateCache?: (cache: TCache) => void;
    include?: RefetchQueriesInclude;
    optimistic?: boolean;
    onQueryUpdated?: OnQueryUpdated<TResult> | null;
}
export type RefetchQueriesPromiseResults<TResult> = IsStrictlyAny<TResult> extends true ? any[] : TResult extends boolean ? QueryResult<any>[] : TResult extends PromiseLike<infer U> ? U[] : TResult[];
export interface RefetchQueriesResult<TResult> extends Promise<RefetchQueriesPromiseResults<TResult>> {
    queries: ObservableQuery<any>[];
    results: InternalRefetchQueriesResult<TResult>[];
}
export interface InternalRefetchQueriesOptions<TCache extends ApolloCache, TResult> extends Omit<RefetchQueriesOptions<TCache, TResult>, "include"> {
    include?: InternalRefetchQueriesInclude;
    removeOptimistic?: string;
}
export type InternalRefetchQueriesResult<TResult> = TResult extends boolean ? Promise<QueryResult<any>> : TResult;
export type InternalRefetchQueriesMap<TResult> = Map<ObservableQuery<any>, InternalRefetchQueriesResult<TResult>>;
export type { QueryOptions as PureQueryOptions };
export type OperationVariables = Record<string, any>;
export interface ApolloQueryResult<T> {
    data: T | undefined;
    /**
     * The single Error object that is passed to onError and useQuery hooks, and is often thrown during manual `client.query` calls.
     * This will contain both a NetworkError field and any GraphQLErrors.
     * See https://www.apollographql.com/docs/react/data/error-handling/ for more information.
     */
    error?: ErrorLike;
    loading: boolean;
    networkStatus: NetworkStatus;
    /**
     * Describes whether `data` is a complete or partial result. This flag is only
     * set when `returnPartialData` is `true` in query options.
     *
     * @deprecated This field will be removed in a future version of Apollo Client.
     */
    partial: boolean;
}
export type MutationQueryReducer<T> = (previousResult: Record<string, any>, options: {
    mutationResult: FetchResult<Unmasked<T>>;
    queryName: string | undefined;
    queryVariables: Record<string, any>;
}) => Record<string, any>;
export type MutationQueryReducersMap<T = {
    [key: string]: any;
}> = {
    [queryName: string]: MutationQueryReducer<T>;
};
/**
 * @deprecated Use `MutationUpdaterFunction` instead.
 */
export type MutationUpdaterFn<T = {
    [key: string]: any;
}> = (cache: ApolloCache, mutationResult: FetchResult<T>) => void;
export type MutationUpdaterFunction<TData, TVariables, TContext, TCache extends ApolloCache> = (cache: TCache, result: Omit<FetchResult<Unmasked<TData>>, "context">, options: {
    context?: TContext;
    variables?: TVariables;
}) => void;
export interface Resolvers {
    [key: string]: {
        [field: string]: Resolver;
    };
}
export interface MutateResult<TData = unknown> {
    /**
    * The data returned from your mutation. Can be `undefined` if `ignoreResults` is `true`.
    */
    data: TData | undefined;
    /**
    * If the mutation produces one or more errors, this object contains either an array of `graphQLErrors` or a single `networkError`. Otherwise, this value is `undefined`.
    * 
    * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
    */
    error?: ErrorLike;
    /**
    * Custom extensions returned from the GraphQL server
    */
    extensions?: Record<string, unknown>;
}
export interface SubscribeResult<TData = unknown> {
    /**
    * The data returned from your mutation. Can be `undefined` if `ignoreResults` is `true`.
    */
    data: TData | undefined;
    /**
    * If the mutation produces one or more errors, this object contains either an array of `graphQLErrors` or a single `networkError`. Otherwise, this value is `undefined`.
    * 
    * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
    */
    error?: ErrorLike;
    /**
    * Custom extensions returned from the GraphQL server
    */
    extensions?: Record<string, unknown>;
}
export interface QueryResult<TData = unknown> {
    /**
    * An object containing the result of your GraphQL query after it completes.
    * 
    * This value might be `undefined` if a query results in one or more errors (depending on the query's `errorPolicy`).
    * 
    * @docGroup
    * 
    * 1. Operation data
    */
    data: TData | undefined;
    /**
    * If the query produces one or more errors, this object contains either an array of `graphQLErrors` or a single `networkError`. Otherwise, this value is `undefined`.
    * 
    * For more information, see [Handling operation errors](https://www.apollographql.com/docs/react/data/error-handling/).
    * 
    * @docGroup
    * 
    * 1. Operation data
    */
    error?: ErrorLike;
}
//# sourceMappingURL=types.d.ts.map
