jeudi 23 juillet 2015

Saving models and their relationships using the new Ember Data JSONAPISerializer/Adapter

I have implemented a JSON-API backend and I'm using ember (1.13.4) and ember data (1.13.5) to pull my data in to the store using the new JSONAPIAdapter / JSONAPISerializer. All is working well and the store is populated with all of the models and their attributes/relationships.

However, when I call the .save() method on my models the JSON-API-formatted request that is generated doesn't contain the "included" key with all related models inside it. This means that if I modify an attribute in a related model and then save the primary model I don't see the changed attribute from the related model in the JSON payload.

What is the correct way to save models and their relationships so they are embedded using the new JSONAPIAdapter / JSONAPISerializer? I tried the EmbeddedRecordsMixin but this resulted in null attribute values within the "attributes" key of the payload.

If anyone can assist me with this I'd be grateful.

Thanks.




Aucun commentaire:

Enregistrer un commentaire