[Specifications] Question about HATEOAS shortcuts (#189)

inf3rno has just created a new issue for https://github.com/HydraCG/Specifications:

== Question about HATEOAS shortcuts ==
In some cases we have to save somehow the actual client state, which is bound to specific REST resources. E.g. we selected a product from the catalog and add to the user favourites, or we use an SPA REST client and we want to link it with `https://example.com/our/client/catalog/product/123`. In those cases the client needs to know which links to follow to reach the a certain client state again, e.g. `main -> catalog -> next-page : until-we-reach-product-with-id(123) -> product(123)`.

We have 2 problems here:

1. Using pagination to find the link to the product having the right id takes forever and uses way too many resources, so we need some sort of shortcut: `main -> catalog -> find-product-by-id(123) -> product(123)`.  Normally we would not have that shortcut. Ofc. we can have search, but a typical user does not search by product id, but by criterias like `color:red, size:medium`, etc. So we need extra link(s) in our REST API just to support saving certain client states by collections.
2. The client needs to know about some sort of REST sitemap in order to reach the specific client states in these cases. If we want to build our client on top of a REST browser it would be a good feature to support this with some sort of sitemap format the REST API could provide. So the client would not need to know that it should follow `main -> catalog -> find-product-by-id(123)` to get to the `product(123)` link, because it could get that info from the sitemap. All it needs to know that it needs to find and follow the `product(123)` link to get to the client state it needs to reach. We could even use a REST browser and just pass the operation we want to use and the input and it could discover the API and find the proper link on its own.

I am curious if somebody is working on a recommended solution for REST sitemaps in this topic, or if you have a better idea for these cases.

Please view or discuss this issue at https://github.com/HydraCG/Specifications/issues/189 using your GitHub account

Received on Sunday, 14 April 2019 04:00:22 UTC