File tree Expand file tree Collapse file tree 2 files changed +20
-8
lines changed Expand file tree Collapse file tree 2 files changed +20
-8
lines changed Original file line number Diff line number Diff line change @@ -15,6 +15,14 @@ const SUB_QUERY = gql`subscription tags($type: String!) {
1515 }
1616}`
1717
18+ interface Foo {
19+ foo : string
20+ }
21+
22+ interface HelloVars {
23+ hello : string
24+ }
25+
1826export const hey = Vue . extend ( {
1927 props : {
2028 meow : String ,
@@ -161,13 +169,16 @@ export const hey = Vue.extend({
161169 }
162170 } ,
163171
164- created ( ) {
165- this . $apollo . mutate ( {
172+ async created ( ) {
173+ const { data } = await this . $apollo . mutate < Foo , HelloVars > ( {
166174 mutation : gql `mutation {}` ,
167175 variables : {
168176 hello : this . hello
169177 } ,
170178 } )
179+ if ( data ) {
180+ console . log ( data . foo )
181+ }
171182 this . hello . toUpperCase ( )
172183 this . $apollo . vm . hello . toUpperCase ( )
173184 }
Original file line number Diff line number Diff line change 77 WatchQueryOptions ,
88 MutationOptions ,
99 SubscriptionOptions ,
10+ OperationVariables ,
1011} from 'apollo-client'
1112import { FetchResult } from 'apollo-link'
1213import { Observable } from 'apollo-client/util/Observable'
@@ -54,14 +55,14 @@ interface ClientOptions {
5455 client ?: string
5556}
5657
57- interface ApolloClientMethods < R > {
58- query : ( options : QueryOptions & ClientOptions ) => ReturnType < ApolloClient < R > [ 'query' ] >
59- watchQuery : ( options : WatchQueryOptions & ClientOptions ) => ReturnType < ApolloClient < R > [ 'watchQuery' ] >
60- mutate : ( options : MutationOptions & ClientOptions ) => ReturnType < ApolloClient < R > [ 'mutate' ] >
61- subscribe : ( options : SubscriptionOptions & ClientOptions ) => ReturnType < ApolloClient < R > [ 'subscribe' ] >
58+ interface ApolloClientMethods {
59+ query < R = any , TVariables = OperationVariables > ( options : QueryOptions < TVariables > & ClientOptions ) : Promise < ApolloQueryResult < R > >
60+ watchQuery < R = any , TVariables = OperationVariables > ( options : WatchQueryOptions < TVariables > & ClientOptions ) : ObservableQuery < R , TVariables >
61+ mutate < R = any , TVariables = OperationVariables > ( options : MutationOptions < R , TVariables > & ClientOptions ) : Promise < FetchResult < R > >
62+ subscribe < R = any , TVariables = OperationVariables > ( options : SubscriptionOptions < TVariables > & ClientOptions ) : Observable < FetchResult < R > >
6263}
6364
64- export interface DollarApollo < V , R = any > extends ApolloClientMethods < R > {
65+ export interface DollarApollo < V > extends ApolloClientMethods {
6566 vm : V
6667 queries : Record < string , SmartQuery < V > >
6768 subscriptions : Record < string , SmartSubscription < V > >
You can’t perform that action at this time.
0 commit comments