Skip to content

Commit ac51f09

Browse files
committed
Bugfix argument description handling
1 parent 14ea90b commit ac51f09

File tree

2 files changed

+61
-4
lines changed

2 files changed

+61
-4
lines changed

src/executor_tests/introspection.rs

Lines changed: 57 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ graphql_object!(Root: () as "Root" |&self| {
5454
field sample_scalar(
5555
first: i64 as "The first number",
5656
second = 123: i64 as "The second number"
57-
) -> FieldResult<Scalar> {
57+
) -> FieldResult<Scalar> as "A sample scalar field on the object" {
5858
Ok(Scalar(first + second))
5959
}
6060
});
@@ -251,6 +251,19 @@ fn object_introspection() {
251251
description
252252
args {
253253
name
254+
description
255+
type {
256+
name
257+
kind
258+
ofType {
259+
name
260+
kind
261+
ofType {
262+
name
263+
}
264+
}
265+
}
266+
defaultValue
254267
}
255268
type {
256269
name
@@ -306,6 +319,8 @@ fn object_introspection() {
306319

307320
assert_eq!(fields.len(), 5); // The two fields, __typename, __type, __schema
308321

322+
println!("Fields: {:#?}", fields);
323+
309324
assert!(fields.contains(&Value::object(vec![
310325
("name", Value::string("sampleEnum")),
311326
("description", Value::null()),
@@ -321,6 +336,47 @@ fn object_introspection() {
321336
("isDeprecated", Value::boolean(false)),
322337
("deprecationReason", Value::null()),
323338
].into_iter().collect())));
339+
340+
assert!(fields.contains(&Value::object(vec![
341+
("name", Value::string("sampleScalar")),
342+
("description", Value::string("A sample scalar field on the object")),
343+
("args", Value::list(vec![
344+
Value::object(vec![
345+
("name", Value::string("first")),
346+
("description", Value::string("The first number")),
347+
("type", Value::object(vec![
348+
("name", Value::null()),
349+
("kind", Value::string("NON_NULL")),
350+
("ofType", Value::object(vec![
351+
("name", Value::string("Int")),
352+
("kind", Value::string("SCALAR")),
353+
("ofType", Value::null()),
354+
].into_iter().collect())),
355+
].into_iter().collect())),
356+
("defaultValue", Value::null()),
357+
].into_iter().collect()),
358+
Value::object(vec![
359+
("name", Value::string("second")),
360+
("description", Value::string("The second number")),
361+
("type", Value::object(vec![
362+
("name", Value::string("Int")),
363+
("kind", Value::string("SCALAR")),
364+
("ofType", Value::null()),
365+
].into_iter().collect())),
366+
("defaultValue", Value::string("123")),
367+
].into_iter().collect()),
368+
])),
369+
("type", Value::object(vec![
370+
("name", Value::null()),
371+
("kind", Value::string("NON_NULL")),
372+
("ofType", Value::object(vec![
373+
("name", Value::string("SampleScalar")),
374+
("kind", Value::string("SCALAR")),
375+
].into_iter().collect())),
376+
].into_iter().collect())),
377+
("isDeprecated", Value::boolean(false)),
378+
("deprecationReason", Value::null()),
379+
].into_iter().collect())));
324380
}
325381

326382
#[test]

src/macros/args.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ macro_rules! __graphql__args {
113113
) => {
114114
$base.argument($reg.arg_with_default::<$t>(
115115
&$crate::to_snake_case(stringify!($name)),
116-
&__graphql__args!(@as_expr, $default)))
117-
.description($desc)
116+
&__graphql__args!(@as_expr, $default))
117+
.description($desc))
118118
};
119119

120120
(
@@ -126,7 +126,8 @@ macro_rules! __graphql__args {
126126
$reg,
127127
$base.argument($reg.arg_with_default::<$t>(
128128
&$crate::to_snake_case(stringify!($name)),
129-
&__graphql__args!(@as_expr, $default))),
129+
&__graphql__args!(@as_expr, $default))
130+
.description($desc)),
130131
( $($rest)* ))
131132
};
132133

0 commit comments

Comments
 (0)