Skip to content

Commit 2f79f33

Browse files
committed
Document input object default values
1 parent 0b07dbe commit 2f79f33

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/macros/input_object.rs

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ is what will be generated:
99
1010
```rust
1111
# #[macro_use] extern crate juniper;
12-
12+
#
1313
graphql_input_object!(
1414
description: "Coordinates for the user"
1515
@@ -29,6 +29,21 @@ and arguments.
2929
If you want to expose the struct under a different name than the Rust
3030
type, you can write `struct Coordinates as "MyCoordinates" { ...`.
3131
32+
You can specify *default values* for input object fields; the syntax
33+
is similar to argument default values:
34+
35+
```rust
36+
# #[macro_use] extern crate juniper;
37+
#
38+
graphql_input_object!(
39+
struct SampleObject {
40+
foo = 123: i64 as "A sample field, defaults to 123 if omitted"
41+
}
42+
);
43+
44+
# fn main() { }
45+
```
46+
3247
*/
3348
#[macro_export]
3449
macro_rules! graphql_input_object {

0 commit comments

Comments
 (0)