/// <reference types="react" />
import * as React from 'react';
import { QueryOptions, QuickQLQuery } from './query';
import { ObjectMap } from './utils';
export interface GraphQLOptions extends QueryOptions {
    pollInterval: number;
}
export declare class GraphQLClient {
    private conf;
    lastQuery: {
        query: string;
        variables: ObjectMap<any>;
        headers?: ObjectMap<string> | null;
        apiHost?: string;
    };
    constructor(options: QueryOptions);
    query: (query: QuickQLQuery) => Promise<{
        data: {};
        ok: boolean;
        statusText: string;
    }>;
    refetch: () => Promise<{
        data: {};
        ok: boolean;
        statusText: string;
    }>;
}
export interface GraphQLConfig extends QueryOptions {
}
export interface GraphQLData<T> {
    data: T;
    loading: boolean;
    lastError: string;
}
export interface GraphQLResult<T> extends GraphQLData<T> {
    client: GraphQLClient;
    refetch: () => void;
}
export interface GraphQLInjectedProps<T> {
    graphql: GraphQLResult<T>;
}
export declare function useConfig(config: Partial<GraphQLConfig>): void;
export interface GraphQLProps<QueryDataType> extends Partial<GraphQLOptions> {
    query?: string | Partial<QuickQLQuery>;
    onQueryResult?: (result: GraphQLResult<QueryDataType>) => void;
}
export interface GraphQLState<T> extends GraphQLData<T> {
}
export declare class GraphQL<QueryDataType> extends React.Component<GraphQLProps<QueryDataType>, GraphQLState<QueryDataType>> {
    private client;
    private query;
    private options;
    private pollingTimeout;
    constructor(props: GraphQLProps<QueryDataType>);
    render(): JSX.Element;
    componentDidMount(): void;
    componentWillReceiveProps(nextProps: GraphQLProps<QueryDataType>): void;
    componentWillUnmount(): void;
    private refetch;
    private pollingRefetch;
}
export declare function withGraphQL<PropsType extends GraphQLInjectedProps<QueryDataType | null>, QueryDataType = any>(query?: string | Partial<QuickQLQuery> | ((props: PropsType) => Partial<QuickQLQuery>), options?: Partial<GraphQLOptions> | ((props: PropsType) => Partial<GraphQLOptions>)): (WrappedComponent: React.ComponentClass<PropsType> | React.StatelessComponent<PropsType>) => {
    new (props?: Pick<PropsType, ({
        [P in keyof PropsType]: P;
    } & {
        graphql: never;
    } & {
        [x: string]: never;
    })[keyof PropsType]>, context?: any): {
        render(): JSX.Element;
        setState<K extends "data" | "loading" | "lastError">(f: (prevState: GraphQLData<QueryDataType>, props: Pick<PropsType, ({
            [P in keyof PropsType]: P;
        } & {
            graphql: never;
        } & {
            [x: string]: never;
        })[keyof PropsType]>) => Pick<GraphQLData<QueryDataType>, K>, callback?: () => any): void;
        setState<K extends "data" | "loading" | "lastError">(state: Pick<GraphQLData<QueryDataType>, K>, callback?: () => any): void;
        forceUpdate(callBack?: () => any): void;
        props: Readonly<{
            children?: React.ReactNode;
        }> & Readonly<Pick<PropsType, ({
            [P in keyof PropsType]: P;
        } & {
            graphql: never;
        } & {
            [x: string]: never;
        })[keyof PropsType]>>;
        state: Readonly<GraphQLData<QueryDataType>>;
        context: any;
        refs: {
            [key: string]: React.ReactInstance;
        };
        componentWillMount?(): void;
        componentDidMount?(): void;
        componentWillReceiveProps?(nextProps: Readonly<Pick<PropsType, ({
            [P in keyof PropsType]: P;
        } & {
            graphql: never;
        } & {
            [x: string]: never;
        })[keyof PropsType]>>, nextContext: any): void;
        shouldComponentUpdate?(nextProps: Readonly<Pick<PropsType, ({
            [P in keyof PropsType]: P;
        } & {
            graphql: never;
        } & {
            [x: string]: never;
        })[keyof PropsType]>>, nextState: Readonly<GraphQLData<QueryDataType>>, nextContext: any): boolean;
        componentWillUpdate?(nextProps: Readonly<Pick<PropsType, ({
            [P in keyof PropsType]: P;
        } & {
            graphql: never;
        } & {
            [x: string]: never;
        })[keyof PropsType]>>, nextState: Readonly<GraphQLData<QueryDataType>>, nextContext: any): void;
        componentDidUpdate?(prevProps: Readonly<Pick<PropsType, ({
            [P in keyof PropsType]: P;
        } & {
            graphql: never;
        } & {
            [x: string]: never;
        })[keyof PropsType]>>, prevState: Readonly<GraphQLData<QueryDataType>>, prevContext: any): void;
        componentWillUnmount?(): void;
        componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void;
    };
};
