Fix for default_with

Signed-off-by: Lee Benson <lee@leebenson.com>
This commit is contained in:
Lee Benson 2021-01-19 09:53:29 +00:00
parent 418d1fe8ad
commit d3373fd7e8
2 changed files with 9 additions and 9 deletions

View File

@ -18,7 +18,7 @@ fn my_default() -> i32 {
impl Query {
// The default value of the value parameter is 0, it will call i32::default()
fn test1(&self, #[graphql(default)] value: i32) {}
// The default value of the value parameter is 10
fn test2(&self, #[graphql(default = 10)] value: i32) {}
@ -36,7 +36,7 @@ use async_graphql::*;
#[graphql(
field(name = "test1", arg(name = "value", default)),
field(name = "test2", arg(name = "value", default = 10)),
field(name = "test3", arg(name = "value", default = "my_default()")),
field(name = "test3", arg(name = "value", default_with = "my_default()")),
)]
enum MyInterface {
MyObj(MyObj),
@ -52,11 +52,11 @@ use async_graphql::*;
struct MyInputObject {
#[graphql(default)]
value1: i32,
#[graphql(default = 10)]
value2: i32,
#[graphql(default = "my_default()")]
#[graphql(default_with = "my_default()")]
value3: i32,
}
```

View File

@ -17,7 +17,7 @@ fn my_default() -> i32 {
impl Query {
// value参数的默认值为0它会调用i32::default()
fn test1(&self, #[graphql(default)] value: i32) {}
// value参数的默认值为10
fn test2(&self, #[graphql(default = 10)] value: i32) {}
@ -35,7 +35,7 @@ use async_graphql::*;
#[graphql(
field(name = "test1", arg(name = "value", default)),
field(name = "test2", arg(name = "value", default = 10)),
field(name = "test3", arg(name = "value", default = "my_default()")),
field(name = "test3", arg(name = "value", default_with = "my_default()")),
)]
enum MyInterface {
MyObj(MyObj),
@ -51,11 +51,11 @@ use async_graphql::*;
struct MyInputObject {
#[graphql(default)]
value1: i32,
#[graphql(default = 10)]
value2: i32,
#[graphql(default = "my_default()")]
#[graphql(default_with = "my_default()")]
value3: i32,
}
```
```