Fix the problem that the `ComplexObject` macro cannot work due to the `secret` attribute.

This commit is contained in:
Sunli 2021-04-23 10:25:00 +08:00
parent 6618013977
commit bdeeff328a
4 changed files with 16 additions and 2 deletions

View File

@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [2.8.4] 2021-04-23
- Fix the problem that the `ComplexObject` macro cannot work due to the `secret` attribute.
## [2.8.3] 2021-04-12
- Fixed an error in exporting Federation SDL.

View File

@ -149,6 +149,7 @@ pub fn generate(
default_with,
validator,
visible,
secret,
..
},
) in &args
@ -191,6 +192,7 @@ pub fn generate(
default_value: #schema_default,
validator: #validator,
visible: #visible,
is_secret: #secret,
});
});

View File

@ -501,6 +501,7 @@ pub use async_graphql_derive::SimpleObject;
/// | guard | Field of guard | [`Guard`](guard/trait.Guard.html) | Y |
/// | visible | If `false`, it will not be displayed in introspection. *[See also the Book](https://async-graphql.github.io/async-graphql/en/visibility.html).* | bool | Y |
/// | visible | Call the specified function. If the return value is `false`, it will not be displayed in introspection. | string | Y |
/// | secret | Mark this field as a secret, it will not output the actual value in the log. | bool | Y |
///
/// # Examples
///

View File

@ -14,13 +14,18 @@ pub async fn test_complex_object() {
async fn c(&self) -> i32 {
self.a + self.b
}
async fn d(&self, v: i32) -> i32 {
self.a + self.b + v
}
}
#[derive(Interface)]
#[graphql(
field(name = "a", type = "&i32"),
field(name = "b", type = "&i32"),
field(name = "c", type = "i32")
field(name = "c", type = "i32"),
field(name = "d", type = "i32", arg(name = "v", type = "i32"))
)]
enum ObjInterface {
MyObj(MyObj),
@ -39,7 +44,7 @@ pub async fn test_complex_object() {
}
}
let query = "{ obj { a b c } obj2 { a b c } }";
let query = "{ obj { a b c d(v:100) } obj2 { a b c d(v:200) } }";
let schema = Schema::new(Query, EmptyMutation, EmptySubscription);
assert_eq!(
schema.execute(query).await.data,
@ -48,11 +53,13 @@ pub async fn test_complex_object() {
"a": 10,
"b": 20,
"c": 30,
"d": 130,
},
"obj2": {
"a": 10,
"b": 20,
"c": 30,
"d": 230,
}
})
);