ghidoz / angular2-jsonapi

A lightweight Angular 2 adapter for JSON API
199 stars 123 forks source link

Omit relationships when saving record #253

Open hpawe01 opened 4 years ago

hpawe01 commented 4 years ago

At the moment, when I save a model, for that already some relationships are loaded, the resulting PATCH request contains all the relationships, which can bloat up the request: https://github.com/ghidoz/angular2-jsonapi/blob/master/projects/angular2-jsonapi/src/services/json-api-datastore.service.ts#L148

Is there a way to send the PATCH request without the relationships, that I do not think of?

Because following the specification, there should be both ways possible: https://jsonapi.org/format/#crud-updating-resource-relationships

If there is no possibility at the moment: any suggestions on how to implement it? Than I could create a pull request.

bosk59 commented 4 years ago

It's a big problem. if a same object has been modified by another user the patch operation can result in an error at backend side. Dbconcurrency exception per example. Because one of the relationships has been modified between the last refresh and the update operation . If you want to update a single value , have this kind of error is ridiculous...

Need a fix for this...