RE: complex queries

On Friday, October 04, 2013 12:19 PM, Alexey Zakhlestin wrotes:
> Hi.
> 
> My question is not strictly about Hydra, but is closely related, still.
> 
> I have an API which lets do queries for RDF objects. Query is
> implemented as something, which strongly resembles JSON-LD Framing.
> My problem is, that there are a lot of cases, when I can't fit such
> request in the GET's query-parameters.
> https://github.com/gridsby/public/blob/master/API.md#3-post--json-ld
> 
> Right now, I went with the option of sending such queries via POST,
> which makes me incompatible with REST.

That doesn't make your solution "incompatible with REST". It's completely
fine to use POST for such things. You just lose some benefits such as
cacheability by doing so.


> Other option would be using GET-with-body, which is known to be
> discouraged
> http://groups.yahoo.com/neo/groups/rest-discuss/conversations/topics/9962

I wouldn't do that as in practice this isn't widely supported.


> I wonder: can I use Hydra in such case?
> 
> Do I have options to make my API REST-friendly?

I would define an operation like gridsby:QueryOperation and a class
gridsby:Query. Then you define which resources support those
QueryOperations:

  ...
  "supportedOperations": [
    {
      "@type": "gridsby:QueryOperation",
      "title": "Execute a query on the data",
      "method": "POST",
      "expects": "gridsby:Query"
    }

The gridsby:Query class then defines what data you expect in such a POST
request. I don't think I fully understand the example you referenced so I
can't really say how I would model that class and its supportedProperties.

Hope this helps,
Markus


--
Markus Lanthaler
@markuslanthaler

Received on Friday, 4 October 2013 10:53:05 UTC