async-graphql/tests/mut_args.rs
2020-08-17 21:48:53 +08:00

28 lines
586 B
Rust

use async_graphql::*;
#[async_std::test]
pub async fn test_mut_args() {
struct Query;
#[Object]
impl Query {
async fn test(&self, mut a: i32, mut b: String) -> String {
a += 1;
b += "a";
format!("{}{}", a, b)
}
}
let schema = Schema::build(Query, EmptyMutation, EmptySubscription).finish();
assert_eq!(
schema
.execute("{ test(a: 10, b: \"abc\") }")
.await
.unwrap()
.data,
serde_json::json!({
"test": "11abca"
})
);
}