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

Should we keep using the "hypermedia interface" or switch to something else? #16

Open
lanthaler opened this issue Sep 17, 2017 · 1 comment

Comments

@lanthaler
Copy link
Member

This was raised in PR #11:

            expect(this.result.hypermedia).toEqual([
                {
                    iri: "http://temp.uri/api/events",
                    isA: [hydra.Collection],
                    totalItems: 1,
                    members: [
                        {
                            iri: "http://temp.uri/api/events/1",
                            isA: [],
                            "http://schema.org/endDate": "2017-04-19",
                            "http://schema.org/eventDescription": "Some event 1",
                            "http://schema.org/eventName": "Event 1",
                            "http://schema.org/startDate": "2017-04-19"
                        }
                    ]
                }, {
                    iri: "http://temp.uri/api/events/1",
                    isA: [],
                    "http://schema.org/endDate": "2017-04-19",
                    "http://schema.org/eventDescription": "Some event 1",
                    "http://schema.org/eventName": "Event 1",
                    "http://schema.org/startDate": "2017-04-19"
                }, {
                    iri: 'some:named.graph',
                    isA: []
                }
            ]);
        });

I made the following comment:

I think this shows the leaky nature of this interface quite clearly. It returns a more or less random set of data. I'd expect to be able to get a list of links to related resources and a list of operations that I then can invoke.

Something like

links = this.result.getLinks();
--> returns an array of Link instances which have the property, the target 
    (and perhaps a few additional properties describing the target)
links[0].getProperty() --> examplevocab:events
links[0].getTarget() --> /api/events
...

This link could then simply be passed to the client this.client.getResource(links[0]) or, perhaps more intuitive, links[0].retrieveTarget(this.client)

@alien-mcl
Copy link
Member

Raw resource would also be a bag of random data.
Having that single hypermedia property is a good place to expand with more specialized accessors. Last #11 introduced hypermedia.members that actually filters this bag to those resources with hydra:member relation, leaving original resource untouched.
You can imagine that this bag could come with links or getLink accessors having all hypermedia in one place.

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

No branches or pull requests

2 participants