Skip to content

Commit 37dfe6f

Browse files
committed
Do not process undefined refs
1 parent a08a889 commit 37dfe6f

File tree

3 files changed

+3
-8
lines changed

3 files changed

+3
-8
lines changed

lib/ApiStore.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,13 +247,8 @@ export default class ApiStore<S> implements StoreOptions<S> {
247247
modelName: string,
248248
prop: string
249249
) {
250-
if (has(this.models, modelName)) {
250+
if (has(this.models, modelName) && has(entity, prop)) {
251251
return this.upsertData(store, this.models[modelName], entity[prop]);
252-
} else {
253-
// eslint-disable-next-line no-console
254-
console.warn(
255-
`Patch error: We could not find the model ${modelName} for the reference ${prop}.`
256-
);
257252
}
258253
}
259254
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vuex-rest-plugin",
3-
"version": "0.2.16",
3+
"version": "0.2.17",
44
"private": true,
55
"main": "dist/vuex-rest-plugin.common.js",
66
"scripts": {

tests/unit/apistoreCustomModel.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ describe("ApiStore custom model", function() {
7272
console.info("Start expected log");
7373
await flushPromises();
7474
expect(spyWarn).toHaveBeenCalledWith(
75-
"Patch error: We could not find the model fakeref for the reference user."
75+
"We could not find the model RESOURCES."
7676
);
7777
console.info("End expected log");
7878
});

0 commit comments

Comments
 (0)