import { WatchQueryOptions, MutationOptions, SubscriptionOptions, SubscribeToMoreOptions, ObservableQuery, NetworkStatus } from 'apollo-client' import { DocumentNode } from 'graphql'; // include Omit type from https://github.com/Microsoft/TypeScript/issues/12215 type Diff = ({ [P in T]: P } & { [P in U]: never } & { [x: string]: never })[T]; type Omit = { [P in Diff]?: T[P] }; type ApolloVueThisType = V & { [key: string]: any }; type VariableFn = ((this: ApolloVueThisType) => Object) | Object; type ApolloVueUpdateQueryFn = (this: ApolloVueThisType, previousQueryResult: { [key: string]: any }, options: { error: any, subscriptionData: { data: any; }; variables?: { [key: string]: any; }; }) => Object; interface ApolloVueSubscribeToMoreOptions { document: DocumentNode; variables?: VariableFn; updateQuery?: ApolloVueUpdateQueryFn; onError?: (error: Error) => void; } type _WatchQueryOptions = Omit; // exclude query prop because it causes type incorrectly error export interface VueApolloQueryOptions extends _WatchQueryOptions { query: ((this: ApolloVueThisType) => DocumentNode) | DocumentNode; variables?: VariableFn; update?: (this: ApolloVueThisType, data: R) => any; result?: (this: ApolloVueThisType, data: R, loader: any, netWorkStatus: NetworkStatus) => void; error?: (this: ApolloVueThisType, error: any) => void; loadingKey?: string; watchLoading?: (isLoading: boolean, countModifier: number) => void; skip?: (this: ApolloVueThisType) => boolean | boolean; manual?: boolean; subscribeToMore?: ApolloVueSubscribeToMoreOptions | ApolloVueSubscribeToMoreOptions[]; prefetch?: (context: any) => boolean | boolean; } export interface VueApolloMutationOptions extends MutationOptions { mutation: DocumentNode; variables?: VariableFn; optimisticResponse?: ((this: ApolloVueThisType) => any) | Object; } export interface VueApolloSubscriptionOptions extends SubscriptionOptions { query: DocumentNode; variables?: VariableFn; result?: (this: V, data: R) => void; } type QueryComponentProperty = ((this: ApolloVueThisType) => VueApolloQueryOptions) | VueApolloQueryOptions type SubscribeComponentProperty = VueApolloSubscriptionOptions | { [key: string]: VueApolloSubscriptionOptions } export type VueApolloOptions = { $skip?: boolean, $skipAllQueries?: boolean, $skipAllSubscriptions?: boolean, $client?: string, $loadingKey?: string, $error?: Function } export interface VueApolloComponentOption extends VueApolloOptions { [key: string]: QueryComponentProperty | SubscribeComponentProperty | string | boolean | Function | undefined; $subscribe?: SubscribeComponentProperty; }