@@ -2,7 +2,7 @@ import Model from './model';
2
2
import { ApolloClient , FetchPolicy } from 'apollo-client' ;
3
3
import { HttpLink } from 'apollo-link-http' ;
4
4
import { InMemoryCache } from 'apollo-cache-inmemory' ;
5
- import { Data , ActionParams , Arguments , DispatchFunction , PatchedModel } from './interfaces' ;
5
+ import { Data , ActionParams , Arguments , DispatchFunction , PatchedModel } from './interfaces' ;
6
6
import QueryBuilder from './queryBuilder' ;
7
7
import { upcaseFirstLetter } from './utils' ;
8
8
import Context from './context' ;
@@ -74,53 +74,43 @@ export default class VuexORMApollo {
74
74
this . context . components . subActions . destroy = this . destroy . bind ( this ) ;
75
75
this . context . components . subActions . mutate = this . customMutation . bind ( this ) ;
76
76
77
-
78
77
// Register static model convenience methods
79
- ( this . context . components . Model as ( typeof PatchedModel ) ) . fetch = async function ( filter : any , bypassCache = false ) {
78
+ ( this . context . components . Model as ( typeof PatchedModel ) ) . fetch = async function ( filter : any , bypassCache = false ) {
80
79
let filterObj = filter ;
81
80
if ( typeof filterObj !== 'object' ) filterObj = { id : filter } ;
82
81
return this . dispatch ( 'fetch' , { filter : filterObj , bypassCache } ) ;
83
82
} ;
84
83
85
- ( this . context . components . Model as ( typeof PatchedModel ) ) . mutate = async function ( params : any ) {
84
+ ( this . context . components . Model as ( typeof PatchedModel ) ) . mutate = async function ( params : any ) {
86
85
return this . dispatch ( 'mutate' , params ) ;
87
86
} ;
88
87
89
-
90
88
// Register model convenience methods
91
- this . context . components . Model . prototype . $mutate = async function ( params : any ) {
89
+ this . context . components . Model . prototype . $mutate = async function ( params : any ) {
92
90
if ( ! params [ 'id' ] ) params [ 'id' ] = this . id ;
93
91
return this . $dispatch ( 'mutate' , params ) ;
94
92
} ;
95
93
96
- this . context . components . Model . prototype . $persist = async function ( args : any ) {
94
+ this . context . components . Model . prototype . $persist = async function ( args : any ) {
97
95
return this . $dispatch ( 'persist' , { id : this . id , args } ) ;
98
96
} ;
99
97
100
- this . context . components . Model . prototype . $push = async function ( args : any ) {
98
+ this . context . components . Model . prototype . $push = async function ( args : any ) {
101
99
return this . $dispatch ( 'push' , { data : this , args } ) ;
102
100
} ;
103
101
104
- this . context . components . Model . prototype . $destroy = async function ( ) {
102
+ this . context . components . Model . prototype . $destroy = async function ( ) {
105
103
return this . $dispatch ( 'destroy' , { id : this . id } ) ;
106
104
} ;
107
105
108
- this . context . components . Model . prototype . $deleteAndDestroy = async function ( ) {
106
+ this . context . components . Model . prototype . $deleteAndDestroy = async function ( ) {
109
107
await this . $delete ( ) ;
110
108
return this . $destroy ( ) ;
111
109
} ;
112
110
113
111
// this.components.subActions.destroyAll = this.destroyAll.bind(this);
114
112
}
115
113
116
-
117
- /**
118
- * Helper to dispatch actions on the store
119
- */
120
- public dispatch ( params : ActionParams ) {
121
-
122
- }
123
-
124
114
/**
125
115
* Will be called, when dispatch('entities/something/fetch') is called.
126
116
*
0 commit comments