diff --git a/tests/use_type_description.rs b/tests/use_type_description.rs index 88339787..cb06b6da 100644 --- a/tests/use_type_description.rs +++ b/tests/use_type_description.rs @@ -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, + } + + let schema = Schema::build( + Query { + value: 100, + value2: Utc::now(), + }, + EmptyMutation, + EmptySubscription, + ) + .override_description::("Hehe") + .override_description::>("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" } + }) + ); +}