@@ -597,7 +597,10 @@ mod test {
597
597
#[ cfg( feature = "schema-language" ) ]
598
598
mod schema_language {
599
599
use crate as juniper;
600
- use crate :: { EmptyMutation , EmptySubscription , GraphQLEnum , GraphQLObject , GraphQLInputObject } ;
600
+ use crate :: {
601
+ EmptyMutation , EmptySubscription , GraphQLEnum , GraphQLInputObject , GraphQLObject ,
602
+ GraphQLUnion ,
603
+ } ;
601
604
602
605
#[ test]
603
606
fn schema_language ( ) {
@@ -620,6 +623,11 @@ mod test {
620
623
& IceCream => match * self { Sweet :: IceCream ( ref x) => Some ( x) , _ => None } ,
621
624
}
622
625
} ) ;
626
+ #[ derive( GraphQLUnion ) ]
627
+ enum GlutenFree {
628
+ Cake ( Cake ) ,
629
+ IceCream ( IceCream ) ,
630
+ }
623
631
#[ derive( GraphQLEnum ) ]
624
632
enum Fruit {
625
633
Apple ,
@@ -653,6 +661,13 @@ mod test {
653
661
fn fruit ( ) -> Fruit {
654
662
Fruit :: Apple
655
663
}
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
+ }
656
671
#[ deprecated]
657
672
fn old ( ) -> i32 {
658
673
42
@@ -670,6 +685,7 @@ mod test {
670
685
) ;
671
686
let ast = graphql_parser:: parse_schema :: < & str > (
672
687
r#"
688
+ union GlutenFree = Cake | IceCream
673
689
enum Fruit {
674
690
APPLE
675
691
ORANGE
@@ -690,6 +706,7 @@ mod test {
690
706
fizz(buzz: String!): Sweet
691
707
arr(stuff: [Coordinate!]!): String
692
708
fruit: Fruit!
709
+ glutenFree(flavor: String!): GlutenFree!
693
710
old: Int! @deprecated
694
711
reallyOld: Float! @deprecated(reason: "This field is deprecated, use another.")
695
712
}
0 commit comments