fix(types): use ApolloQueryResult & FetchResult
This commit is contained in:
Vendored
+12
-3
@@ -1,4 +1,13 @@
|
||||
import { WatchQueryOptions, MutationOptions, SubscriptionOptions, SubscribeToMoreOptions, ObservableQuery, NetworkStatus } from 'apollo-client'
|
||||
import {
|
||||
WatchQueryOptions,
|
||||
MutationOptions,
|
||||
SubscriptionOptions,
|
||||
SubscribeToMoreOptions,
|
||||
ObservableQuery,
|
||||
NetworkStatus,
|
||||
ApolloQueryResult,
|
||||
} from 'apollo-client';
|
||||
import { FetchResult } from 'apollo-link';
|
||||
import { DocumentNode } from 'graphql';
|
||||
|
||||
// include Omit type from https://github.com/Microsoft/TypeScript/issues/12215
|
||||
@@ -28,7 +37,7 @@ type _WatchQueryOptions = Omit<WatchQueryOptions, 'query'>; // exclude query pro
|
||||
|
||||
interface ExtendableVueApolloQueryOptions<V, R> extends _WatchQueryOptions {
|
||||
update?: (this: ApolloVueThisType<V>, data: R) => any;
|
||||
result?: (this: ApolloVueThisType<V>, data: R, loader: any, netWorkStatus: NetworkStatus) => void;
|
||||
result?: (this: ApolloVueThisType<V>, data: ApolloQueryResult<R>, loader: any, netWorkStatus: NetworkStatus) => void;
|
||||
error?: ErrorHandler<V>;
|
||||
loadingKey?: string;
|
||||
watchLoading?: WatchLoading<V>;
|
||||
@@ -55,7 +64,7 @@ export interface VueApolloSubscriptionOptions<V, R> extends SubscriptionOptions
|
||||
query: DocumentNode;
|
||||
variables?: VariableFn<V>;
|
||||
skip?: (this: ApolloVueThisType<V>) => boolean | boolean;
|
||||
result?: (this: V, data: R) => void;
|
||||
result?: (this: V, data: FetchResult<R>) => void;
|
||||
}
|
||||
|
||||
type QueryComponentProperty<V> = ((this: ApolloVueThisType<V>) => VueApolloQueryOptions<V, any>) | VueApolloQueryOptions<V, any>
|
||||
|
||||
Vendored
+5
-9
@@ -1,5 +1,6 @@
|
||||
import Vue, { PluginObject, PluginFunction } from 'vue';
|
||||
import { ApolloClient, ObservableQuery } from 'apollo-client';
|
||||
import { ApolloClient, ObservableQuery, ApolloQueryResult } from 'apollo-client';
|
||||
import { FetchResult } from 'apollo-link';
|
||||
import { Observable } from 'apollo-client/util/Observable';
|
||||
import { ApolloProvider, VueApolloComponent } from './apollo-provider'
|
||||
import {
|
||||
@@ -40,11 +41,6 @@ export interface SmartQuery<V> extends SmartApollo<V> {
|
||||
export interface SmartSubscription<V> extends SmartApollo<V> {
|
||||
}
|
||||
|
||||
export declare type QueryResult<T> = {
|
||||
data: T;
|
||||
errors?: GraphQLError[];
|
||||
};
|
||||
|
||||
export interface DollarApollo<V> {
|
||||
vm: V;
|
||||
queries: Record<string, SmartQuery<V>>;
|
||||
@@ -57,9 +53,9 @@ export interface DollarApollo<V> {
|
||||
/* writeonly */ skipAllSubscriptions: boolean;
|
||||
/* writeonly */ skipAll: boolean;
|
||||
|
||||
query<R=any>(options: VueApolloQueryOptions<V, R>): Promise<QueryResult<R>>;
|
||||
mutate<R=any>(options: VueApolloMutationOptions<V, R>): Promise<QueryResult<R>>;
|
||||
subscribe<R=any>(options: VueApolloSubscriptionOptions<V, R>): Observable<R>;
|
||||
query<R=any>(options: VueApolloQueryOptions<V, R>): Promise<ApolloQueryResult<R>>;
|
||||
mutate<R=any>(options: VueApolloMutationOptions<V, R>): Promise<FetchResult<R>>;
|
||||
subscribe<R=any>(options: VueApolloSubscriptionOptions<V, R>): Observable<FetchResult<R>>;
|
||||
|
||||
addSmartQuery<R=any>(key: string, options: VueApolloQueryOptions<V, R>): SmartQuery<V>;
|
||||
addSmartSubscription<R=any>(key: string, options: VueApolloSubscriptionOptions<V, R>): SmartSubscription<V>;
|
||||
|
||||
Reference in New Issue
Block a user