@@ -15,6 +15,14 @@ const RESPONSE: &'static str = include_str!("unions/union_query_response.json");
1515) ]
1616pub struct UnionQuery ;
1717
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+
1826#[ test]
1927fn union_query_deserialization ( ) {
2028 let response_data: union_query:: ResponseData = serde_json:: from_str ( RESPONSE ) . unwrap ( ) ;
@@ -41,3 +49,35 @@ fn union_query_deserialization() {
4149
4250 assert_eq ! ( response_data. names. map( |names| names. len( ) ) , Some ( 4 ) ) ;
4351}
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:: FragmentOnUnionNames :: Person (
60+ fragment_on_union:: FragmentOnUnionNamesOnPerson {
61+ first_name: "Audrey" . to_string( ) ,
62+ } ,
63+ ) ,
64+ fragment_on_union:: FragmentOnUnionNames :: Dog (
65+ fragment_on_union:: FragmentOnUnionNamesOnDog {
66+ name: "Laïka" . to_string( ) ,
67+ } ,
68+ ) ,
69+ fragment_on_union:: FragmentOnUnionNames :: Organization (
70+ fragment_on_union:: FragmentOnUnionNamesOnOrganization {
71+ title: "Mozilla" . to_string( ) ,
72+ } ,
73+ ) ,
74+ fragment_on_union:: FragmentOnUnionNames :: Dog (
75+ fragment_on_union:: FragmentOnUnionNamesOnDog {
76+ name: "Norbert" . to_string( ) ,
77+ } ,
78+ ) ,
79+ ] ) ,
80+ } ;
81+
82+ assert_eq ! ( response_data, expected) ;
83+ }
0 commit comments