From 5fcd3b2d337de521596abae717751827d86d7f62 Mon Sep 17 00:00:00 2001 From: Oleksandr Chepurnyi Date: Fri, 2 Sep 2022 20:41:58 +0300 Subject: [PATCH] Fix deprecation: `ember-data:deprecate-snapshot-model-class-access`. --- addon/serializers/serializer.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/addon/serializers/serializer.js b/addon/serializers/serializer.js index 545e660..94f0138 100644 --- a/addon/serializers/serializer.js +++ b/addon/serializers/serializer.js @@ -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'); } @@ -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'); }