Skip to content

Commit 0254d85

Browse files
author
Guillaume Chau
committed
fix(types): use ApolloQueryResult & FetchResult
1 parent 9e3b2bf commit 0254d85

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

types/options.d.ts

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,13 @@
1-
import { WatchQueryOptions, MutationOptions, SubscriptionOptions, SubscribeToMoreOptions, ObservableQuery, NetworkStatus } from 'apollo-client'
1+
import {
2+
WatchQueryOptions,
3+
MutationOptions,
4+
SubscriptionOptions,
5+
SubscribeToMoreOptions,
6+
ObservableQuery,
7+
NetworkStatus,
8+
ApolloQueryResult,
9+
} from 'apollo-client';
10+
import { FetchResult } from 'apollo-link';
211
import { DocumentNode } from 'graphql';
312

413
// include Omit type from https://github.com/Microsoft/TypeScript/issues/12215
@@ -28,7 +37,7 @@ type _WatchQueryOptions = Omit<WatchQueryOptions, 'query'>; // exclude query pro
2837

2938
interface ExtendableVueApolloQueryOptions<V, R> extends _WatchQueryOptions {
3039
update?: (this: ApolloVueThisType<V>, data: R) => any;
31-
result?: (this: ApolloVueThisType<V>, data: R, loader: any, netWorkStatus: NetworkStatus) => void;
40+
result?: (this: ApolloVueThisType<V>, data: ApolloQueryResult<R>, loader: any, netWorkStatus: NetworkStatus) => void;
3241
error?: ErrorHandler<V>;
3342
loadingKey?: string;
3443
watchLoading?: WatchLoading<V>;
@@ -55,7 +64,7 @@ export interface VueApolloSubscriptionOptions<V, R> extends SubscriptionOptions
5564
query: DocumentNode;
5665
variables?: VariableFn<V>;
5766
skip?: (this: ApolloVueThisType<V>) => boolean | boolean;
58-
result?: (this: V, data: R) => void;
67+
result?: (this: V, data: FetchResult<R>) => void;
5968
}
6069

6170
type QueryComponentProperty<V> = ((this: ApolloVueThisType<V>) => VueApolloQueryOptions<V, any>) | VueApolloQueryOptions<V, any>

types/vue-apollo.d.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import Vue, { PluginObject, PluginFunction } from 'vue';
2-
import { ApolloClient, ObservableQuery } from 'apollo-client';
2+
import { ApolloClient, ObservableQuery, ApolloQueryResult } from 'apollo-client';
3+
import { FetchResult } from 'apollo-link';
34
import { Observable } from 'apollo-client/util/Observable';
45
import { ApolloProvider, VueApolloComponent } from './apollo-provider'
56
import {
@@ -40,11 +41,6 @@ export interface SmartQuery<V> extends SmartApollo<V> {
4041
export interface SmartSubscription<V> extends SmartApollo<V> {
4142
}
4243

43-
export declare type QueryResult<T> = {
44-
data: T;
45-
errors?: GraphQLError[];
46-
};
47-
4844
export interface DollarApollo<V> {
4945
vm: V;
5046
queries: Record<string, SmartQuery<V>>;
@@ -57,9 +53,9 @@ export interface DollarApollo<V> {
5753
/* writeonly */ skipAllSubscriptions: boolean;
5854
/* writeonly */ skipAll: boolean;
5955

60-
query<R=any>(options: VueApolloQueryOptions<V, R>): Promise<QueryResult<R>>;
61-
mutate<R=any>(options: VueApolloMutationOptions<V, R>): Promise<QueryResult<R>>;
62-
subscribe<R=any>(options: VueApolloSubscriptionOptions<V, R>): Observable<R>;
56+
query<R=any>(options: VueApolloQueryOptions<V, R>): Promise<ApolloQueryResult<R>>;
57+
mutate<R=any>(options: VueApolloMutationOptions<V, R>): Promise<FetchResult<R>>;
58+
subscribe<R=any>(options: VueApolloSubscriptionOptions<V, R>): Observable<FetchResult<R>>;
6359

6460
addSmartQuery<R=any>(key: string, options: VueApolloQueryOptions<V, R>): SmartQuery<V>;
6561
addSmartSubscription<R=any>(key: string, options: VueApolloSubscriptionOptions<V, R>): SmartSubscription<V>;

0 commit comments

Comments
 (0)