We are trying to use the JsonServiceClient to manually construct autoquery requests. The code is pretty simple for most operations but I don't see how filters are applied:
var client = new JsonServiceClient('https://my-app.azurewebsites.net');
var req = new dto.something();
req.pageSize = 10;
req.skip = 0;
req.take = 10;
What I don't see is how to send filters?
Here is the implementation of QueryBase:
export class QueryBase {
// @DataMember(Order=1)
skip: number;
// @DataMember(Order=2)
take: number;
// @DataMember(Order=3)
orderBy: string;
// @DataMember(Order=4)
orderByDesc: string;
// @DataMember(Order=5)
include: string;
// @DataMember(Order=6)
fields: string;
// @DataMember(Order=7)
meta: { [index: string]: string; };
}
Lastly, is there an analog to ToPostUrl/ToGetUrl for the javascript/typescript client?
New support for querying Services was added in 0.0.23 of the TypeScript JsonServiceClient which will let you add additional args when querying Services, e.g:
var request = new dto.MyQuery();
client.get(request, {MyField:"TheFilter"})
.then(r => {});
It will also let call services by relative or absolute url with optional queryString arguments, e.g:
client.get<Response>("/my-request/foo")
client.get<Response>("http://example.org/my-request/foo")
client.get<Response>("/my-request", { arg: "foo"})
ServiceStack can only generate Typed properties for Explicit Conditions on your AutoQuery Request DTO.
There's no ToPostUrl/ToGetUrl equivalent in JavaScript/TypeScript but there are some URL helpers in ss-utils which can help create URLs, e.g:
var url = $.ss.createUrl("https://my-app.azurewebsites.net/myquery",
{pageSize:10,take:10,MyField:"TheFilter"});
$.getJSON(url, function(r) {
console.log(r.Results);
});
Similar URL Helpers are also available in the servicestack-client
npm package, e.g:
import { combinePaths, nameof, appendQueryString } from 'servicestack-client';
let baseUrl = "https://my-app.azurewebsites.net";
let requestDto = new MyQuery();
requestDto.take = 10;
let pathInfo = combinePaths(baseUrl, "json", "reply", nameof(requestDto));
let url = appendQueryString(pathInfo, requestDto);