@@ -28,13 +28,14 @@ export default class QueryBuilder {
2828 args ?: Arguments ,
2929 ignoreModels : Array < Model > = [ ] ,
3030 name ?: string ,
31+ filter : boolean = false ,
3132 allowIdFields : boolean = false ) : string {
3233
3334 const context = Context . getInstance ( ) ;
3435 model = context . getModel ( model ) ;
3536 ignoreModels . push ( model ) ;
3637
37- let params : string = this . buildArguments ( model , args , false , multiple , allowIdFields ) ;
38+ let params : string = this . buildArguments ( model , args , false , filter , allowIdFields ) ;
3839
3940 const fields = `
4041 ${ model . getQueryFields ( ) . join ( ' ' ) }
@@ -66,9 +67,11 @@ export default class QueryBuilder {
6667 * @param {string } name Optional name of the query/mutation. Will overwrite the name from the model.
6768 * @param {Arguments } args Arguments for the query
6869 * @param {boolean } multiple Determines if the root query field is a connection or not (will be passed to buildField)
70+ * @param {boolean } filter When true the query arguments are passed via a filter object.
6971 * @returns {any } Whatever gql() returns
7072 */
71- public static buildQuery ( type : string , model : Model | string , name ?: string , args ?: Arguments , multiple ?: boolean ) {
73+ public static buildQuery ( type : string , model : Model | string , name ?: string , args ?: Arguments , multiple ?: boolean ,
74+ filter ?: boolean ) {
7275 const context = Context . getInstance ( ) ;
7376
7477 // model
@@ -94,7 +97,7 @@ export default class QueryBuilder {
9497 // build query
9598 const query : string =
9699 `${ type } ${ upcaseFirstLetter ( name ) } ${ this . buildArguments ( model , args , true , false ) } {\n` +
97- ` ${ this . buildField ( model , multiple , args , [ ] , name , true ) } \n` +
100+ ` ${ this . buildField ( model , multiple , args , [ ] , name , filter , true ) } \n` +
98101 `}` ;
99102
100103 return gql ( query ) ;
@@ -234,7 +237,7 @@ export default class QueryBuilder {
234237 const multiple : boolean = ! ( field instanceof context . components . BelongsTo ||
235238 field instanceof context . components . HasOne ) ;
236239
237- relationQueries . push ( this . buildField ( relatedModel , multiple , undefined , ignoreModels , name ) ) ;
240+ relationQueries . push ( this . buildField ( relatedModel , multiple , undefined , ignoreModels , name , false ) ) ;
238241 }
239242 } ) ;
240243
0 commit comments