@@ -10001,6 +10001,29 @@ var Context = /** @class */ (function () {
1000110001 } ) ;
1000210002 } ) ;
1000310003 } ;
10004+ Context . prototype . processSchema = function ( ) {
10005+ var _this = this ;
10006+ this . models . forEach ( function ( model ) {
10007+ var type ;
10008+ try {
10009+ type = _this . schema . getType ( model . singularName ) ;
10010+ }
10011+ catch ( error ) {
10012+ _this . logger . warn ( "Ignoring entity " + model . singularName + " because it's not in the schema." ) ;
10013+ return ;
10014+ }
10015+ model . fields . forEach ( function ( field , fieldName ) {
10016+ if ( ! type . fields . find ( function ( f ) { return f . name === fieldName ; } ) ) {
10017+ _this . logger . warn ( "Ignoring field " + model . singularName + "." + fieldName + " because it's not in the schema." ) ;
10018+ // TODO: Move skipFields to the model
10019+ model . baseModel . skipFields = model . baseModel . skipFields ? model . baseModel . skipFields : [ ] ;
10020+ if ( ! model . baseModel . skipFields . includes ( fieldName ) ) {
10021+ model . baseModel . skipFields . push ( fieldName ) ;
10022+ }
10023+ }
10024+ } ) ;
10025+ } ) ;
10026+ } ;
1000410027 /**
1000510028 * Returns a model from the model collection by it's name
1000610029 *
@@ -10030,29 +10053,6 @@ var Context = /** @class */ (function () {
1003010053 Model . augment ( model ) ;
1003110054 } ) ;
1003210055 } ;
10033- Context . prototype . processSchema = function ( ) {
10034- var _this = this ;
10035- this . models . forEach ( function ( model ) {
10036- var type ;
10037- try {
10038- type = _this . schema . getType ( model . singularName ) ;
10039- }
10040- catch ( error ) {
10041- _this . logger . warn ( "Ignoring entity " + model . singularName + " because it's not in the schema." ) ;
10042- return ;
10043- }
10044- model . fields . forEach ( function ( field , fieldName ) {
10045- if ( ! type . fields . find ( function ( f ) { return f . name === fieldName ; } ) ) {
10046- _this . logger . warn ( "Ignoring field " + model . singularName + "." + fieldName + " because it's not in the schema." ) ;
10047- // TODO: Move skipFields to the model
10048- model . baseModel . skipFields = model . baseModel . skipFields ? model . baseModel . skipFields : [ ] ;
10049- if ( ! model . baseModel . skipFields . includes ( fieldName ) ) {
10050- model . baseModel . skipFields . push ( fieldName ) ;
10051- }
10052- }
10053- } ) ;
10054- } ) ;
10055- } ;
1005610056 return Context ;
1005710057} ( ) ) ;
1005810058
@@ -10211,26 +10211,32 @@ var QueryBuilder = /** @class */ (function () {
1021110211 * @returns {string }
1021210212 */
1021310213 QueryBuilder . determineAttributeType = function ( model , key , value ) {
10214- var field = model . fields . get ( key ) ;
1021510214 var context = Context . getInstance ( ) ;
10216- if ( field && field instanceof context . components . String ) {
10217- return 'String' ;
10218- }
10219- else if ( field && field instanceof context . components . Number ) {
10220- return 'Int' ;
10221- }
10222- else if ( field && field instanceof context . components . Boolean ) {
10223- return 'Boolean' ;
10215+ var field = model . fields . get ( key ) ;
10216+ var schemaField = context . schema . getType ( model . singularName ) . fields . find ( function ( f ) { return f . name === key ; } ) ;
10217+ if ( schemaField ) {
10218+ return schemaField . type . name ;
1022410219 }
1022510220 else {
10226- if ( typeof value === 'number' )
10227- return 'Int' ;
10228- if ( typeof value === 'string' )
10221+ if ( field instanceof context . components . String ) {
1022910222 return 'String' ;
10230- if ( typeof value === 'boolean' )
10223+ }
10224+ else if ( field && field instanceof context . components . Number ) {
10225+ return 'Int' ;
10226+ }
10227+ else if ( field && field instanceof context . components . Boolean ) {
1023110228 return 'Boolean' ;
10229+ }
10230+ else {
10231+ if ( typeof value === 'number' )
10232+ return 'Int' ;
10233+ if ( typeof value === 'string' )
10234+ return 'String' ;
10235+ if ( typeof value === 'boolean' )
10236+ return 'Boolean' ;
10237+ throw new Error ( "Can't find suitable graphql type for field '" + model . singularName + "." + key + "'." ) ;
10238+ }
1023210239 }
10233- throw new Error ( "Can't find suitable graphql type for variable " + key + " for model " + model . singularName ) ;
1023410240 } ;
1023510241 /**
1023610242 * Generates the fields for all related models.
0 commit comments