Skip to content

Commit 3207dd3

Browse files
committed
build
1 parent aaeedb0 commit 3207dd3

File tree

1 file changed

+25
-4
lines changed

1 file changed

+25
-4
lines changed

dist/vuex-orm-apollo.esm.js

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7867,7 +7867,11 @@ var QueryBuilder = /** @class */ (function () {
78677867
this.context.logger.log('Transformed data:', result);
78687868
this.context.logger.groupEnd();
78697869
}
7870-
return result;
7870+
else {
7871+
result['$isPersisted'] = true;
7872+
}
7873+
// MAke sure this is really a plain JS object. We had some issues in testing here.
7874+
return JSON.parse(JSON.stringify(result));
78717875
};
78727876
/**
78737877
* Generates the arguments string for a graphql query based on a given map.
@@ -8144,6 +8148,12 @@ var Context = /** @class */ (function () {
81448148
throw new Error('database param is required to initialize vuex-orm-apollo!');
81458149
}
81468150
this.collectModels();
8151+
this.logger.group('Context setup');
8152+
this.logger.log('components', this.components);
8153+
this.logger.log('options', this.options);
8154+
this.logger.log('database', this.database);
8155+
this.logger.log('models', this.models);
8156+
this.logger.groupEnd();
81478157
}
81488158
/**
81498159
* Returns a model by name
@@ -8168,8 +8178,17 @@ var Context = /** @class */ (function () {
81688178
this.database.entities.forEach(function (entity) {
81698179
var model = new Model(entity.model, _this);
81708180
_this.models.set(model.singularName, model);
8181+
_this.augmentModel(model);
81718182
});
81728183
};
8184+
Context.prototype.augmentModel = function (model) {
8185+
var originalFieldGenerator = model.baseModel.fields.bind(model.baseModel);
8186+
model.baseModel.fields = function () {
8187+
var originalFields = originalFieldGenerator();
8188+
originalFields['$isPersisted'] = model.baseModel.attr(false);
8189+
return originalFields;
8190+
};
8191+
};
81738192
return Context;
81748193
}());
81758194

@@ -8308,7 +8327,7 @@ var VuexORMApollo = /** @class */ (function () {
83088327
var state = _a.state, dispatch = _a.dispatch;
83098328
var id = _b.id, args = _b.args;
83108329
return __awaiter(this, void 0, void 0, function () {
8311-
var model, data, mutationName;
8330+
var model, data, mutationName, record;
83128331
return __generator(this, function (_c) {
83138332
switch (_c.label) {
83148333
case 0:
@@ -8321,8 +8340,10 @@ var VuexORMApollo = /** @class */ (function () {
83218340
return [4 /*yield*/, this.mutate(mutationName, args, dispatch, model, false)];
83228341
case 1:
83238342
_c.sent();
8324-
// TODO is this really necessary?
8325-
return [2 /*return*/, model.baseModel.getters('find')(id)];
8343+
record = model.baseModel.getters('find')(id);
8344+
record.$isPersisted = true;
8345+
record.$dispatch('update', { where: record.id, data: record });
8346+
return [2 /*return*/, record];
83268347
case 2: return [2 /*return*/];
83278348
}
83288349
});

0 commit comments

Comments
 (0)