Recursive Sideloading

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.


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…

I believe the recursive models still need to be “unpacked”, eg. be inside of root-level objects. I don’t think you can just nest them in place.

@kylecoberly I updated the question with my payload I think I’m “unpacking” it but I maybe interpreting your meaning incorrectly.

Has it been your experience that ember will recursively resolve sideloading?

Your response is structured correctly- I think the problem is that you’re calling things like “group_measure_ids” instead of “groupMeasures.” That’s adapter/serializer specific though. Mine looks more like the example from the docs:

  "post": {
    "id": 1,
    "title": "Node is not omakase",
    "comments": [1, 2, 3]

  "comments": [{
    "id": 1,
    "body": "But is it _lightweight_ omakase?"
    "id": 2,
    "body": "I for one welcome our new omakase overlords"
    "id": 3,
    "body": "Put me on the fast track to a delicious dinner"

@kylcoberly thanks for your response. I’m using ActiveModelSerializer which does seem to accept this formatting as other sideloaded models work fine. In this example the group_measures get loaded but the measures on the group measures do not.

You’re comment has got me thinking to look deeper into ActiveModelSerializer.