Skip to content

Commit 9ec1799

Browse files
fix: Wrap read only relationships deletion in try catch (#4056)
* fix: Event creation/deletion error * try-catch * fix final * Adding comments Co-Authored-By: Areeb Jamal <[email protected]> * Trailing space fix Co-authored-by: Areeb Jamal <[email protected]>
1 parent 957934c commit 9ec1799

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

app/serializers/event.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,20 @@ export default ApplicationSerializer.extend(CustomPrimaryKeyMixin, {
1313

1414
serialize() {
1515
const json = this._super(...arguments);
16-
delete json.data.relationships['general-statistics'];
17-
delete json.data.relationships['order-statistics'];
16+
17+
const { relationships } = json.data;
18+
// We are deleting read only relationships so that they don't
19+
// break the server. Since these relationships are not always
20+
// present, we catch and ignore the error
21+
try {
22+
delete relationships['general-statistics'];
23+
} catch {} // eslint-disable-line no-empty
24+
try {
25+
delete relationships['order-statistics'];
26+
} catch {} // eslint-disable-line no-empty
1827

1928
return json;
29+
2030
}
2131

2232
});

0 commit comments

Comments
 (0)