File tree Expand file tree Collapse file tree 4 files changed +13
-12
lines changed Expand file tree Collapse file tree 4 files changed +13
-12
lines changed Original file line number Diff line number Diff line change @@ -27810,12 +27810,13 @@ var Schema = /** @class */ (function () {
27810
27810
return 'plain';
27811
27811
}
27812
27812
};
27813
- Schema.prototype.getType = function (name) {
27813
+ Schema.prototype.getType = function (name, allowNull) {
27814
+ if (allowNull === void 0) { allowNull = false; }
27814
27815
name = upcaseFirstLetter(name);
27815
27816
var type = this.types.get(name);
27816
- if (!type)
27817
+ if (!allowNull && ! type)
27817
27818
throw new Error("Couldn't find Type of name " + name + " in the GraphQL Schema.");
27818
- return type;
27819
+ return type || null ;
27819
27820
};
27820
27821
Schema.prototype.getMutation = function (name, allowNull) {
27821
27822
if (allowNull === void 0) { allowNull = false; }
@@ -28179,7 +28180,7 @@ var QueryBuilder = /** @class */ (function () {
28179
28180
var skipFieldDueId = (key === 'id' || isForeignKey) && !allowIdFields;
28180
28181
var schema = Context.getInstance().schema;
28181
28182
var type = schema.getType(model.singularName + (filter ? 'Filter' : ''));
28182
- var schemaField = (filter ? type.inputFields : type.fields).find(function (f) { return f.name === key; });
28183
+ var schemaField = type ? (filter ? type.inputFields : type.fields).find(function (f) { return f.name === key; }) : null ;
28183
28184
var isConnectionField = schemaField && Schema.getTypeNameOfField(schemaField).endsWith('TypeConnection');
28184
28185
// Ignore null fields, ids and connections
28185
28186
if (value && !skipFieldDueId && !isConnectionField) {
Original file line number Diff line number Diff line change @@ -237,7 +237,7 @@ export default class Context {
237
237
let type : GraphQLType ;
238
238
239
239
try {
240
- type = this . schema ! . getType ( model . singularName ) ;
240
+ type = this . schema ! . getType ( model . singularName ) ! ;
241
241
} catch ( error ) {
242
242
this . logger . warn ( `Ignoring entity ${ model . singularName } because it's not in the schema.` ) ;
243
243
return ;
Original file line number Diff line number Diff line change @@ -174,7 +174,7 @@ export default class QueryBuilder {
174
174
175
175
const schema = Context . getInstance ( ) . schema ! ;
176
176
const type = schema . getType ( model . singularName + ( filter ? 'Filter' : '' ) ) ;
177
- const schemaField = ( filter ? type . inputFields ! : type . fields ! ) . find ( f => f . name === key ) ;
177
+ const schemaField = type ? ( filter ? type . inputFields ! : type . fields ! ) . find ( f => f . name === key ) : null ;
178
178
const isConnectionField = schemaField && Schema . getTypeNameOfField ( schemaField ) . endsWith ( 'TypeConnection' ) ;
179
179
180
180
// Ignore null fields, ids and connections
@@ -232,7 +232,7 @@ export default class QueryBuilder {
232
232
const context : Context = Context . getInstance ( ) ;
233
233
const field : undefined | Field = model . fields . get ( key ) ;
234
234
235
- const schemaField = context . schema ! . getType ( model . singularName ) . fields ! . find ( f => f . name === key ) ;
235
+ const schemaField = context . schema ! . getType ( model . singularName ) ! . fields ! . find ( f => f . name === key ) ;
236
236
237
237
if ( schemaField && Schema . getTypeNameOfField ( schemaField ) ) {
238
238
return Schema . getTypeNameOfField ( schemaField ) ;
Original file line number Diff line number Diff line change @@ -15,8 +15,8 @@ export default class Schema {
15
15
16
16
this . schema . types . forEach ( ( t : GraphQLType ) => this . types . set ( t . name , t ) ) ;
17
17
18
- this . getType ( 'Query' ) . fields ! . forEach ( f => this . queries . set ( f . name , f ) ) ;
19
- this . getType ( 'Mutation' ) . fields ! . forEach ( f => this . mutations . set ( f . name , f ) ) ;
18
+ this . getType ( 'Query' ) ! . fields ! . forEach ( f => this . queries . set ( f . name , f ) ) ;
19
+ this . getType ( 'Mutation' ) ! . fields ! . forEach ( f => this . mutations . set ( f . name , f ) ) ;
20
20
}
21
21
22
22
public determineQueryMode ( ) : string {
@@ -44,13 +44,13 @@ export default class Schema {
44
44
}
45
45
}
46
46
47
- public getType ( name : string ) : GraphQLType {
47
+ public getType ( name : string , allowNull : boolean = false ) : GraphQLType | null {
48
48
name = upcaseFirstLetter ( name ) ;
49
49
const type = this . types . get ( name ) ;
50
50
51
- if ( ! type ) throw new Error ( `Couldn't find Type of name ${ name } in the GraphQL Schema.` ) ;
51
+ if ( ! allowNull && ! type ) throw new Error ( `Couldn't find Type of name ${ name } in the GraphQL Schema.` ) ;
52
52
53
- return type ;
53
+ return type || null ;
54
54
}
55
55
56
56
public getMutation ( name : string , allowNull : boolean = false ) : GraphQLField | null {
You can’t perform that action at this time.
0 commit comments