File tree Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Expand file tree Collapse file tree 2 files changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -357,6 +357,19 @@ describe('Type System: Schema', () => {
357
357
) ;
358
358
} ) ;
359
359
360
+ it ( 'rejects a Schema when a provided type has no name' , ( ) => {
361
+ const query = new GraphQLObjectType ( {
362
+ name : 'Query' ,
363
+ fields : { foo : { type : GraphQLString } } ,
364
+ } ) ;
365
+ const types = [ { } , query , { } ] ;
366
+
367
+ // $DisableFlowOnNegativeTest
368
+ expect ( ( ) => new GraphQLSchema ( { query, types } ) ) . to . throw (
369
+ 'One of the provided types for building the Schema is missing a name.' ,
370
+ ) ;
371
+ } ) ;
372
+
360
373
it ( 'rejects a Schema which defines an object type twice' , ( ) => {
361
374
const types = [
362
375
new GraphQLObjectType ( { name : 'SameName' , fields : { } } ) ,
Original file line number Diff line number Diff line change @@ -213,6 +213,10 @@ export class GraphQLSchema {
213
213
}
214
214
215
215
const typeName = namedType . name ;
216
+ devAssert (
217
+ typeName ,
218
+ 'One of the provided types for building the Schema is missing a name.' ,
219
+ ) ;
216
220
if ( this . _typeMap [ typeName ] !== undefined ) {
217
221
throw new Error (
218
222
`Schema must contain uniquely named types but contains multiple types named "${ typeName } ".` ,
You can’t perform that action at this time.
0 commit comments