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

JSON-API Support

Open drush opened this issue 7 years ago • 9 comments

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.

drush avatar Dec 13 '17 01:12 drush

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

andresgutgon avatar Dec 13 '17 08:12 andresgutgon

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.

masylum avatar Dec 13 '17 10:12 masylum

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.

drush avatar Jan 05 '18 22:01 drush

whats the current status of this?

auvipy avatar Nov 01 '19 20:11 auvipy

We haven't worked in JSON-API compatibility and it's not on our roadmap at the moment.

masylum avatar Nov 04 '19 11:11 masylum

if I want to work on it, choosing devour could be a good option?

auvipy avatar Nov 04 '19 14:11 auvipy

What does devour mean?

masylum avatar Nov 05 '19 08:11 masylum

https://github.com/twg/devour

auvipy avatar Nov 06 '19 17:11 auvipy

I found alternative! https://mobx.reststate.codingitwrong.com/

auvipy avatar Nov 09 '19 07:11 auvipy