@@ -13,6 +13,10 @@ fn skip_serializing_none() {
1313 use skip_serializing_none_mutation:: * ;
1414
1515 let query = SkipSerializingNoneMutation :: build_query ( Variables {
16+ optional_int : None ,
17+ optional_list : None ,
18+ non_optional_int : 1337 ,
19+ non_optional_list : vec ! [ ] ,
1620 param : Some ( Param {
1721 data : Author {
1822 name : "test" . to_owned ( ) ,
@@ -25,5 +29,29 @@ fn skip_serializing_none() {
2529
2630 println ! ( "{}" , stringified) ;
2731
28- assert ! ( stringified. contains( r#""data":{"name":"test"}"# ) ) ;
32+ assert ! ( stringified. contains( r#""param":{"data":{"name":"test"}}"# ) ) ;
33+ assert ! ( stringified. contains( r#""nonOptionalInt":1337"# ) ) ;
34+ assert ! ( stringified. contains( r#""nonOptionalList":[]"# ) ) ;
35+ assert ! ( !stringified. contains( r#""optionalInt""# ) ) ;
36+ assert ! ( !stringified. contains( r#""optionalList""# ) ) ;
37+
38+ let query = SkipSerializingNoneMutation :: build_query ( Variables {
39+ optional_int : Some ( 42 ) ,
40+ optional_list : Some ( vec ! [ ] ) ,
41+ non_optional_int : 1337 ,
42+ non_optional_list : vec ! [ ] ,
43+ param : Some ( Param {
44+ data : Author {
45+ name : "test" . to_owned ( ) ,
46+ id : None ,
47+ } ,
48+ } ) ,
49+ } ) ;
50+ let stringified = serde_json:: to_string ( & query) . expect ( "SkipSerializingNoneMutation is valid" ) ;
51+ println ! ( "{}" , stringified) ;
52+ assert ! ( stringified. contains( r#""param":{"data":{"name":"test"}}"# ) ) ;
53+ assert ! ( stringified. contains( r#""nonOptionalInt":1337"# ) ) ;
54+ assert ! ( stringified. contains( r#""nonOptionalList":[]"# ) ) ;
55+ assert ! ( stringified. contains( r#""optionalInt":42"# ) ) ;
56+ assert ! ( stringified. contains( r#""optionalList":[]"# ) ) ;
2957}
0 commit comments