Skip to content

Commit 3eca85d

Browse files
committed
Also allow passing additional args in convenience methods
1 parent 7ea36e3 commit 3eca85d

File tree

4 files changed

+19
-8
lines changed

4 files changed

+19
-8
lines changed

dist/vuex-orm-apollo.esm.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -9962,17 +9962,17 @@ var VuexORMApollo = /** @class */ (function () {
99629962
});
99639963
});
99649964
};
9965-
this.context.components.Model.prototype.$persist = function () {
9965+
this.context.components.Model.prototype.$persist = function (args) {
99669966
return __awaiter(this, void 0, void 0, function () {
99679967
return __generator(this, function (_a) {
9968-
return [2 /*return*/, this.$dispatch('persist', { id: this.id })];
9968+
return [2 /*return*/, this.$dispatch('persist', { id: this.id, args: args })];
99699969
});
99709970
});
99719971
};
9972-
this.context.components.Model.prototype.$push = function () {
9972+
this.context.components.Model.prototype.$push = function (args) {
99739973
return __awaiter(this, void 0, void 0, function () {
99749974
return __generator(this, function (_a) {
9975-
return [2 /*return*/, this.$dispatch('push', { data: this })];
9975+
return [2 /*return*/, this.$dispatch('push', { data: this, args: args })];
99769976
});
99779977
});
99789978
};

docs/guide/persist/README.md

+5
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,8 @@ Variables:
5858

5959
Like when pushing, all records which are returned replace the respective existing records in the Vuex-ORM database.
6060

61+
62+
## Additional variables
63+
64+
You can pass a object like this: `$perist({ captchaToken: 'asdfasdf' })`. All fields in the object will be passed as
65+
variables to the mutation.

docs/guide/push/README.md

+6
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,9 @@ Variables:
5353

5454
Like when persisting, all records which are returned replace the respective existing records in the Vuex-ORM database.
5555

56+
57+
58+
## Additional variables
59+
60+
You can pass a object like this: `$push({ captchaToken: 'asdfasdf' })`. All fields in the object will be passed as
61+
variables to the mutation.

src/vuex-orm-apollo.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,12 @@ export default class VuexORMApollo {
9393
return this.$dispatch('mutate', params);
9494
};
9595

96-
this.context.components.Model.prototype.$persist = async function() {
97-
return this.$dispatch('persist', { id: this.id });
96+
this.context.components.Model.prototype.$persist = async function(args: any) {
97+
return this.$dispatch('persist', { id: this.id, args });
9898
};
9999

100-
this.context.components.Model.prototype.$push = async function() {
101-
return this.$dispatch('push', { data: this });
100+
this.context.components.Model.prototype.$push = async function(args: any) {
101+
return this.$dispatch('push', { data: this, args });
102102
};
103103

104104
this.context.components.Model.prototype.$destroy = async function() {

0 commit comments

Comments
 (0)