Hi Lionel, and welcome to the forum!
A bit late reply, but hopefully not too late
You are correct in your assumption; call requests can only respond with static JSON data, or a reference to a single resource. But you have a few options how to solve this:
Get request
You can still go with a get
request. This is the way to go if you want the resulting collection to be updated live; meaning, that the client can have the resulting collection be up-to-date, even when the underlaying data changes.
And regarding complex queries; you don’t have to use the “standard” query format. You are free to use any format, such as URI encoded JSON. Eg:
client.get("users?" + encodeURI(JSON.stringify({limit:10, roles:["admin","guest"], offset:100})))
.then(result => console.log(result));
Call request returning resource reference to search result
This options let’s you use send params in the call request, but the result is fetched in a separate get request. So, in this case, you will actually have 2 handlers:
call.users.search
get.users.search.{$searchid}
The call.users.search
request would take the provided (json) params, maybe validate them, and store them in a database table (maybe including some user ID of who made the call), and then return a reference to the search result resource:
Resource response to the call request:
{"resource":"users.search.ID_OF_THE_STORED_QUERY_PARAMS"}
This will make Resgate follow that resource reference and fetch the collection from the get.users.search.{$searchid}
handler. So it is the get
handler that uses the search params and performs the query against the database, and returns the collection that you showed above.
The client will only see this as a single call, even if Resgate makes 3 calls in total:
client.call("users", "search", {limit:10, roles: ["admin", "guest"], offset:100})
.then(result => console.log(result));
Call request with static result
Or, you can just send a big JSON blob of data as the result to the call request. But then you lose all the beauty of simply referencing resources.
This is not really what I would recommend.
Hope that helps!
/Samuel