From e22f3b80285f483fd588629ae94bfe4cb6c7eda6 Mon Sep 17 00:00:00 2001 From: Ilya Radchenko Date: Wed, 1 Sep 2021 15:12:57 -0400 Subject: [PATCH 1/2] fix: modelName undefined when serializing fragment Resolves https://github.com/adopted-ember-addons/ember-data-model-fragments/issues/406 --- addon/transforms/fragment.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/transforms/fragment.js b/addon/transforms/fragment.js index d62dfc59..8b080a73 100644 --- a/addon/transforms/fragment.js +++ b/addon/transforms/fragment.js @@ -35,7 +35,7 @@ const FragmentTransform = Transform.extend({ } let store = this.store; - let serializer = store.serializerFor(snapshot.modelName); + let serializer = store.serializerFor(snapshot.modelName || snapshot.constructor.modelName); return serializer.serialize(snapshot); }, From 3f8fc211d5794c58bcdefcd22d1b0afeb4150ded Mon Sep 17 00:00:00 2001 From: Ilya Radchenko Date: Wed, 15 Sep 2021 13:14:22 -0400 Subject: [PATCH 2/2] fix: alternative model name for fragment array --- addon/transforms/fragment-array.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/addon/transforms/fragment-array.js b/addon/transforms/fragment-array.js index 56b1fc3e..c7cd25dd 100644 --- a/addon/transforms/fragment-array.js +++ b/addon/transforms/fragment-array.js @@ -31,7 +31,7 @@ const FragmentArrayTransform = FragmentTransform.extend({ let store = this.store; return snapshots.map(snapshot => { - let serializer = store.serializerFor(snapshot.modelName); + let serializer = store.serializerFor(snapshot.modelName || snapshot.constructor.modelName); return serializer.serialize(snapshot); }); }