DS.Errors in a call with DS.EmbeddedRecordsMixin



I’m doing a call to an endpoint, with embedded records (for various reasons). I’m trying to adhere to the JSON API standard as closely as possible with my backend, but in this case embedded records are necessary.

This is a hypothetical use case to illustrate my problem:

Say I have a model Account, with a child relationship Contacts, when saving an account, I have to include all the contacts in the REST call, by defining my serializer like this:


import DS from 'ember-data';

export default DS.JSONAPISerializer.extend(DS.EmbeddedRecordsMixin, {
  attrs: {
    contacts: { embedded: 'always' },

My backend deserialises the incoming call, and validates each model separately, first the account, next all the included contacts.

If we can say that the saving of the account is only possible when the contacts included in the call can also be saved, How would by back-end need to respond to handle validation errors on 1 or more contacts to be able to correctly respond with a DS.Errors response?

Or if that isn’t possible, how could I handle the response on the Ember side?