Re: Filters as views (ISSUE-45)

January 14 2016 10:11 PM, "Pierre-Antoine Champin" <pierre-antoine.champin@liris.cnrs.fr> wrote: 
> 
> Could you precisely define what is a "member"?
> 
> Because I can see two ways of defining them, which I think are exclusive...
> 
> - a member of a collection is a resource linked to it by the hydra:member property
> - a member of a collection is a resource whose representation is included in the collection's
> representation
> 

I think this is very important question that hasn't been answered really. Why do you think the above cases are exclusive?

Consider an application, which presents a table of, say, movies. The server could return just the links for the client to GET

{
"@id": "/movies",
"member": [ "/movie/matrix", "/movie/pulp_fiction", ... ]
}

But the save server could also include (partial) representation of the movies so that 1. the client doesn't have to GET them all immediately, thus avoiding an N+1 problem and 2. the movies' representations can have minimal data and metadata for the client to produce a UI (eg. <table>) and act upon them (by adding some operations)

{
"@id": "/movies",
"member": [ 
{ "@id": "/movie/matrix", "@type": "Movie", "title": "The Matrix" }, 
{ "@id": "/movie/pulp_fiction", "@type": "Movie", "title": "Pulp Fiction"}
]
}

The client can still GET full representations by following the movies' @ids. Thus both way link data together. And I don't think they exclusive, because you could mix both. In fact the first snippet can be rewritten as 

{
"@id": "/movies",
"member": [ 
{ "@id": "/movie/matrix" }, 
{ "@id": "/movie/pulp_fiction" }
]
}

See how it's the second one, but with members' @ids only. After getting a member, you could simply replace it's representation within the member array. This is why I think there is no real difference between a "link-only" member and a "representation-included" member.

Received on Friday, 15 January 2016 08:00:16 UTC