resgateio/resgate

Allow query on non-query get request

Closed this issue · 1 comments

Issue

The RES protocol currently doesn't allow responding with a query resource on a non-query get request. In the RES Service Protocol - Get request, it states in the Result section:

query
MUST be omitted if the request had no query parameter.

This restriction should be removed as it may cause unnecessary complexity for service development of query resource that uses default values for omitted query parameters.

Use case

Assume we have a collection of a million items, but the service wish to only expose the collection as a query resource where a from and limit parameter may be provided to specify the span.

To simplify the request, omitting any of the two parameters will have the service fall back to the default values (eg. from=0&limit=50).

If both parameters were omitted, the query would be empty, and due to the restriction it would no longer accept a normalized query in the response. This would currently force the developers to either:

  1. Add specific non-query handling on the service for the default params usecase.
  2. Add a dummy property to the query (eg. ignore=this) on the request

This scenario would be solved if the restriction was lifted.

Example request

Request body for get.example.list:

{ }

Response:

{
    "result": {
        "collection": [{ "rid": "example.item.1" }, ... , { "rid": "example.item.50" }],
        "query": "from=0&limit=50"
    }
}

Compatibility

Removing the restriction would:

  • be backwards compatible (running older services on a newer versions of Resgate)
  • have no impact on client

Resolved in PR #117