@@ -597,7 +597,10 @@ mod test {
597597 #[ cfg( feature = "schema-language" ) ]
598598 mod schema_language {
599599 use crate as juniper;
600- use crate :: { EmptyMutation , EmptySubscription , GraphQLEnum , GraphQLObject , GraphQLInputObject } ;
600+ use crate :: {
601+ EmptyMutation , EmptySubscription , GraphQLEnum , GraphQLInputObject , GraphQLObject ,
602+ GraphQLUnion ,
603+ } ;
601604
602605 #[ test]
603606 fn schema_language ( ) {
@@ -620,6 +623,11 @@ mod test {
620623 & IceCream => match * self { Sweet :: IceCream ( ref x) => Some ( x) , _ => None } ,
621624 }
622625 } ) ;
626+ #[ derive( GraphQLUnion ) ]
627+ enum GlutenFree {
628+ Cake ( Cake ) ,
629+ IceCream ( IceCream ) ,
630+ }
623631 #[ derive( GraphQLEnum ) ]
624632 enum Fruit {
625633 Apple ,
@@ -653,6 +661,13 @@ mod test {
653661 fn fruit ( ) -> Fruit {
654662 Fruit :: Apple
655663 }
664+ fn gluten_free ( flavor : String ) -> GlutenFree {
665+ if flavor == "savory" {
666+ GlutenFree :: Cake ( Cake :: default ( ) )
667+ } else {
668+ GlutenFree :: IceCream ( IceCream :: default ( ) )
669+ }
670+ }
656671 #[ deprecated]
657672 fn old ( ) -> i32 {
658673 42
@@ -670,6 +685,7 @@ mod test {
670685 ) ;
671686 let ast = graphql_parser:: parse_schema :: < & str > (
672687 r#"
688+ union GlutenFree = Cake | IceCream
673689 enum Fruit {
674690 APPLE
675691 ORANGE
@@ -690,6 +706,7 @@ mod test {
690706 fizz(buzz: String!): Sweet
691707 arr(stuff: [Coordinate!]!): String
692708 fruit: Fruit!
709+ glutenFree(flavor: String!): GlutenFree!
693710 old: Int! @deprecated
694711 reallyOld: Float! @deprecated(reason: "This field is deprecated, use another.")
695712 }
0 commit comments