mobx-rest
mobx-rest copied to clipboard
JSON-API Support
We are looking to use mobx-rest to connect to a variety of backends including some using JSON-API format data.
It looks like there will be a variety of issues to get this to work. At minimum, there needs to be a transformation of data prior to populating Models which doesn't seem to be easily done without overriding all of the primary methods ie fetch(). In addition JSON-API provides additional request-level metadata for things like paging, and total data set sizes. It would be great for this metadata to natively accessible within the mobx-rest API and/or data-shape.
The mobx-jsonapi project appears to be a POC forked from an older version of mobx-rest that demonstrates some of this functionality. It seems like this requirement might be better fulfilled with some extensions to mobx-rest, or a specialized adapter.
Posting this issue to see if any other teams are pursuing the same goal and to facilitate discussion on the cleanest way to implement JSON-API support.
Yes, I don't know exactly what JSON-API requires to work with mobx-rest. But I think an api adapter could work. But I guess is the community that will need to do a PR to this project or an adapter
mobx-rest
is just a layer of REST conventions so you don't have to implement them from scratch. That being said, we abstracted away the transport layer so that it can be plugged in different environments (ReactNative, Web, Nodejs). I haven't seen anyone doing a mobx-rest-adapter
to support different format data, but I don't see the reason why this shouldn't be possible.
You could start by forking mobx-rest-fetch-adapter and see how that goes.
Some of the metadata from json-api
like pagination would require some changes upstream (generic pagination handling) which I'm more than interested to move forward.
We are doing so prototyping work on this. At a high level JSONAPI provides some standard conventions for paging, filtering, sorting, and object relationships in server interactions.
The JSORM library implements some of these, and you can see where there is some overlap with mobx-rest.
We hope to have some feedback shortly on how this library might be integrated with mobx-rest via an adapter and/or how it works natively with mobx in general.
Paging, sorting and filtering are at the top of the list for implementation at the moment.
whats the current status of this?
We haven't worked in JSON-API compatibility and it's not on our roadmap at the moment.
if I want to work on it, choosing devour could be a good option?
What does devour mean?
https://github.com/twg/devour
I found alternative! https://mobx.reststate.codingitwrong.com/