@@ -14,10 +14,19 @@ Syntax to validate:
14
14
* Single arg vs. multi arg
15
15
* Trailing comma vs. no trailing comma
16
16
* Default value vs. no default value
17
+ * Complex default value
17
18
* Description vs. no description
18
19
19
20
*/
20
21
22
+ graphql_input_object ! (
23
+ #[ derive( Debug ) ]
24
+ struct Point {
25
+ x: i64 ,
26
+ y: i64 ,
27
+ }
28
+ ) ;
29
+
21
30
graphql_object ! ( Root : ( ) |& self | {
22
31
field simple( ) -> i64 { 0 }
23
32
field exec_arg( & executor) -> i64 { 0 }
@@ -62,6 +71,11 @@ graphql_object!(Root: () |&self| {
62
71
arg1 = 123 : i64 as "The first arg" ,
63
72
arg2 = 456 : i64 as "The second arg" ,
64
73
) -> 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 }
65
79
} ) ;
66
80
67
81
fn run_args_info_query < F > ( field_name : & str , f : F )
@@ -461,3 +475,30 @@ fn introspect_field_multi_args_with_default_trailing_comma_descr() {
461
475
] . into_iter( ) . collect( ) ) ) ) ;
462
476
} ) ;
463
477
}
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