I have a request that sideloads data two level deep IE the sideloaded data also has data that is sideloaded.
{
"group_measures": [{
"id": 565,
"group_id": 572,
"measure_id": 47
}],
"measures": [{
"id": 47,
}],
"group": {
"id": 572,
"group_measure_ids": [565]
}
}
I’m loading a group in this example and the group measure is properly filled but the group_measures measure attribute is null.
I’m currently digging through the source to figure out how this is happening. Does anyone know if ember-data recursively resolves sideloading? Also if you know where in the source I can find this behavior. I’m still digging around for it at the moment and haven’t isolated where it happens.
UPDATE
Ember does recursively resolve sideloading, though recursive isn’t really the best way to describe it since it just loads everything into the store and the resolving seems to happen outside the payload processing.
My problem was I had my group_measure defined as
var GroupMeasure = DS.Model.extend({
measureId: attr(),
group: DS.belongsTo('group'),
measure: DS.belongsTo('measure')
});
After removing measureId: attr() it works just fine. The measureId attr was the only way I could think of to be able to save a model with just the ID as opposed to having the whole record but that causes the record to not load properly. In fact out of the box saving with just the measureId didn’t work and I monkey patched it to force it to work so obviously this is not the way to do this…