UNPKG

apollo-mobx

Version:

HOC for querying graphql server

50 lines (49 loc) 1.62 kB
import { ApolloCache } from 'apollo-cache'; import ApolloClientBase, { ApolloError, NetworkStatus } from 'apollo-client'; import { ApolloLink } from 'apollo-link'; import { SpyLink } from '../testing/spy_link'; export interface IQuery<C = {}, D = {}, V = {}> { query: any; variables?: V; thenCallback?: (data?: D, context?: C) => void; catchCallback?: (error?: ApolloError, context?: C) => void; finalCallback?: (context?: C) => void; } export interface IMutation<C = {}, D = {}, V = {}, T = {}> { mutation: any; variables?: V; optimisticResponse?: any; updateQueries?: any; thenCallback?: (data?: D, context?: C) => void; catchCallback?: (error?: ApolloError, context?: C) => void; finalCallback?: (context?: C) => void; } export interface Options<T> { link: ApolloLink; cache: ApolloCache<any>; ssrMode?: boolean; ssrForceFetchDelay?: number; addTypename?: boolean; connectToDevTools?: boolean; queryDeduplication?: boolean; context?: T; loadingComponent?: (props?: any) => JSX.Element; } export declare class ApolloClient<C> extends ApolloClientBase<any> { spyLink: SpyLink; context: C; loadingComponent?: (props?: any) => JSX.Element; constructor(options: Options<C>); mutate<D, V = {}>(options: IMutation<C, D, V>): Promise<{ data: D; loading: boolean; networkStatus: NetworkStatus; stale: boolean; }>; query<D, V = {}>(options: IQuery<C, D, V>): Promise<{ data: D; loading: boolean; networkStatus: NetworkStatus; stale: boolean; }>; }