mobx-rest icon indicating copy to clipboard operation
mobx-rest copied to clipboard

Model mapper support

Open emrahtoy opened this issue 5 years ago • 3 comments

Sometime we may need to use different kind of models for view model and request model. That could be vice and versa. Model mapper can handle such mapping automatically.

emrahtoy avatar Sep 22 '19 08:09 emrahtoy

I'm not sure about the reason for that change. mobx-rest id built around REST semantics. The problem you are describing falls outside of REST.

For example, if you're using an api takes and returns different kind of models or you are using view model different than api model, you use username for view and name for api request, it could look like this

This is what I don't fully grasp. When using REST, there are no api model nor view model. Either the resource has username or has name, or both. But read and write are symmetrical.

I would prefer to not support non-REST semantics.

masylum avatar Oct 14 '19 06:10 masylum

I guess this try to add JSON-API compliance

auvipy avatar Dec 09 '19 09:12 auvipy

I guess this try to add JSON-API compliance

It could work that way too.

Apps on field are not always well designed. Sometime for security reasons mainly you may need change your response model to something else. It is indeed made for that case. Also makes view-model and server-model bindings/mappings easier.

emrahtoy avatar Dec 09 '19 10:12 emrahtoy