Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hydra:collection to resources #63

Closed
tpluscode opened this issue May 3, 2019 · 3 comments · Fixed by #65
Closed

Add hydra:collection to resources #63

tpluscode opened this issue May 3, 2019 · 3 comments · Fixed by #65
Milestone

Comments

@tpluscode
Copy link
Member

As surfaced but HydraCG/api-examples#4, Alcaeus needs to natively support hydra:collection property.

I can think of two ways to add it to the API.

First would be to implicitly treat hydra:collection as a hydra:Link property. I would add a getLinks() method to the base resource type so which gathers explicit links and collections in a single array.

const response = await Hydra.loadResource(url)
const resource = response.root

// will return collections and links defined as `hydra:Link`
resource.getLinks()

I favour this approach as it will play nice with the generic app and is one less place too look at when processing Hydra representations.


Alternatively, a dedicated property/method could be introduced which only accesses the related collections.

I do feel though that it's just bloat.

@tpluscode
Copy link
Member Author

@angelo-v what do you think?

@angelo-v
Copy link

angelo-v commented May 3, 2019

I did not use Alceaus yet, so I am not sure which fits better in the "thinking" of it. In general I think collections are a core element of each API and it does not feel like bloat to me. In contrast, I would like to have more specific ways to find collections in an API, e.g. to say something like getCollections(Movie) to find collections that manage specific types.

@tpluscode
Copy link
Member Author

In general I think collections are a core element of each API and it does not feel like bloat to me

Thanks for sharing your thoughts.

I actually came to this conclusion through different reasoning. If you remember, I mentioned to you and Karol that in a PoC I used collection property to describe supported properties. Thus, it cannot be reduced to links only but has to be its own piece of the library API.

to find collections that manage specific types.

Interesting idea. Such snippets have floated around the spec repository although I'm not sure what is the practical application yet. Also, the manages information can be found in more than one place I think.

@tpluscode tpluscode added this to the 0.6 milestone May 3, 2019
@tpluscode tpluscode mentioned this issue May 12, 2019
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants