@@ -562,23 +562,33 @@ describe('Type System: Union types must be valid', () => {
562562 } ) ;
563563
564564 it ( 'rejects a Union type with empty types' , ( ) => {
565- const schema = buildSchema ( `
565+ let schema = buildSchema ( `
566566 type Query {
567567 test: BadUnion
568568 }
569569
570570 union BadUnion
571571 ` ) ;
572+
573+ schema = extendSchema (
574+ schema ,
575+ parse ( `
576+ directive @test on UNION
577+
578+ extend union BadUnion @test
579+ ` ) ,
580+ ) ;
581+
572582 expect ( validateSchema ( schema ) ) . to . deep . equal ( [
573583 {
574584 message : 'Union type BadUnion must define one or more member types.' ,
575- locations : [ { line : 6 , column : 7 } ] ,
585+ locations : [ { line : 6 , column : 7 } , { line : 4 , column : 9 } ] ,
576586 } ,
577587 ] ) ;
578588 } ) ;
579589
580590 it ( 'rejects a Union type with duplicated member type' , ( ) => {
581- const schema = buildSchema ( `
591+ let schema = buildSchema ( `
582592 type Query {
583593 test: BadUnion
584594 }
@@ -596,16 +606,30 @@ describe('Type System: Union types must be valid', () => {
596606 | TypeB
597607 | TypeA
598608 ` ) ;
609+
599610 expect ( validateSchema ( schema ) ) . to . deep . equal ( [
600611 {
601612 message : 'Union type BadUnion can only include type TypeA once.' ,
602613 locations : [ { line : 15 , column : 11 } , { line : 17 , column : 11 } ] ,
603614 } ,
604615 ] ) ;
616+
617+ schema = extendSchema ( schema , parse ( 'extend union BadUnion = TypeB' ) ) ;
618+
619+ expect ( validateSchema ( schema ) ) . to . deep . equal ( [
620+ {
621+ message : 'Union type BadUnion can only include type TypeA once.' ,
622+ locations : [ { line : 15 , column : 11 } , { line : 17 , column : 11 } ] ,
623+ } ,
624+ {
625+ message : 'Union type BadUnion can only include type TypeB once.' ,
626+ locations : [ { line : 16 , column : 11 } , { line : 1 , column : 25 } ] ,
627+ } ,
628+ ] ) ;
605629 } ) ;
606630
607631 it ( 'rejects a Union type with non-Object members types' , ( ) => {
608- const schema = buildSchema ( `
632+ let schema = buildSchema ( `
609633 type Query {
610634 test: BadUnion
611635 }
@@ -623,13 +647,20 @@ describe('Type System: Union types must be valid', () => {
623647 | String
624648 | TypeB
625649 ` ) ;
650+
651+ schema = extendSchema ( schema , parse ( 'extend union BadUnion = Int' ) ) ;
652+
626653 expect ( validateSchema ( schema ) ) . to . deep . equal ( [
627654 {
628655 message :
629- 'Union type BadUnion can only include Object types, ' +
630- 'it cannot include String.' ,
656+ 'Union type BadUnion can only include Object types, it cannot include String.' ,
631657 locations : [ { line : 16 , column : 11 } ] ,
632658 } ,
659+ {
660+ message :
661+ 'Union type BadUnion can only include Object types, it cannot include Int.' ,
662+ locations : [ { line : 1 , column : 25 } ] ,
663+ } ,
633664 ] ) ;
634665
635666 const badUnionMemberTypes = [
@@ -671,18 +702,28 @@ describe('Type System: Input Objects must have fields', () => {
671702 } ) ;
672703
673704 it ( 'rejects an Input Object type with missing fields' , ( ) => {
674- const schema = buildSchema ( `
705+ let schema = buildSchema ( `
675706 type Query {
676707 field(arg: SomeInputObject): String
677708 }
678709
679710 input SomeInputObject
680711 ` ) ;
712+
713+ schema = extendSchema (
714+ schema ,
715+ parse ( `
716+ directive @test on ENUM
717+
718+ extend input SomeInputObject @test
719+ ` ) ,
720+ ) ;
721+
681722 expect ( validateSchema ( schema ) ) . to . deep . equal ( [
682723 {
683724 message :
684725 'Input Object type SomeInputObject must define one or more fields.' ,
685- locations : [ { line : 6 , column : 7 } ] ,
726+ locations : [ { line : 6 , column : 7 } , { line : 4 , column : 9 } ] ,
686727 } ,
687728 ] ) ;
688729 } ) ;
@@ -722,17 +763,27 @@ describe('Type System: Input Objects must have fields', () => {
722763
723764describe ( 'Type System: Enum types must be well defined' , ( ) => {
724765 it ( 'rejects an Enum type without values' , ( ) => {
725- const schema = buildSchema ( `
766+ let schema = buildSchema ( `
726767 type Query {
727768 field: SomeEnum
728769 }
729770
730771 enum SomeEnum
731772 ` ) ;
773+
774+ schema = extendSchema (
775+ schema ,
776+ parse ( `
777+ directive @test on ENUM
778+
779+ extend enum SomeEnum @test
780+ ` ) ,
781+ ) ;
782+
732783 expect ( validateSchema ( schema ) ) . to . deep . equal ( [
733784 {
734785 message : 'Enum type SomeEnum must define one or more values.' ,
735- locations : [ { line : 6 , column : 7 } ] ,
786+ locations : [ { line : 6 , column : 7 } , { line : 4 , column : 9 } ] ,
736787 } ,
737788 ] ) ;
738789 } ) ;
@@ -1000,13 +1051,21 @@ describe('Type System: Interface extensions should be valid', () => {
10001051 extend interface AnotherInterface {
10011052 newField: String
10021053 }
1054+
1055+ extend type AnotherObject {
1056+ differentNewField: String
1057+ }
10031058 ` ) ,
10041059 ) ;
10051060 expect ( validateSchema ( extendedSchema ) ) . to . deep . equal ( [
10061061 {
10071062 message :
10081063 'Interface field AnotherInterface.newField expected but AnotherObject does not provide it.' ,
1009- locations : [ { line : 3 , column : 11 } , { line : 10 , column : 7 } ] ,
1064+ locations : [
1065+ { line : 3 , column : 11 } ,
1066+ { line : 10 , column : 7 } ,
1067+ { line : 6 , column : 9 } ,
1068+ ] ,
10101069 } ,
10111070 ] ) ;
10121071 } ) ;
0 commit comments