async-graphql/tests/scalar.rs

42 lines
839 B
Rust
Raw Normal View History

2020-11-03 05:50:22 +00:00
use async_graphql::*;
mod test_mod {
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
pub struct MyValue {
a: i32,
}
}
#[tokio::test]
2020-11-03 05:50:22 +00:00
pub async fn test_scalar_macro() {
scalar!(test_mod::MyValue, "MV", "DESC");
struct Query;
#[Object]
2021-01-11 01:01:28 +00:00
#[allow(unreachable_code)]
2020-11-03 05:50:22 +00:00
impl Query {
async fn value(&self) -> test_mod::MyValue {
todo!()
}
}
let schema = Schema::new(Query, EmptyMutation, EmptySubscription);
assert_eq!(
schema
.execute(r#"{ __type(name:"MV") { name description } }"#)
.await
.into_result()
.unwrap()
.data,
value!({
"__type": {
"name": "MV",
"description": "DESC",
}
})
);
}