@@ -282,6 +282,11 @@ describe('Schema Parser', () => {
282
282
locations : [ { line : 1 , column : 19 } ] ,
283
283
} ) ;
284
284
285
+ expectSyntaxError ( 'extend intersection Hello' ) . to . deep . equal ( {
286
+ message : 'Syntax Error: Unexpected <EOF>.' ,
287
+ locations : [ { line : 1 , column : 26 } ] ,
288
+ } ) ;
289
+
285
290
expectSyntaxError ( 'extend enum Hello' ) . to . deep . equal ( {
286
291
message : 'Syntax Error: Unexpected <EOF>.' ,
287
292
locations : [ { line : 1 , column : 18 } ] ,
@@ -961,6 +966,97 @@ describe('Schema Parser', () => {
961
966
} ) ;
962
967
} ) ;
963
968
969
+ it ( 'Simple union' , ( ) => {
970
+ const doc = parse ( 'intersection Hello = World' ) ;
971
+
972
+ expectJSON ( doc ) . toDeepEqual ( {
973
+ kind : 'Document' ,
974
+ definitions : [
975
+ {
976
+ kind : 'IntersectionTypeDefinition' ,
977
+ name : nameNode ( 'Hello' , { start : 13 , end : 18 } ) ,
978
+ description : undefined ,
979
+ directives : [ ] ,
980
+ types : [ typeNode ( 'World' , { start : 21 , end : 26 } ) ] ,
981
+ loc : { start : 0 , end : 26 } ,
982
+ } ,
983
+ ] ,
984
+ loc : { start : 0 , end : 26 } ,
985
+ } ) ;
986
+ } ) ;
987
+
988
+ it ( 'Intersection with two types' , ( ) => {
989
+ const doc = parse ( 'intersection Hello = Wo & Rld' ) ;
990
+
991
+ expectJSON ( doc ) . toDeepEqual ( {
992
+ kind : 'Document' ,
993
+ definitions : [
994
+ {
995
+ kind : 'IntersectionTypeDefinition' ,
996
+ name : nameNode ( 'Hello' , { start : 13 , end : 18 } ) ,
997
+ description : undefined ,
998
+ directives : [ ] ,
999
+ types : [
1000
+ typeNode ( 'Wo' , { start : 21 , end : 23 } ) ,
1001
+ typeNode ( 'Rld' , { start : 26 , end : 29 } ) ,
1002
+ ] ,
1003
+ loc : { start : 0 , end : 29 } ,
1004
+ } ,
1005
+ ] ,
1006
+ loc : { start : 0 , end : 29 } ,
1007
+ } ) ;
1008
+ } ) ;
1009
+
1010
+ it ( 'Intersection with two types and leading ampersand' , ( ) => {
1011
+ const doc = parse ( 'intersection Hello = & Wo & Rld' ) ;
1012
+
1013
+ expectJSON ( doc ) . toDeepEqual ( {
1014
+ kind : 'Document' ,
1015
+ definitions : [
1016
+ {
1017
+ kind : 'IntersectionTypeDefinition' ,
1018
+ name : nameNode ( 'Hello' , { start : 13 , end : 18 } ) ,
1019
+ description : undefined ,
1020
+ directives : [ ] ,
1021
+ types : [
1022
+ typeNode ( 'Wo' , { start : 23 , end : 25 } ) ,
1023
+ typeNode ( 'Rld' , { start : 28 , end : 31 } ) ,
1024
+ ] ,
1025
+ loc : { start : 0 , end : 31 } ,
1026
+ } ,
1027
+ ] ,
1028
+ loc : { start : 0 , end : 31 } ,
1029
+ } ) ;
1030
+ } ) ;
1031
+
1032
+ it ( 'Intersection fails with no types' , ( ) => {
1033
+ expectSyntaxError ( 'intersection Hello = &' ) . to . deep . equal ( {
1034
+ message : 'Syntax Error: Expected Name, found <EOF>.' ,
1035
+ locations : [ { line : 1 , column : 23 } ] ,
1036
+ } ) ;
1037
+ } ) ;
1038
+
1039
+ it ( 'Intersection fails with leading double ampersand' , ( ) => {
1040
+ expectSyntaxError ( 'intersection Hello = && Wo & Rld' ) . to . deep . equal ( {
1041
+ message : 'Syntax Error: Expected Name, found "&".' ,
1042
+ locations : [ { line : 1 , column : 23 } ] ,
1043
+ } ) ;
1044
+ } ) ;
1045
+
1046
+ it ( 'Intersection fails with double ampersand' , ( ) => {
1047
+ expectSyntaxError ( 'intersection Hello = Wo && Rld' ) . to . deep . equal ( {
1048
+ message : 'Syntax Error: Expected Name, found "&".' ,
1049
+ locations : [ { line : 1 , column : 26 } ] ,
1050
+ } ) ;
1051
+ } ) ;
1052
+
1053
+ it ( 'Intersection fails with trailing ampersand' , ( ) => {
1054
+ expectSyntaxError ( 'intersection Hello = & Wo & Rld &' ) . to . deep . equal ( {
1055
+ message : 'Syntax Error: Expected Name, found <EOF>.' ,
1056
+ locations : [ { line : 1 , column : 34 } ] ,
1057
+ } ) ;
1058
+ } ) ;
1059
+
964
1060
it ( 'Scalar' , ( ) => {
965
1061
const doc = parse ( 'scalar Hello' ) ;
966
1062
0 commit comments