diff --git a/CHANGELOG.md b/CHANGELOG.md index a7294070..bbbe9a64 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ - `c-select-many-to-many` is now based on `c-select` rather than `v-autocomplete`. As a result, it has gained support for all of the props and slots of `c-select`. - Added strong types for pass-through Vuetify slots and props to `c-input`, `c-select`, `c-select-many-to-many`, and `c-datetime-picker`. - Added a `color` prop to `c-datetime-picker`. +- Added experimental client-side support for System.Text.Json's PreserveReferences reference handling option in server responses. This does not require changes to your JSON settings in Program.cs - instead, it is activated by setting `refResponse` on the `DataSourceParameters` for a request (i.e. the `$params` object on a ViewModel or ListViewModel). This option can significantly reduce response sizes in cases where the same object occurs many times in a response. # 5.2.1 diff --git a/src/coalesce-vue/src/api-client.ts b/src/coalesce-vue/src/api-client.ts index cdb4ae7e..c8440f8a 100644 --- a/src/coalesce-vue/src/api-client.ts +++ b/src/coalesce-vue/src/api-client.ts @@ -91,13 +91,13 @@ export interface DataSourceParameters { * which can significantly reduce the size of the response payload. This will also cause the resulting * `Model` and `ViewModel` instances on the client to be deduplicated. */ - useRef?: boolean; + refResponse?: boolean; } export class DataSourceParameters { constructor() { this.includes = null; this.dataSource = null; - this.useRef = false; + this.refResponse = false; } } @@ -761,10 +761,10 @@ export class ApiClient { } let headers = config?.headers; - if (standardParameters?.useRef) { + if (standardParameters?.refResponse) { headers = { ...config?.headers, - Accept: standardParameters?.useRef + Accept: standardParameters?.refResponse ? ["application/json+ref", "application/json"] : ["application/json"], }; @@ -775,8 +775,8 @@ export class ApiClient { data: body, responseType: method.return.type == "file" ? "blob" : "json", cancelToken: this._cancelToken, - headers, ...config, + headers, params: { ...query, ...(config && config.params ? config.params : null),