@@ -14,10 +14,19 @@ Syntax to validate:
1414* Single arg vs. multi arg
1515* Trailing comma vs. no trailing comma
1616* Default value vs. no default value
17+ * Complex default value
1718* Description vs. no description
1819
1920*/
2021
22+ graphql_input_object ! (
23+ #[ derive( Debug ) ]
24+ struct Point {
25+ x: i64 ,
26+ y: i64 ,
27+ }
28+ ) ;
29+
2130graphql_object ! ( Root : ( ) |& self | {
2231 field simple( ) -> i64 { 0 }
2332 field exec_arg( & executor) -> i64 { 0 }
@@ -62,6 +71,11 @@ graphql_object!(Root: () |&self| {
6271 arg1 = 123 : i64 as "The first arg" ,
6372 arg2 = 456 : i64 as "The second arg" ,
6473 ) -> i64 { 0 }
74+
75+ field args_with_complex_default(
76+ arg1 = ( "test" . to_owned( ) ) : String as "A string default argument" ,
77+ arg2 = ( Point { x: 1 , y: 2 } ) : Point as "An input object default argument" ,
78+ ) -> i64 { 0 }
6579} ) ;
6680
6781fn run_args_info_query < F > ( field_name : & str , f : F )
@@ -461,3 +475,30 @@ fn introspect_field_multi_args_with_default_trailing_comma_descr() {
461475 ] . into_iter( ) . collect( ) ) ) ) ;
462476 } ) ;
463477}
478+
479+ #[ test]
480+ fn introspect_field_args_with_complex_default ( ) {
481+ run_args_info_query ( "argsWithComplexDefault" , |args| {
482+ assert_eq ! ( args. len( ) , 2 ) ;
483+
484+ assert ! ( args. contains( & Value :: object( vec![
485+ ( "name" , Value :: string( "arg1" ) ) ,
486+ ( "description" , Value :: string( "A string default argument" ) ) ,
487+ ( "defaultValue" , Value :: string( r#""test""# ) ) ,
488+ ( "type" , Value :: object( vec![
489+ ( "name" , Value :: string( "String" ) ) ,
490+ ( "ofType" , Value :: null( ) ) ,
491+ ] . into_iter( ) . collect( ) ) ) ,
492+ ] . into_iter( ) . collect( ) ) ) ) ;
493+
494+ assert ! ( args. contains( & Value :: object( vec![
495+ ( "name" , Value :: string( "arg2" ) ) ,
496+ ( "description" , Value :: string( "An input object default argument" ) ) ,
497+ ( "defaultValue" , Value :: string( r#"{y: 2, x: 1}"# ) ) ,
498+ ( "type" , Value :: object( vec![
499+ ( "name" , Value :: string( "Point" ) ) ,
500+ ( "ofType" , Value :: null( ) ) ,
501+ ] . into_iter( ) . collect( ) ) ) ,
502+ ] . into_iter( ) . collect( ) ) ) ) ;
503+ } ) ;
504+ }
0 commit comments