Add test for SchemaBuilder::override_description
. #327
This commit is contained in:
parent
3052e13c8a
commit
8d2c8f9bcc
|
@ -1,5 +1,6 @@
|
|||
use async_graphql::*;
|
||||
use async_std::stream::Stream;
|
||||
use chrono::{DateTime, Utc};
|
||||
|
||||
#[async_std::test]
|
||||
pub async fn test_object() {
|
||||
|
@ -98,3 +99,45 @@ pub async fn test_subscription() {
|
|||
})
|
||||
);
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
pub async fn test_override_description() {
|
||||
/// Haha
|
||||
#[derive(SimpleObject)]
|
||||
struct Query {
|
||||
value: i32,
|
||||
value2: DateTime<Utc>,
|
||||
}
|
||||
|
||||
let schema = Schema::build(
|
||||
Query {
|
||||
value: 100,
|
||||
value2: Utc::now(),
|
||||
},
|
||||
EmptyMutation,
|
||||
EmptySubscription,
|
||||
)
|
||||
.override_description::<Query>("Hehe")
|
||||
.override_description::<DateTime<Utc>>("DT")
|
||||
.finish();
|
||||
|
||||
assert_eq!(
|
||||
schema
|
||||
.execute(r#"{ __type(name: "Query") { description } }"#)
|
||||
.await
|
||||
.data,
|
||||
value!({
|
||||
"__type": { "description": "Hehe" }
|
||||
})
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
schema
|
||||
.execute(r#"{ __type(name: "DateTime") { description } }"#)
|
||||
.await
|
||||
.data,
|
||||
value!({
|
||||
"__type": { "description": "DT" }
|
||||
})
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user