@@ -7898,6 +7898,7 @@ var QueryBuilder = /** @class */ (function () {
78987898 * @returns {String }
78997899 */
79007900 QueryBuilder . prototype . buildArguments = function ( model , args , signature , filter , allowIdFields ) {
7901+ var _this = this ;
79017902 if ( signature === void 0 ) { signature = false ; }
79027903 if ( filter === void 0 ) { filter = false ; }
79037904 if ( allowIdFields === void 0 ) { allowIdFields = true ; }
@@ -7924,12 +7925,7 @@ var QueryBuilder = /** @class */ (function () {
79247925 }
79257926 else {
79267927 // Case 1 (String!)
7927- if ( typeof value === 'number' )
7928- typeOrValue = 'Int' ;
7929- if ( typeof value === 'string' )
7930- typeOrValue = 'String' ;
7931- if ( typeof value === 'boolean' )
7932- typeOrValue = 'Boolean' ;
7928+ typeOrValue = _this . determineAttributeType ( model , key , value ) ;
79337929 typeOrValue = typeOrValue + '!' ;
79347930 }
79357931 }
@@ -7949,6 +7945,35 @@ var QueryBuilder = /** @class */ (function () {
79497945 }
79507946 return returnValue ;
79517947 } ;
7948+ /**
7949+ * Determines the GraphQL primitive type of a field in the variables hash by the field type or (when
7950+ * the field type is generic attribute) by the variable type.
7951+ * @param {Model } model
7952+ * @param {string } key
7953+ * @param {string } value
7954+ * @returns {string }
7955+ */
7956+ QueryBuilder . prototype . determineAttributeType = function ( model , key , value ) {
7957+ var field = model . fields . get ( key ) ;
7958+ if ( field && field instanceof this . context . components . String ) {
7959+ return 'String' ;
7960+ }
7961+ else if ( field && field instanceof this . context . components . Number ) {
7962+ return 'Int' ;
7963+ }
7964+ else if ( field && field instanceof this . context . components . Boolean ) {
7965+ return 'Boolean' ;
7966+ }
7967+ else {
7968+ if ( typeof value === 'number' )
7969+ return 'Int' ;
7970+ if ( typeof value === 'string' )
7971+ return 'String' ;
7972+ if ( typeof value === 'boolean' )
7973+ return 'Boolean' ;
7974+ }
7975+ throw new Error ( "Can't find suitable graphql type for variable " + key + " for model " + model . singularName ) ;
7976+ } ;
79527977 /**
79537978 *
79547979 * @param {Model } model
@@ -8140,8 +8165,11 @@ var Model = /** @class */ (function () {
81408165 return relations ;
81418166 } ;
81428167 Model . prototype . fieldIsAttribute = function ( field ) {
8143- return field instanceof this . context . components . Attr ||
8144- field instanceof this . context . components . Increment ;
8168+ return field instanceof this . context . components . Increment ||
8169+ field instanceof this . context . components . Attr ||
8170+ field instanceof this . context . components . String ||
8171+ field instanceof this . context . components . Number ||
8172+ field instanceof this . context . components . Boolean ;
81458173 } ;
81468174 return Model ;
81478175} ( ) ) ;
0 commit comments