Skip to content

Commit

Permalink
Fix deprecation: ember-data:deprecate-snapshot-model-class-access.
Browse files Browse the repository at this point in the history
  • Loading branch information
wuron committed Sep 2, 2022
1 parent 65c7d73 commit 5fcd3b2
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions addon/serializers/serializer.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,8 @@ export default JSONAPISerializer.extend({
if (belongsTo === null || belongsToIsNotNew) {
json.relationships = json.relationships || {};

let payloadKey = this._getMappedKey(key, snapshot.type);
let modelType = this.store.modelFor(snapshot.modelName);
let payloadKey = this._getMappedKey(key, modelType);
if (payloadKey === key) {
payloadKey = this.keyForRelationship(key, 'belongsTo', 'serialize');
}
Expand Down Expand Up @@ -67,7 +68,8 @@ export default JSONAPISerializer.extend({
if (hasMany !== undefined) {
json.relationships = json.relationships || {};

let payloadKey = this._getMappedKey(key, snapshot.type);
let modelType = this.store.modelFor(snapshot.modelName);
let payloadKey = this._getMappedKey(key, modelType);
if (payloadKey === key && this.keyForRelationship) {
payloadKey = this.keyForRelationship(key, 'hasMany', 'serialize');
}
Expand Down

0 comments on commit 5fcd3b2

Please sign in to comment.