Add test for `SchemaBuilder::override_description`.
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" }
+ })
+ );
+}
