Blafasel42
Blafasel42

Reputation: 355

HATEOAS backend?

I would like to use react-admin with my Restful HATEOAS inspired server. Has anyone ever tried that?

Unfortunately, react-admin wants to work with id's and does not hand objects to the dataprovider. Especially in getManyReference it does not supply the referencing resource but only a fieldname (target) and an id. Is there any way to change that?

I have seen the hal implementation of a data provider and the graphql implementation. They grep an object's id from the "self" link which is basically perverting the whole idea of HATEOAS.

UPDATE: We now plan to slightly re-define the param target. It should contain a filter field name which together with param idcan be used to filter for referenced resource. Instead of denoting a field-name, we give the name of the referencing resource in target so that the dataprovider can fetch the record of the referencing resource, containing the links to subresources. The resource field passed to getManyReference is then used as name of the link. We then extract the URL from the referencing record, append query parameters, and, with some luck, bob will be our uncle... Didn't try yet, just mentioning that we are doing some research here.

Upvotes: 1

Views: 231

Answers (1)

Evert
Evert

Reputation: 99831

If the id can be the string, you should make the id the entire absolute URL, because ultimately... in HATEOAS the URL is the globally unique id for any object.

Upvotes: 0

Related Questions