简体   繁体   English

HATEOAS 后端?

[英]HATEOAS backend?

I would like to use react-admin with my Restful HATEOAS inspired server.我想将react-admin与我受 Restful HATEOAS 启发的服务器一起使用。 Has anyone ever tried that?有人试过吗?

Unfortunately, react-admin wants to work with id's and does not hand objects to the dataprovider.不幸的是, react-admin想要使用 id 而不会将对象交给数据提供者。 Especially in getManyReference it does not supply the referencing resource but only a fieldname (target) and an id.特别是在getManyReference中,它不提供引用资源,而只提供字段名(目标)和 ID。 Is there any way to change that?有什么办法可以改变吗?

I have seen the hal implementation of a data provider and the graphql implementation.我已经看到了数据提供者的 hal 实现和 graphql 实现。 They grep an object's id from the "self" link which is basically perverting the whole idea of HATEOAS.他们 grep 来自“自我”链接的对象 ID,这基本上是在扭曲 HATEOAS 的整个想法。

UPDATE: We now plan to slightly re-define the param target .更新:我们现在计划稍微重新定义参数target It should contain a filter field name which together with param id can be used to filter for referenced resource.它应该包含一个过滤器字段名称,该名称与参数id一起可用于过滤引用的资源。 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.我们在target中给出引用资源的名称,而不是表示字段名称,以便数据提供dataprovider可以获取引用资源的记录,其中包含到子资源的链接。 The resource field passed to getManyReference is then used as name of the link.传递给getManyReferenceresource字段然后用作链接的名称。 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.然后我们从引用记录中提取 URL,append 查询参数,运气好的话,bob 将是我们的叔叔......还没有尝试,只是提到我们正在这里做一些研究。

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.如果id可以是字符串,则应使id成为整个绝对值 URL,因为最终......在 HATEOAS 中,URL任何 object 的全局唯一 id。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM