-
Notifications
You must be signed in to change notification settings - Fork 26
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
hydra:search with HTTP POST #149
Comments
I think you managed to smoosh many separate issues in here :) First let's start with the {
"@id": "http://api.example.com/issues",
"operation": [
{
"@type": [ "Operation", "schema:SearchAction" ],
"method": "POST",
"???:contentType": "application/sparql-query"
}
]
} The Maybe |
Good catch, I think we would have search directly on the collection {
"@context": { ... },
"@id": "http://api.example.com/issues",
"@type": "hydra:Collection",
"search": {
"@type": "IriTemplate",
"template": "http://api.example.com/issues{?q}",
"variableRepresentation": "BasicRepresentation",
"mapping": [{
"@type": "IriTemplateMapping",
"variable": "q",
"property": "hydra:freetextQuery",
"required": true
}]
},
"operation": [{
"@type": ["Operation", "schema:SearchAction"],
"method": "POST",
"???:contentType": "application/sparql-query"
}, {
"@type": ["Operation", "schema:CreateAction"],
"method": "POST",
"expects": "foo:Issue",
"???:contentType": "application/ld+json"
}]
} Or collection would 'delegate' it to different resource via {
"@context": { ... },
"@id": "http://api.example.com/issues",
"@type": "hydra:Collection",
"search": [{
"@type": "IriTemplate",
"template": "http://api.example.com/issues/search{?q}",
"variableRepresentation": "BasicRepresentation",
"mapping": [{
"@type": "IriTemplateMapping",
"variable": "q",
"property": "hydra:freetextQuery",
"required": true
}]
}, {
"@id": "http://api.example.com/issues/search",
"operation": {
"@type": ["Operation", "schema:SearchAction"],
"method": "POST",
"???:contentType": "application/sparql-query"
}
}],
"operation": {
"@type": ["Operation", "schema:CreateAction"],
"method": "POST",
"expects": "foo:Issue",
"???:contentType": "application/ld+json"
}
} So client needs to check collection for:
I think with just added in #143
I think in this issue we can focus on |
I'm actually inclined to get rid of |
Also for |
Yes, if we would have an answer for issue #3, i.e., a way to associate a resource to an operation whose target is another resource or an IRI template. |
Would it be OK then to assume that As for the |
Perhaps an orthogonal, but still related, issue: Would it be good for Hydra to incubate and ensure the registration of an HTTP |
hydra:Link is a subclass of rdf:Property. If
The client can assume that
Let's discuss support for different media types in a separate issue.
I would prefer to stay focused on Hydra as a group... that doesn't mean someone from the group can do so though. |
I gave it many thoughts and I think this issue should be taken to another level - how to mint operations with IRI template. I think current Heracles.ts implementation already allows this kind of constructs. I've started from an assumption that a link is actually a shortcut of an operation that is using GET by default. </api> hydra:collection </api/users>.
</api> api:users [
hydra:IriTemplate;
hydra:template "/api/users{?search}".
api:users a
rdfs:subPropertyOf hydra:search;
hydra:operation [hydra:method "POST"]. This way we don't need to create any new terms and everything seems OK compared against existing vocabulary and it's constratins. The client could use either a direct collection, GET search results (as the What do you think about it? We could add a paragraph to the spec to clarify how to interprete such constructs. |
Yes, I agree that operations supported by property should be enough. Rather than having a concrete URI as the object of a predicate, we have a template. The client must construct the final URI first and then perform any of the supported operation 🎉 The detail is, like you say, the actual action of minting the identifier. Search is easier, but in the past I may have proposed this method also for creating new resources # ApiDocumentation
api:newUser hydra:supportedOperation
[
hydra:title "Create User" ;
hydra:method "PUT" ;
] .
# Entrypoint
<> api:newUser [
hydra:template "/user/{name}" ;
hydra:mapping
[
hydra:variable "name" ;
hydra:property schema:name ;
] ;
] .
# New user to be created
[] schema:name "John" . Given the resources above, the client would make a request to Besides, I think it only needs one change (unless you mean inline operation) -hydra:operation [hydra:method "POST"]
+hydra:supportedOperation [hydra:method "POST"] |
Actually, I meant |
Hm, I don't think I agree with this train of thought. My understanding is that with
|
Ok. You're right - I think I'll create a PR with additional section regarding templated operations and I'd change that description. |
In various examples of
hydra:search
I always see it using 'a default operation` of the tempate- HTTP GET. Also currently its definition includeshydra:search a hydra:TemplatedLink ; rdfs:range hydra:IriTemplate .
I can think of a cases where service would choose to use HTTP POST to perform search for example with https://www.w3.org/TR/sparql11-protocol/#query-via-post-direct using
application/sparql-query
content type.In that case it seems that we would have
hydra:Resource
accepting the POST, nothydra:IriTemplate
and alsohydra:search
seems an instance ofhydra:Link
nothydra:TemplatedLink
.For collection that provides more then one search mechanism, we might get something like:
In this case, besides the
hydra:search
,hydra:(Templated)Link
we also seem to needschema:SearchAction
to select intended operation on the resource. We can't any more rely on 'a default operation' (HTTP GET) as we did with thehydra:IriTemplate
.@RubenVerborgh do you have any experience with using
hydra:search
via HTTP POST (possibly alsoapplication/sparql-query
)?The text was updated successfully, but these errors were encountered: