@@ -15,6 +15,14 @@ const RESPONSE: &'static str = include_str!("unions/union_query_response.json");
15
15
) ]
16
16
pub struct UnionQuery ;
17
17
18
+ #[ derive( GraphQLQuery ) ]
19
+ #[ graphql(
20
+ query_path = "tests/unions/union_query.graphql" ,
21
+ schema_path = "tests/unions/union_schema.graphql" ,
22
+ response_derives = "PartialEq, Debug"
23
+ ) ]
24
+ pub struct FragmentOnUnion ;
25
+
18
26
#[ test]
19
27
fn union_query_deserialization ( ) {
20
28
let response_data: union_query:: ResponseData = serde_json:: from_str ( RESPONSE ) . unwrap ( ) ;
@@ -41,3 +49,28 @@ fn union_query_deserialization() {
41
49
42
50
assert_eq ! ( response_data. names. map( |names| names. len( ) ) , Some ( 4 ) ) ;
43
51
}
52
+
53
+ #[ test]
54
+ fn fragment_on_union ( ) {
55
+ let response_data: fragment_on_union:: ResponseData = serde_json:: from_str ( RESPONSE ) . unwrap ( ) ;
56
+
57
+ let expected = fragment_on_union:: ResponseData {
58
+ names : Some ( vec ! [
59
+ fragment_on_union:: MyQueryNames :: Person ( fragment_on_union:: MyQueryNamesOnPerson {
60
+ first_name: "Audrey" . to_string( ) ,
61
+ last_name: Some ( "Lorde" . to_string( ) ) ,
62
+ } ) ,
63
+ fragment_on_union:: MyQueryNames :: Dog ( fragment_on_union:: MyQueryNamesOnDog {
64
+ name: "Laïka" . to_string( ) ,
65
+ } ) ,
66
+ fragment_on_union:: MyQueryNames :: Organization ( fragment_on_union:: MyQueryNamesOnOrganization {
67
+ title: "Mozilla" . to_string( ) ,
68
+ } ) ,
69
+ fragment_on_union:: MyQueryNames :: Dog ( fragment_on_union:: MyQueryNamesOnDog {
70
+ name: "Norbert" . to_string( ) ,
71
+ } ) ,
72
+ ] ) ,
73
+ } ;
74
+
75
+ assert_eq ! ( response_data, expected) ;
76
+ }
0 commit comments