@@ -230,6 +230,24 @@ describe('Schema Parser', () => {
230230 } ) ;
231231 } ) ;
232232
233+ it ( 'Union extension without types' , ( ) => {
234+ const doc = parse ( 'extend union HelloOrGoodbye implements Greeting' ) ;
235+ expectJSON ( doc ) . toDeepEqual ( {
236+ kind : 'Document' ,
237+ definitions : [
238+ {
239+ kind : 'UnionTypeExtension' ,
240+ name : nameNode ( 'HelloOrGoodbye' , { start : 13 , end : 27 } ) ,
241+ interfaces : [ typeNode ( 'Greeting' , { start : 39 , end : 47 } ) ] ,
242+ directives : [ ] ,
243+ types : [ ] ,
244+ loc : { start : 0 , end : 47 } ,
245+ } ,
246+ ] ,
247+ loc : { start : 0 , end : 47 } ,
248+ } ) ;
249+ } ) ;
250+
233251 it ( 'Object extension without fields followed by extension' , ( ) => {
234252 const doc = parse ( `
235253 extend type Hello implements Greeting
@@ -323,6 +341,36 @@ describe('Schema Parser', () => {
323341 } ) ;
324342 } ) ;
325343
344+ it ( 'Union extension without types followed by extension' , ( ) => {
345+ const doc = parse ( `
346+ extend union HelloOrGoodbye implements Greeting
347+
348+ extend union HelloOrGoodbye implements SecondGreeting
349+ ` ) ;
350+ expectJSON ( doc ) . toDeepEqual ( {
351+ kind : 'Document' ,
352+ definitions : [
353+ {
354+ kind : 'UnionTypeExtension' ,
355+ name : nameNode ( 'HelloOrGoodbye' , { start : 20 , end : 34 } ) ,
356+ interfaces : [ typeNode ( 'Greeting' , { start : 46 , end : 54 } ) ] ,
357+ directives : [ ] ,
358+ types : [ ] ,
359+ loc : { start : 7 , end : 54 } ,
360+ } ,
361+ {
362+ kind : 'UnionTypeExtension' ,
363+ name : nameNode ( 'HelloOrGoodbye' , { start : 75 , end : 89 } ) ,
364+ interfaces : [ typeNode ( 'SecondGreeting' , { start : 101 , end : 115 } ) ] ,
365+ directives : [ ] ,
366+ types : [ ] ,
367+ loc : { start : 62 , end : 115 } ,
368+ } ,
369+ ] ,
370+ loc : { start : 0 , end : 120 } ,
371+ } ) ;
372+ } ) ;
373+
326374 it ( 'Object extension do not include descriptions' , ( ) => {
327375 expectSyntaxError ( `
328376 "Description"
@@ -517,6 +565,26 @@ describe('Schema Parser', () => {
517565 } ) ;
518566 } ) ;
519567
568+ it ( 'Simple union inheriting interface' , ( ) => {
569+ const doc = parse ( 'union Hello implements World = Subtype' ) ;
570+
571+ expectJSON ( doc ) . toDeepEqual ( {
572+ kind : 'Document' ,
573+ definitions : [
574+ {
575+ kind : 'UnionTypeDefinition' ,
576+ name : nameNode ( 'Hello' , { start : 6 , end : 11 } ) ,
577+ description : undefined ,
578+ interfaces : [ typeNode ( 'World' , { start : 23 , end : 28 } ) ] ,
579+ directives : [ ] ,
580+ types : [ typeNode ( 'Subtype' , { start : 31 , end : 38 } ) ] ,
581+ loc : { start : 0 , end : 38 } ,
582+ } ,
583+ ] ,
584+ loc : { start : 0 , end : 38 } ,
585+ } ) ;
586+ } ) ;
587+
520588 it ( 'Simple type inheriting multiple interfaces' , ( ) => {
521589 const doc = parse ( 'type Hello implements Wo & rld { field: String }' ) ;
522590
@@ -574,6 +642,29 @@ describe('Schema Parser', () => {
574642 } ) ;
575643 } ) ;
576644
645+ it ( 'Simple union inheriting multiple interfaces' , ( ) => {
646+ const doc = parse ( 'union Hello implements Wo & rld = Subtype' ) ;
647+
648+ expectJSON ( doc ) . toDeepEqual ( {
649+ kind : 'Document' ,
650+ definitions : [
651+ {
652+ kind : 'UnionTypeDefinition' ,
653+ name : nameNode ( 'Hello' , { start : 6 , end : 11 } ) ,
654+ description : undefined ,
655+ interfaces : [
656+ typeNode ( 'Wo' , { start : 23 , end : 25 } ) ,
657+ typeNode ( 'rld' , { start : 28 , end : 31 } ) ,
658+ ] ,
659+ directives : [ ] ,
660+ types : [ typeNode ( 'Subtype' , { start : 34 , end : 41 } ) ] ,
661+ loc : { start : 0 , end : 41 } ,
662+ } ,
663+ ] ,
664+ loc : { start : 0 , end : 41 } ,
665+ } ) ;
666+ } ) ;
667+
577668 it ( 'Simple type inheriting multiple interfaces with leading ampersand' , ( ) => {
578669 const doc = parse ( 'type Hello implements & Wo & rld { field: String }' ) ;
579670
@@ -633,6 +724,29 @@ describe('Schema Parser', () => {
633724 } ) ;
634725 } ) ;
635726
727+ it ( 'Simple union inheriting multiple interfaces with leading ampersand' , ( ) => {
728+ const doc = parse ( 'union Hello implements & Wo & rld = Subtype' ) ;
729+
730+ expectJSON ( doc ) . toDeepEqual ( {
731+ kind : 'Document' ,
732+ definitions : [
733+ {
734+ kind : 'UnionTypeDefinition' ,
735+ name : nameNode ( 'Hello' , { start : 6 , end : 11 } ) ,
736+ description : undefined ,
737+ interfaces : [
738+ typeNode ( 'Wo' , { start : 25 , end : 27 } ) ,
739+ typeNode ( 'rld' , { start : 30 , end : 33 } ) ,
740+ ] ,
741+ directives : [ ] ,
742+ types : [ typeNode ( 'Subtype' , { start : 36 , end : 43 } ) ] ,
743+ loc : { start : 0 , end : 43 } ,
744+ } ,
745+ ] ,
746+ loc : { start : 0 , end : 43 } ,
747+ } ) ;
748+ } ) ;
749+
636750 it ( 'Single value enum' , ( ) => {
637751 const doc = parse ( 'enum Hello { WORLD }' ) ;
638752
@@ -880,6 +994,7 @@ describe('Schema Parser', () => {
880994 kind : 'UnionTypeDefinition' ,
881995 name : nameNode ( 'Hello' , { start : 6 , end : 11 } ) ,
882996 description : undefined ,
997+ interfaces : [ ] ,
883998 directives : [ ] ,
884999 types : [ typeNode ( 'World' , { start : 14 , end : 19 } ) ] ,
8851000 loc : { start : 0 , end : 19 } ,
@@ -899,6 +1014,7 @@ describe('Schema Parser', () => {
8991014 kind : 'UnionTypeDefinition' ,
9001015 name : nameNode ( 'Hello' , { start : 6 , end : 11 } ) ,
9011016 description : undefined ,
1017+ interfaces : [ ] ,
9021018 directives : [ ] ,
9031019 types : [
9041020 typeNode ( 'Wo' , { start : 14 , end : 16 } ) ,
@@ -921,6 +1037,7 @@ describe('Schema Parser', () => {
9211037 kind : 'UnionTypeDefinition' ,
9221038 name : nameNode ( 'Hello' , { start : 6 , end : 11 } ) ,
9231039 description : undefined ,
1040+ interfaces : [ ] ,
9241041 directives : [ ] ,
9251042 types : [
9261043 typeNode ( 'Wo' , { start : 16 , end : 18 } ) ,
0 commit comments