import type { ApolloError, ApolloQueryResult, OperationVariables, SubscribeToMoreOptions, SubscriptionOptions, WatchQueryOptions, } from '@apollo/client/core/index.js' import type { DocumentNode } from 'graphql' // import { DeepApplyThisType } from './utils' /* Component options */ export interface AllVueApolloComponentSpecialOptions { $skip: boolean $skipAllQueries: boolean $skipAllSubscriptions: boolean $deep: boolean $client: string $loadingKey: string $watchLoading: WatchLoading $error: ErrorHandler $query: Partial $subscribe: VueApolloSubscriptionProperty } export type VueApolloComponentSpecialOptions = Partial interface PrivateVueApolloComponentOptions extends VueApolloComponentSpecialOptions { [key: string]: VueApolloQueryProperty | VueApolloComponentSpecialOptions[keyof VueApolloComponentSpecialOptions] } // DeepApplyThisType is buggy: https://github.com/microsoft/TypeScript/issues/33392 // export type VueApolloComponentOptions = DeepApplyThisType export type VueApolloComponentOptions = PrivateVueApolloComponentOptions & ThisType /* Special component options */ export type WatchLoading = (isLoading: boolean, countModifier: number) => void export type ErrorHandler = (error: ApolloError) => void /* Query */ type QueryVariables = (() => Variables) | Variables export type VueApolloQueryProperty = DocumentNode | VueApolloQueryDefinition | (() => VueApolloQueryDefinition | null) // exclude query prop because it causes type incorrectly error type WatchQueryOptionsWithoutQuery = Omit export interface VueApolloQueryDefinition extends WatchQueryOptionsWithoutQuery { query: DocumentNode | (() => DocumentNode | null) variables?: QueryVariables update?: (data: Result) => any result?: (result: ApolloQueryResult, key: string) => void error?: ErrorHandler manual?: boolean loadingKey?: string watchLoading?: WatchLoading skip?: (() => boolean) | boolean prefetch?: boolean client?: string deep?: boolean subscribeToMore?: VueApolloSubscribeToMoreOptions | VueApolloSubscribeToMoreOptions[] throttle?: number debounce?: number } /* Subscriptions */ export interface VueApolloSubscribeToMoreOptions extends Omit, 'variables'> { variables?: QueryVariables } export interface VueApolloSubscriptionDefinition extends Omit, 'variables'> { variables?: QueryVariables client?: string } export type VueApolloSubscriptionProperty = VueApolloSubscriptionDefinition | { [key: string]: VueApolloSubscriptionDefinition }