[web/json] Controller.publish must return encoded data
We were mixing binary from super() and text from our params, thus
wrongly returning text. Closes #5507573.
[hooks] manhandle the parsed rql query, not its string representation
... and add a groupby clause to make it actually work (the selection
might well use an aggregate function, so we need to tell the backend to
group on our target entity).
Closes #5362574