@@ -323,6 +323,52 @@ describe('Type System: A Schema must have Object root types', () => {
323
323
] ) ;
324
324
} ) ;
325
325
326
+ it ( 'rejects a schema extended with invalid root types' , ( ) => {
327
+ let schema = buildSchema ( `
328
+ input SomeInputObject {
329
+ test: String
330
+ }
331
+ ` ) ;
332
+
333
+ schema = extendSchema ( schema , parse ( `
334
+ extend schema {
335
+ query: SomeInputObject
336
+ }
337
+ ` ) ) ;
338
+
339
+ schema = extendSchema ( schema , parse ( `
340
+ extend schema {
341
+ mutation: SomeInputObject
342
+ }
343
+ ` ) ) ;
344
+
345
+ schema = extendSchema ( schema , parse ( `
346
+ extend schema {
347
+ subscription: SomeInputObject
348
+ }
349
+ ` ) ) ;
350
+
351
+ const errorMsg = ( operation ) =>
352
+ `${ operation } root type must be Object type, it cannot be SomeInputObject.` ;
353
+ expect ( validateSchema ( schema ) ) . to . deep . equal ( [
354
+ {
355
+ message :
356
+ 'Query root type must be Object type, it cannot be SomeInputObject.' ,
357
+ locations : [ { line : 3 , column : 16 } ] ,
358
+ } ,
359
+ {
360
+ message :
361
+ 'Mutation root type must be Object type if provided, it cannot be SomeInputObject.' ,
362
+ locations : [ { line : 3 , column : 19 } ] ,
363
+ } ,
364
+ {
365
+ message :
366
+ 'Subscription root type must be Object type if provided, it cannot be SomeInputObject.' ,
367
+ locations : [ { line : 3 , column : 23 } ] ,
368
+ } ,
369
+ ] ) ;
370
+ } ) ;
371
+
326
372
it ( 'rejects a Schema whose directives are incorrectly typed' , ( ) => {
327
373
const schema = new GraphQLSchema ( {
328
374
query : SomeObjectType ,
0 commit comments