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

How should indirections through collections be handled/interpreted #33

Open
lanthaler opened this issue Feb 4, 2014 · 0 comments
Open

Comments

@lanthaler
Copy link
Member

_This was raised by Gregg Kellogg:_

Excuse me for some random thoughts, but I've been reconciling using Hydra for an API which typically returns JSON-LD representations of entities described using schema.org. Similar issues may exist with the schema.org action vocabulary as well. As a simple example, I may want to express follows information for a Person. In Turtle, this might look like the following:

<http://example/people/gregg> a schema:Person;
  schema:name "Gregg Kellogg"@en;
  schema:follows <http://example/people/markus>, <http://example/people/kingsley> ...

However, given that the list of potentially people I follow could be large; using Hydra I may construct this using a separate relationship to a Collection:

<http://example/people/gregg> a schema:Person, :ApiPerson;
  :follows <http://example/people/gregg/follows> .

:ApiPerson a hydra:Class;
  hydra:supportedProperties [hydra:property schema:name], [hydra:property :follows] .

:follows a hydra:Link
    rdfs:label "follows";
    rdfs:comment "Collection of followed people";
    rdfs:domain schema:Person;
    rdfs:range schema:Person;
    hydra:supportedOperations [
      hydra:method "GET";
      hydra:returns hydra:Collection
  ] .

If the referenced collection contained the following data:

<http://example/people/gregg/follows> a hydra:Collection;
  hydra:members ( <http://example/people/markus> <http://example/kingsley> .

After loading both the original document and the collection into a graph, I would now have the following:

<http://example/people/gregg> a schema:Person, :ApiPerson;
  :follows <http://example/people/gregg/follows> .
<http://example/people/gregg/follows> a hydra:Collection;
  hydra:members (<http://example/people/markus> <http://example/kingsley> .

This now does not describe what I would want using the schema.org definitions. One way to reconstruct what I want would be to add more data to the collection document:

<http://example/people/gregg/follows> a hydra:Collection;
  hydra:members (<http://example/people/markus> <http://example/kingsley> .
<http://example/people/gregg> schema:follows <http://example/people/markus>,
            <http://example/people/kingsley> .

This is actually easier to do in JSON-LD:

{
  "@context": {
    "hydra": "http://www.w3.org/ns/hydra/core#",
    "schema": "http://schema.org/",
    "follower": {"@reverse": "schema:follows"}
  }
  "@id": "http://example/people/gregg/follows",
  "@type": "hydra:Collection",
  "members": [
    { "@id": "http://example/people/markus", "follower": "http://example/people/gregg"},
    { "@id": "http://example/people/kingsley", "follower": "http://example/people/gregg"}
  ]
}

The issue is better for single-valued properties, as the property value would be the same as the entity identifier, which would result in what you would expect when merging both entity definitions.

I guess the question is, is this an expected usage pattern? Should the collection examples represent this, or should it be described as a recommended practice? Perhaps I've missed something.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant