Handle Ember Data 2.0.0 Error for missing hasMany relationsship in Payload


#1

Hey everyone, I´m currently migrating an old Ember Project from ember-data 1.0.0-beta15 to 2.0.0

While most works fine there´s one thing which will get in my way many times during this process, old Ember just ignored the case when there´s a hasMany Relationship in a Model which is not part of the received payload, the hasMany relationship was just empty or null.

Now with the new Version im getting an TypeError: Cannot read property ‘map’ of undefined error for relationshipHash == undefined in json-serializer

 if (relationshipMeta.kind === 'belongsTo') {
     data = _this4.extractRelationship(relationshipMeta.type, relationshipHash);
 } else if (relationshipMeta.kind === 'hasMany') {
     data = -->relationshipHash<--.map(function(item) {
         return _this4.extractRelationship(relationshipMeta.type, item);
     });
 }

Is there any workaround for this without the need to change the rest api ? We initially excluded nodes from the Responses to keep the payload as small as possible

Help would be much appreciated

EDIT: Admin please delete this, this behaviour is fixed by replacing old normalize: with normalizePayload: