@@ -9318,9 +9318,11 @@ var QueryBuilder = /** @class */ (function () {
93189318 args = args ? JSON . parse ( JSON . stringify ( args ) ) : { } ;
93199319 if ( ! args )
93209320 throw new Error ( 'args is undefined' ) ;
9321- if ( args [ model . singularName ] && typeof args [ model . singularName ] === 'object' ) {
9322- args [ model . singularName ] = { __type : upcaseFirstLetter ( model . singularName ) } ;
9323- }
9321+ Object . keys ( args ) . forEach ( function ( key ) {
9322+ if ( args && args [ key ] && typeof args [ key ] === 'object' ) {
9323+ args [ key ] = { __type : upcaseFirstLetter ( key ) } ;
9324+ }
9325+ } ) ;
93249326 // multiple
93259327 multiple = multiple === undefined ? ! args [ 'id' ] : multiple ;
93269328 // name
@@ -9351,14 +9353,17 @@ var QueryBuilder = /** @class */ (function () {
93519353 if ( ( ! relations . has ( key ) || relations . get ( key ) instanceof _this . context . components . BelongsTo ) &&
93529354 ! key . startsWith ( '$' ) && value !== null ) {
93539355 if ( value instanceof Array ) {
9356+ // Iterate over all fields and transform them if value is an array
93549357 var arrayModel_1 = _this . getModel ( inflection . singularize ( key ) ) ;
93559358 returnValue [ key ] = value . map ( function ( v ) { return _this . transformOutgoingData ( arrayModel_1 || model , v ) ; } ) ;
93569359 }
9357- else if ( relations . get ( key ) instanceof _this . context . components . BelongsTo ) {
9360+ else if ( typeof value === 'object' && _this . context . getModel ( inflection . singularize ( key ) , true ) ) {
9361+ // Value is a record, transform that too
93589362 var relatedModel = _this . getModel ( inflection . singularize ( key ) ) ;
93599363 returnValue [ key ] = _this . transformOutgoingData ( relatedModel || model , value ) ;
93609364 }
93619365 else {
9366+ // In any other case just let the value be what ever it is
93629367 returnValue [ key ] = value ;
93639368 }
93649369 }
@@ -9939,16 +9944,16 @@ var VuexORMApollo = /** @class */ (function () {
99399944 VuexORMApollo . prototype . fetch = function ( _a , params ) {
99409945 var state = _a . state , dispatch = _a . dispatch ;
99419946 return __awaiter ( this , void 0 , void 0 , function ( ) {
9942- var filter , bypassCache , multiple , model , name , query , data ;
9947+ var model , filter , bypassCache , multiple , name , query , data ;
99439948 return __generator ( this , function ( _b ) {
99449949 switch ( _b . label ) {
99459950 case 0 :
9946- filter = params ? params . filter || { } : { } ;
9951+ model = this . context . getModel ( state . $name ) ;
9952+ filter = params && params . filter ? this . queryBuilder . transformOutgoingData ( model , params . filter ) : { } ;
99479953 bypassCache = params && params . bypassCache ;
99489954 multiple = ! filter [ 'id' ] ;
9949- model = this . context . getModel ( state . $name ) ;
99509955 name = "" + ( multiple ? model . pluralName : model . singularName ) ;
9951- query = this . queryBuilder . buildQuery ( 'query' , model , name , filter ) ;
9956+ query = this . queryBuilder . buildQuery ( 'query' , model , name , filter , multiple ) ;
99529957 return [ 4 /*yield*/ , this . apolloRequest ( model , query , filter , false , bypassCache ) ] ;
99539958 case 1 :
99549959 data = _b . sent ( ) ;
0 commit comments