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

Added support for strongly typed collections #240

Conversation

alien-mcl
Copy link
Member

Summary

This pull request add some changes to the spec that should enable hydra powered APIs to describe strongly typed collections.

More details

There is an issue #233 that should be addressed by this pull request. While the changes are somehow small in numbers, there is another possibly a breaking change as one of the terms has it's domain changed.

Copy link
Contributor

@tpluscode tpluscode left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome, like it overall. Just suggested some editiorial changes

@tpluscode
Copy link
Contributor

tpluscode commented Jun 26, 2021

Something just occurred to me. I think it we should add a paragraph describing that an instance of a strongly type can have its own member assertions. In that scenario all those assertions should be combined, right?

@tpluscode
Copy link
Contributor

Ah, and one more, similar case. We should clarify the behaviour when there are multiple (sub)classes which may have member assertions. I'd say that clients and server should walk up the rdfs:subClassOf hierarchy and combine them all.

To sum up with an example

:ArticleCollection
  rdfs:subClassOf hydra:Collection ;
  hydra:memberAssertion [
    hydra:property rdf:type ;
    hydra:object :Article ;
  ] ;
.

:DraftArticleCollection
  rdfs:subClassOf :ArticleCollection ;
  hydra:memberAssertion [
    hydra:property :status ;
    hydra:object :Draft ;
  ] ;
.

:KarolsDraftsCollection
  rdfs:subClassOf :DraftArticleCollection ;
  hydra:memberAssertion [
    hydra:property acl:owner ;
    hydra:object </person/Karol> ;
  ] ;
.

</person/Karol/drafts> a :KarolsDraftsCollection .

By combining all the member assertions above we could generate a query like below to find all members of the resource </person/Karol/drafts>.

SELECT ?member {
  </person/Karol/drafts> hydra:member ?member .

  # asserted by :ArticleCollection 
  ?member a :Article .

  # asserted by :DraftArticleCollection
  ?member :status :Draft .

  # asserted by :KarolsDraftsCollection
  ?member acl:owner </person/Karol> .
}

@alien-mcl
Copy link
Member Author

I've added both paragraphs, but I think clients should not be overweighed with such a complex tasks as class hierarchy traversing.

@alien-mcl
Copy link
Member Author

@tpluscode could you please review changes you've requested? I've got another bunch of changes made on this branch I'd like to proceed with (brand new diagram and made the terms stable rather than testing)

spec/latest/core/index.html Outdated Show resolved Hide resolved
Comment on lines +1108 to +1111
to gather all of the member assertions. In order to take such a burden from clients
it is strongly recommended to provide all member assertion blocks to be provided
on each class level including it's base class blocks so the client does not have
to perform this traversing behavior.</p>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this makes the much sense. Even if an API duplicates all assertions on all levels of a class hierarchy, the client does not have a way of knowing that. Thus, they will have to traverse the hierarchy nonetheless.

I think I would change this paragraph and require only that a client inspects explicit rdf:type of a collection resource. In the example below the client would only discover the hydra:manages of PersonCollection

# resource
</people> a api:PersonCollection, hydra:Collection .

# api docs
api:PersonCollection
  rdfs:subClassOf api:AgentCollection ;
  hydra:manages [ hydra:property rdf:type ; hydra:object foaf:Person ] ;
.

api:AgentCollection
  rdfs:subClassOf hydra:Collection ;
  hydra:manages [ hydra:property rdf:type ; hydra:object foaf:Agent ] ;
.

Technically, a client could perform RDFS reasoning but in practice I would suggest that the server did that and served all materialised RDF types instead, to relieve the clients from performing additional processing

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm - I see your point. I've softened this required from SHOULD to MAY. Strong recommendation for the server to provide all the details is still in force, but I do not see a way of forcing developers to do so. The client still can do the traversing though.

@alien-mcl alien-mcl merged commit ee3ff0c into HydraCG:master Dec 11, 2022
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 this pull request may close these issues.

3 participants