Skip to content

Commit f76a62f

Browse files
committed
Bugfix
1 parent a1edbd0 commit f76a62f

File tree

4 files changed

+14
-24
lines changed

4 files changed

+14
-24
lines changed

src/context.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import Logger from './logger';
22
import Model from './model';
3-
import ORMModel from "@vuex-orm/core/lib/model/Model";
3+
import ORMModel from '@vuex-orm/core/lib/model/Model';
44
import { Components, Options } from '@vuex-orm/core/lib/plugins/use';
55
import { downcaseFirstLetter } from './utils';
66
const inflection = require('inflection');

src/interfaces.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import ORMModel from "@vuex-orm/core/lib/model/Model";
1+
import ORMModel from '@vuex-orm/core/lib/model/Model';
22

33
export type DispatchFunction = (action: string, data: Data) => Promise<any>;
44

@@ -36,6 +36,6 @@ export interface Field {
3636
}
3737

3838
export class PatchedModel extends ORMModel {
39-
static async fetch(filter: any, bypassCache = false): Promise<any> { return; };
40-
static async mutate(params: any): Promise<any> { return; };
39+
static async fetch (filter: any, bypassCache = false): Promise<any> { return undefined; }
40+
static async mutate (params: any): Promise<any> { return undefined; }
4141
}

src/model.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import ORMModel from "@vuex-orm/core/lib/model/Model";
2-
import { Field, } from './interfaces';
1+
import ORMModel from '@vuex-orm/core/lib/model/Model';
2+
import { Field } from './interfaces';
33
import Context from './context';
44
const inflection = require('inflection');
55

src/vuex-orm-apollo.ts

+8-18
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Model from './model';
22
import { ApolloClient, FetchPolicy } from 'apollo-client';
33
import { HttpLink } from 'apollo-link-http';
44
import { InMemoryCache } from 'apollo-cache-inmemory';
5-
import {Data, ActionParams, Arguments, DispatchFunction, PatchedModel} from './interfaces';
5+
import { Data, ActionParams, Arguments, DispatchFunction, PatchedModel } from './interfaces';
66
import QueryBuilder from './queryBuilder';
77
import { upcaseFirstLetter } from './utils';
88
import Context from './context';
@@ -74,53 +74,43 @@ export default class VuexORMApollo {
7474
this.context.components.subActions.destroy = this.destroy.bind(this);
7575
this.context.components.subActions.mutate = this.customMutation.bind(this);
7676

77-
7877
// 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) {
8079
let filterObj = filter;
8180
if (typeof filterObj !== 'object') filterObj = { id: filter };
8281
return this.dispatch('fetch', { filter: filterObj, bypassCache });
8382
};
8483

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) {
8685
return this.dispatch('mutate', params);
8786
};
8887

89-
9088
// 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) {
9290
if (!params['id']) params['id'] = this.id;
9391
return this.$dispatch('mutate', params);
9492
};
9593

96-
this.context.components.Model.prototype.$persist = async function(args: any) {
94+
this.context.components.Model.prototype.$persist = async function (args: any) {
9795
return this.$dispatch('persist', { id: this.id, args });
9896
};
9997

100-
this.context.components.Model.prototype.$push = async function(args: any) {
98+
this.context.components.Model.prototype.$push = async function (args: any) {
10199
return this.$dispatch('push', { data: this, args });
102100
};
103101

104-
this.context.components.Model.prototype.$destroy = async function() {
102+
this.context.components.Model.prototype.$destroy = async function () {
105103
return this.$dispatch('destroy', { id: this.id });
106104
};
107105

108-
this.context.components.Model.prototype.$deleteAndDestroy = async function() {
106+
this.context.components.Model.prototype.$deleteAndDestroy = async function () {
109107
await this.$delete();
110108
return this.$destroy();
111109
};
112110

113111
// this.components.subActions.destroyAll = this.destroyAll.bind(this);
114112
}
115113

116-
117-
/**
118-
* Helper to dispatch actions on the store
119-
*/
120-
public dispatch(params: ActionParams) {
121-
122-
}
123-
124114
/**
125115
* Will be called, when dispatch('entities/something/fetch') is called.
126116
*

0 commit comments

Comments
 (0)