@@ -230,6 +230,24 @@ describe('Schema Parser', () => {
230
230
} ) ;
231
231
} ) ;
232
232
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
+
233
251
it ( 'Object extension without fields followed by extension' , ( ) => {
234
252
const doc = parse ( `
235
253
extend type Hello implements Greeting
@@ -323,6 +341,36 @@ describe('Schema Parser', () => {
323
341
} ) ;
324
342
} ) ;
325
343
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
+
326
374
it ( 'Object extension do not include descriptions' , ( ) => {
327
375
expectSyntaxError ( `
328
376
"Description"
@@ -517,6 +565,26 @@ describe('Schema Parser', () => {
517
565
} ) ;
518
566
} ) ;
519
567
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
+
520
588
it ( 'Simple type inheriting multiple interfaces' , ( ) => {
521
589
const doc = parse ( 'type Hello implements Wo & rld { field: String }' ) ;
522
590
@@ -574,6 +642,29 @@ describe('Schema Parser', () => {
574
642
} ) ;
575
643
} ) ;
576
644
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
+
577
668
it ( 'Simple type inheriting multiple interfaces with leading ampersand' , ( ) => {
578
669
const doc = parse ( 'type Hello implements & Wo & rld { field: String }' ) ;
579
670
@@ -633,6 +724,29 @@ describe('Schema Parser', () => {
633
724
} ) ;
634
725
} ) ;
635
726
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
+
636
750
it ( 'Single value enum' , ( ) => {
637
751
const doc = parse ( 'enum Hello { WORLD }' ) ;
638
752
@@ -880,6 +994,7 @@ describe('Schema Parser', () => {
880
994
kind : 'UnionTypeDefinition' ,
881
995
name : nameNode ( 'Hello' , { start : 6 , end : 11 } ) ,
882
996
description : undefined ,
997
+ interfaces : [ ] ,
883
998
directives : [ ] ,
884
999
types : [ typeNode ( 'World' , { start : 14 , end : 19 } ) ] ,
885
1000
loc : { start : 0 , end : 19 } ,
@@ -899,6 +1014,7 @@ describe('Schema Parser', () => {
899
1014
kind : 'UnionTypeDefinition' ,
900
1015
name : nameNode ( 'Hello' , { start : 6 , end : 11 } ) ,
901
1016
description : undefined ,
1017
+ interfaces : [ ] ,
902
1018
directives : [ ] ,
903
1019
types : [
904
1020
typeNode ( 'Wo' , { start : 14 , end : 16 } ) ,
@@ -921,6 +1037,7 @@ describe('Schema Parser', () => {
921
1037
kind : 'UnionTypeDefinition' ,
922
1038
name : nameNode ( 'Hello' , { start : 6 , end : 11 } ) ,
923
1039
description : undefined ,
1040
+ interfaces : [ ] ,
924
1041
directives : [ ] ,
925
1042
types : [
926
1043
typeNode ( 'Wo' , { start : 16 , end : 18 } ) ,
0 commit comments