Added a small test for field validation error in the async executor
This commit is contained in:
parent
75b597d8f3
commit
03229ddf65
1 changed files with 32 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
||||||
use juniper::{graphql_value, RootNode, Value};
|
use juniper::{graphql_value, RootNode, Value, GraphQLError};
|
||||||
|
|
||||||
#[derive(juniper::GraphQLEnum)]
|
#[derive(juniper::GraphQLEnum)]
|
||||||
enum UserKind {
|
enum UserKind {
|
||||||
|
@ -112,4 +112,35 @@ async fn async_simple() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[tokio::test]
|
||||||
|
async fn async_field_validation_error() {
|
||||||
|
let schema = RootNode::new(Query, Mutation);
|
||||||
|
let doc = r#"
|
||||||
|
query {
|
||||||
|
nonExistentField
|
||||||
|
fieldSync
|
||||||
|
fieldAsyncPlain
|
||||||
|
delayed
|
||||||
|
user(id: "user1") {
|
||||||
|
kind
|
||||||
|
name
|
||||||
|
delayed
|
||||||
|
}
|
||||||
|
}
|
||||||
|
"#;
|
||||||
|
|
||||||
|
let vars = Default::default();
|
||||||
|
let result = juniper::execute_async(doc, None, &schema, &vars, &())
|
||||||
|
.await;
|
||||||
|
assert!(result.is_err());
|
||||||
|
|
||||||
|
let error = result.err().unwrap();
|
||||||
|
let is_validation_error = match error {
|
||||||
|
GraphQLError::ValidationError(_) => true,
|
||||||
|
_ => false
|
||||||
|
};
|
||||||
|
assert!(is_validation_error);
|
||||||
|
}
|
||||||
|
|
||||||
fn main() {}
|
fn main() {}
|
||||||
|
|
Loading…
Add table
Reference in a new issue