Ember Data asynchronous dependencies with links issue


#1

I’m trying to get my around this issue I found with Ember Data

export default DS.Model.extend({
  name: DS.attr('string'),
  children: DS.hasMany('child', {async: true}),
  jobs: DS.hasMany('job', {async: true}),
})

And having the server API defined to use .links, as define by JSON API, the response when retrieving a person is:

"person": {
  "name": "John Smith",
  "links": {
    "children": "./children",
    "jobs": "./jobs"
  }
}

This works perfectly fine. I know to edit or add a async dependency I need to trigger the load in the parent and then modify the collection. Where I am stuck now is in the following case:

I have a route where I’m modifying the children, and I operate as indicated above, but I have not doing anything to the jobs relationship, when I save the person with the modified children, is saving the whole object, and sending this payload to the server:

person: {
  name: "John Smith",
  children: "newChild_id",
  jobs: []
}

The jobs dependency is being sent anyway and empty, therefore removing it from the parent.

I would have thought that Ember Data would check if the dependency was not loaded and remove it from the payload, to avoid forcing users to load all async dependencies even they are not to be modified.

I know Ember Data is not finished and they just wrote recently about it in their blog, and specifically about something related to it, two-way relationships, but I don’t think is exactly the same case.

Am I missing something here?