@@ -341,6 +341,12 @@ describe('Type System: A Schema must have Object root types', () => {
341
341
input SomeInputObject {
342
342
test: String
343
343
}
344
+ input SomeInputObject2 {
345
+ test: String
346
+ }
347
+ input SomeInputObject3 {
348
+ test: String
349
+ }
344
350
` ) ;
345
351
346
352
schema = extendSchema (
@@ -356,7 +362,7 @@ describe('Type System: A Schema must have Object root types', () => {
356
362
schema ,
357
363
parse ( `
358
364
extend schema {
359
- mutation: SomeInputObject
365
+ mutation: SomeInputObject2
360
366
}
361
367
` ) ,
362
368
) ;
@@ -365,7 +371,7 @@ describe('Type System: A Schema must have Object root types', () => {
365
371
schema ,
366
372
parse ( `
367
373
extend schema {
368
- subscription: SomeInputObject
374
+ subscription: SomeInputObject3
369
375
}
370
376
` ) ,
371
377
) ;
@@ -378,12 +384,12 @@ describe('Type System: A Schema must have Object root types', () => {
378
384
} ,
379
385
{
380
386
message :
381
- 'Mutation root type must be Object type if provided, it cannot be SomeInputObject .' ,
387
+ 'Mutation root type must be Object type if provided, it cannot be SomeInputObject2 .' ,
382
388
locations : [ { line : 3 , column : 21 } ] ,
383
389
} ,
384
390
{
385
391
message :
386
- 'Subscription root type must be Object type if provided, it cannot be SomeInputObject .' ,
392
+ 'Subscription root type must be Object type if provided, it cannot be SomeInputObject3 .' ,
387
393
locations : [ { line : 3 , column : 25 } ] ,
388
394
} ,
389
395
] ) ;
@@ -427,6 +433,73 @@ describe('Type System: A Schema must have Object root types', () => {
427
433
} ) ;
428
434
} ) ;
429
435
436
+ describe ( 'Type System: Root types must all be different if provided' , ( ) => {
437
+ it ( 'rejects a Schema where the same type is used for the "query" and "mutation" root types' , ( ) => {
438
+ const schema = buildSchema ( `
439
+ type SomeObject {
440
+ f: SomeObject
441
+ }
442
+
443
+ schema {
444
+ query: SomeObject
445
+ mutation: SomeObject
446
+ }
447
+ ` ) ;
448
+ expectJSON ( validateSchema ( schema ) ) . toDeepEqual ( [
449
+ {
450
+ message :
451
+ 'All root types must be different, SomeObject is already used for "query" and cannot also be used for "mutation".' ,
452
+ locations : [ { line : 8 , column : 19 } ] ,
453
+ } ,
454
+ ] ) ;
455
+ } ) ;
456
+
457
+ it ( 'rejects a Schema where the same type is used for the "query" and "subscription" root types' , ( ) => {
458
+ const schema = buildSchema ( `
459
+ type SomeObject {
460
+ f: SomeObject
461
+ }
462
+
463
+ schema {
464
+ query: SomeObject
465
+ subscription: SomeObject
466
+ }
467
+ ` ) ;
468
+ expectJSON ( validateSchema ( schema ) ) . toDeepEqual ( [
469
+ {
470
+ message :
471
+ 'All root types must be different, SomeObject is already used for "query" and cannot also be used for "subscription".' ,
472
+ locations : [ { line : 8 , column : 23 } ] ,
473
+ } ,
474
+ ] ) ;
475
+ } ) ;
476
+
477
+ it ( 'rejects a Schema where the same type is used for the "mutation" and "subscription" root types' , ( ) => {
478
+ const schema = buildSchema ( `
479
+ type SomeObject {
480
+ f: SomeObject
481
+ }
482
+
483
+ type Query {
484
+ f: SomeObject
485
+ }
486
+
487
+ schema {
488
+ query: Query
489
+ mutation: SomeObject
490
+ subscription: SomeObject
491
+ }
492
+ ` ) ;
493
+ expectJSON ( validateSchema ( schema ) ) . toDeepEqual ( [
494
+ {
495
+ message :
496
+ 'All root types must be different, SomeObject is already used for "mutation" and cannot also be used for "subscription".' ,
497
+ locations : [ { line : 13 , column : 23 } ] ,
498
+ } ,
499
+ ] ) ;
500
+ } ) ;
501
+ } ) ;
502
+
430
503
describe ( 'Type System: Objects must have fields' , ( ) => {
431
504
it ( 'accepts an Object type with fields object' , ( ) => {
432
505
const schema = buildSchema ( `
0 commit comments