Skip to content

Commit aa4d2bc

Browse files
committed
Some kind of bugfix
1 parent 5ccb97a commit aa4d2bc

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

dist/vuex-orm-apollo.esm.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -7811,7 +7811,7 @@ var QueryBuilder = /** @class */ (function () {
78117811
Object.keys(data).forEach(function (key) {
78127812
var value = data[key];
78137813
// Ignore IDs and connections and empty fields
7814-
if (!relations.has(key) && !key.startsWith('$') && key !== 'id' && value !== null) {
7814+
if (!relations.has(key) && !model.skipField(key) && key !== 'id' && value !== null) {
78157815
returnValue[key] = value;
78167816
}
78177817
});
@@ -8505,7 +8505,14 @@ var VuexORMApollo = /** @class */ (function () {
85058505
return [4 /*yield*/, this.insertData(newData, dispatch)];
85068506
case 2:
85078507
insertedData = _a.sent();
8508-
return [2 /*return*/, insertedData[model.pluralName][0]];
8508+
if (insertedData[model.pluralName] && insertedData[model.pluralName][0]) {
8509+
return [2 /*return*/, insertedData[model.pluralName][0]];
8510+
}
8511+
else {
8512+
this.context.logger.log("Couldn't find the record of type", model.pluralName, 'in', insertedData, '. Fallback to find()');
8513+
return [2 /*return*/, model.baseModel.getters('query')().last()];
8514+
}
8515+
_a.label = 3;
85098516
case 3: return [2 /*return*/, true];
85108517
case 4: return [2 /*return*/];
85118518
}

src/queryBuilder.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ export default class QueryBuilder {
140140
const value = data[key];
141141

142142
// Ignore IDs and connections and empty fields
143-
if (!relations.has(key) && !key.startsWith('$') && key !== 'id' && value !== null) {
143+
if (!relations.has(key) && !model.skipField(key) && key !== 'id' && value !== null) {
144144
returnValue[key] = value;
145145
}
146146
});

src/vuex-orm-apollo.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,14 @@ export default class VuexORMApollo {
224224

225225
if (name !== `delete${upcaseFirstLetter(model.singularName)}`) {
226226
const insertedData: Data = await this.insertData(newData, dispatch);
227-
return insertedData[model.pluralName][0];
227+
228+
if (insertedData[model.pluralName] && insertedData[model.pluralName][0]) {
229+
return insertedData[model.pluralName][0];
230+
} else {
231+
this.context.logger.log("Couldn't find the record of type", model.pluralName, 'in', insertedData,
232+
'. Fallback to find()');
233+
return model.baseModel.getters('query')().last();
234+
}
228235
}
229236

230237
return true;

0 commit comments

Comments
 (0)