Remove unnecessary Result on Schema::execute_stream function.

This commit is contained in:
Sunli 2020-09-11 07:58:02 +08:00
parent c88747dfe4
commit 553e6ffd53
24 changed files with 252 additions and 225 deletions

View File

@ -20,7 +20,7 @@ default = ["bson", "url", "chrono-tz"]
async-graphql-derive = { path = "derive", version = "1.18.0" }
async-graphql-parser = { path = "parser", version = "1.18.0" }
async-stream = "0.2.1"
async-stream = "0.3"
async-trait = "0.1.30"
bytes = "0.5.4"
chrono = "0.4.10"

View File

@ -98,11 +98,6 @@
#![recursion_limit = "256"]
#![forbid(unsafe_code)]
// Do not try to modify the location of this line of code, it must be
// the first mod defined, otherwise there will be a danger of failing to compile.
#[macro_use]
mod macros;
mod base;
mod context;
mod error;
@ -280,7 +275,7 @@ pub use types::{EnumItem, EnumType};
/// valueWithError
/// valueWithArg1: valueWithArg
/// valueWithArg2: valueWithArg(a: 99)
/// }"#).await.unwrap().data;
/// }"#).await.into_result().unwrap().data;
/// assert_eq!(res, serde_json::json!({
/// "value": 10,
/// "valueRef": 10,
@ -335,7 +330,7 @@ pub use async_graphql_derive::Object;
///
/// async_std::task::block_on(async move {
/// let schema = Schema::new(QueryRoot{ value: 10 }, EmptyMutation, EmptySubscription);
/// let res = schema.execute("{ value }").await.unwrap().data;
/// let res = schema.execute("{ value }").await.into_result().unwrap().data;
/// assert_eq!(res, serde_json::json!({
/// "value": 10,
/// }));
@ -453,7 +448,7 @@ pub use async_graphql_derive::GQLSimpleObject;
///
/// async_std::task::block_on(async move {
/// let schema = Schema::new(QueryRoot{ value1: MyEnum::A, value2: MyEnum::B }, EmptyMutation, EmptySubscription);
/// let res = schema.execute("{ value1 value2 }").await.unwrap().data;
/// let res = schema.execute("{ value1 value2 }").await.into_result().unwrap().data;
/// assert_eq!(res, serde_json::json!({ "value1": "A", "value2": "b" }));
/// });
/// ```
@ -461,6 +456,7 @@ pub use async_graphql_derive::Enum;
/// Define a GraphQL input object
///
///
/// You can also [derive this](derive.GQLInputObject.html).
///
/// *[See also the Book](https://async-graphql.github.io/async-graphql/en/define_input_object.html).*
@ -512,7 +508,7 @@ pub use async_graphql_derive::Enum;
/// {
/// value1: value(input:{a:9, b:3})
/// value2: value(input:{a:9})
/// }"#).await.unwrap().data;
/// }"#).await.into_result().unwrap().data;
/// assert_eq!(res, serde_json::json!({ "value1": 27, "value2": 90 }));
/// });
/// ```
@ -634,7 +630,7 @@ pub use async_graphql_derive::InputObject;
/// valueC(a: 3, b: 2)
/// value_d
/// }
/// }"#).await.unwrap().data;
/// }"#).await.into_result().unwrap().data;
/// assert_eq!(res, serde_json::json!({
/// "typeA": {
/// "valueA": "hello",
@ -711,7 +707,7 @@ pub use async_graphql_derive::GQLInterface;
/// valueB
/// }
/// }
/// }"#).await.unwrap().data;
/// }"#).await.into_result().unwrap().data;
/// assert_eq!(res, serde_json::json!({
/// "allData": [
/// { "valueA": 10 },

View File

@ -1,8 +0,0 @@
macro_rules! try_query_result {
($res:expr) => {
match $res {
Ok(resp) => resp,
Err(err) => return err.into(),
}
};
}

View File

@ -134,9 +134,9 @@ pub struct MetaEnumValue {
/// #[async_std::main]
/// async fn main() {
/// let schema = Schema::new(QueryRoot, EmptyMutation, EmptySubscription);
/// assert_eq!(schema.execute("{ value1 }").await.unwrap().cache_control, CacheControl { public: true, max_age: 30 });
/// assert_eq!(schema.execute("{ value2 }").await.unwrap().cache_control, CacheControl { public: false, max_age: 60 });
/// assert_eq!(schema.execute("{ value1 value2 }").await.unwrap().cache_control, CacheControl { public: false, max_age: 30 });
/// assert_eq!(schema.execute("{ value1 }").await.into_result().unwrap().cache_control, CacheControl { public: true, max_age: 30 });
/// assert_eq!(schema.execute("{ value2 }").await.into_result().unwrap().cache_control, CacheControl { public: false, max_age: 60 });
/// assert_eq!(schema.execute("{ value1 value2 }").await.into_result().unwrap().cache_control, CacheControl { public: false, max_age: 30 });
/// }
/// ```
#[derive(Clone, Copy, PartialEq, Eq, Debug)]

View File

@ -29,52 +29,6 @@ impl Response {
self.error.is_some()
}
/// Get self.
///
/// Panics
///
/// It will panic when the response is error.
#[inline]
pub fn unwrap(self) -> Self {
self
}
/// Get the error object.
///
/// Panics
///
/// It will panic when the response is ok.
#[inline]
pub fn unwrap_err(self) -> Error {
self.error.unwrap()
}
/// Returns the contained error, consuming the self value.
///
/// Panics
///
/// Panics if the response is ok, with a panic message including the passed message.
#[inline]
pub fn expect_err(self, msg: &str) -> Error {
match self.error {
Some(err) => err,
None => panic!("{}", msg),
}
}
/// Returns self, consuming the self value.
///
/// Panics
///
/// Panics if the response is errror, with a panic message including the passed message.
#[inline]
pub fn expect(self, msg: &str) -> Self {
match self.error {
Some(_) => panic!("{}", msg),
None => self,
}
}
/// Convert response to `Result<Response>`.
#[inline]
pub fn into_result(self) -> Result<Self> {

View File

@ -128,7 +128,7 @@ mod test {
let query = r#"{ obj(input: { a: 1, b: 2, c: { a: 11, b: 22 } } ) }"#;
let schema = Schema::new(Query, EmptyMutation, EmptySubscription);
assert_eq!(
schema.execute(query).await.unwrap().data,
schema.execute(query).await.into_result().unwrap().data,
serde_json::json!({
"obj": {
"a": 1,

View File

@ -12,7 +12,7 @@ use crate::{
do_resolve, CacheControl, ContextBase, Error, ObjectType, Pos, QueryEnv, QueryError, Request,
Response, Result, SubscriptionType, Type, Variables, ID,
};
use futures::Stream;
use futures::{Stream, StreamExt};
use indexmap::map::IndexMap;
use itertools::Itertools;
use std::any::Any;
@ -20,6 +20,15 @@ use std::ops::Deref;
use std::sync::atomic::AtomicUsize;
use std::sync::Arc;
macro_rules! try_query_result {
($res:expr) => {
match $res {
Ok(resp) => resp,
Err(err) => return err.into(),
}
};
}
/// Schema builder
pub struct SchemaBuilder<Query, Mutation, Subscription> {
validation_mode: ValidationMode,
@ -431,55 +440,72 @@ where
}
/// Execute an GraphQL subscription.
pub async fn execute_stream(
&self,
request: impl Into<Request>,
) -> Result<impl Stream<Item = Response> + Send> {
let request = request.into();
let (document, _, extensions) = self.prepare_query(&request.query, &request.variables)?;
pub fn execute_stream(&self, request: impl Into<Request>) -> impl Stream<Item = Response> {
let schema = self.clone();
Box::pin(async_stream::stream! {
let request = request.into();
let (document, extensions) = match schema.prepare_query(&request.query, &request.variables) {
Ok((document, _, extensions)) => (document, extensions),
Err(err) => {
yield Response::from(err);
return;
}
};
let document = match document.into_data(request.operation_name.as_deref()) {
Some(document) => document,
None => {
let err = if let Some(name) = request.operation_name {
QueryError::UnknownOperationNamed {
name: name.to_string(),
}
.into_error(Pos::default())
} else {
QueryError::MissingOperation.into_error(Pos::default())
};
let document = match document.into_data(request.operation_name.as_deref()) {
Some(document) => document,
None => {
let err = if let Some(name) = request.operation_name {
QueryError::UnknownOperationNamed {
name: name.to_string(),
}
.into_error(Pos::default())
} else {
QueryError::MissingOperation.into_error(Pos::default())
};
extensions.lock().error(&err);
yield err.into();
return;
}
};
if document.operation.node.ty != OperationType::Subscription {
let err = QueryError::NotSupported.into_error(Pos::default());
extensions.lock().error(&err);
return Err(err.into());
yield err.into();
return;
}
};
if document.operation.node.ty != OperationType::Subscription {
let err = QueryError::NotSupported.into_error(Pos::default());
extensions.lock().error(&err);
return Err(err);
}
let resolve_id = AtomicUsize::default();
let env = QueryEnv::new(
extensions,
request.variables,
document,
Arc::new(request.ctx_data),
);
let resolve_id = AtomicUsize::default();
let env = QueryEnv::new(
extensions,
request.variables,
document,
Arc::new(request.ctx_data),
);
let ctx = env.create_context(
&self.env,
None,
&env.document.operation.node.selection_set,
&resolve_id,
);
let mut streams = Vec::new();
match create_subscription_stream(self, env.clone(), &ctx, &mut streams).await {
Ok(()) => Ok(futures::stream::select_all(streams)),
Err(err) => {
env.extensions.lock().error(&err);
Err(err)
let ctx = env.create_context(
&schema.env,
None,
&env.document.operation.node.selection_set,
&resolve_id,
);
let mut streams = Vec::new();
if let Err(err) = create_subscription_stream(&schema, env.clone(), &ctx, &mut streams).await {
yield err.into();
return;
}
}
let mut stream = futures::stream::select_all(streams);
while let Some(resp) = stream.next().await {
let is_err = resp.is_err();
yield resp;
if is_err {
break;
}
}
})
}
}

View File

@ -69,7 +69,7 @@ pub struct EmptyFields;
/// async fn main() {
/// let schema = Schema::new(QueryRoot, EmptyMutation, EmptySubscription);
///
/// assert_eq!(schema.execute("{ numbers(first: 2) { edges { node diff } } }").await.unwrap().data, serde_json::json!({
/// assert_eq!(schema.execute("{ numbers(first: 2) { edges { node diff } } }").await.into_result().unwrap().data, serde_json::json!({
/// "numbers": {
/// "edges": [
/// {"node": 0, "diff": 10000},
@ -78,7 +78,7 @@ pub struct EmptyFields;
/// },
/// }));
///
/// assert_eq!(schema.execute("{ numbers(last: 2) { edges { node diff } } }").await.unwrap().data, serde_json::json!({
/// assert_eq!(schema.execute("{ numbers(last: 2) { edges { node diff } } }").await.into_result().unwrap().data, serde_json::json!({
/// "numbers": {
/// "edges": [
/// {"node": 9998, "diff": 2},

View File

@ -35,7 +35,7 @@ use std::borrow::Cow;
/// v3:value1
/// }"#;
/// assert_eq!(
/// schema.execute(query).await.unwrap().data,
/// schema.execute(query).await.into_result().unwrap().data,
/// serde_json::json!({
/// "v1": 99,
/// "v2": 1,

View File

@ -37,7 +37,7 @@ pub async fn test_complexity_and_depth() {
.limit_complexity(2)
.finish();
assert_eq!(
schema.execute(query).await.unwrap_err(),
schema.execute(query).await.into_result().unwrap_err(),
Error::Query {
pos: Pos { line: 0, column: 0 },
path: None,
@ -62,7 +62,7 @@ pub async fn test_complexity_and_depth() {
.limit_complexity(2)
.finish();
assert_eq!(
schema.execute(query).await.unwrap_err(),
schema.execute(query).await.into_result().unwrap_err(),
Error::Query {
pos: Pos { line: 0, column: 0 },
path: None,
@ -95,7 +95,7 @@ pub async fn test_complexity_and_depth() {
.limit_depth(2)
.finish();
assert_eq!(
schema.execute(query).await.unwrap_err(),
schema.execute(query).await.into_result().unwrap_err(),
Error::Query {
pos: Pos { line: 0, column: 0 },
path: None,

View File

@ -84,7 +84,7 @@ pub async fn test_field_features() {
let query = "{ valueAbc }";
assert_eq!(
schema.execute(query).await.unwrap_err(),
schema.execute(query).await.into_result().unwrap_err(),
Error::Query {
pos: Pos { column: 3, line: 1 },
path: Some(serde_json::json!(["valueAbc"])),
@ -113,7 +113,7 @@ pub async fn test_field_features() {
let query = "{ obj { valueAbc } }";
assert_eq!(
schema.execute(query).await.unwrap_err(),
schema.execute(query).await.into_result().unwrap_err(),
Error::Query {
pos: Pos { column: 9, line: 1 },
path: Some(serde_json::json!(["obj", "valueAbc"])),
@ -124,10 +124,7 @@ pub async fn test_field_features() {
}
);
let mut stream = schema
.execute_stream("subscription { values }")
.await
.unwrap();
let mut stream = schema.execute_stream("subscription { values }");
assert_eq!(
stream.next().await.map(|resp| resp.data),
Some(serde_json::json!({
@ -135,10 +132,7 @@ pub async fn test_field_features() {
}))
);
let mut stream = schema
.execute_stream("subscription { valuesBson }")
.await
.unwrap();
let mut stream = schema.execute_stream("subscription { valuesBson }");
assert_eq!(
stream.next().await.map(|resp| resp.data),
Some(serde_json::json!({
@ -146,13 +140,14 @@ pub async fn test_field_features() {
}))
);
let err = schema
.execute_stream("subscription { valuesAbc }")
.await
.map(|_| ())
.unwrap_err();
assert_eq!(
err,
schema
.execute_stream("subscription { valuesAbc }")
.next()
.await
.unwrap()
.error
.unwrap(),
Error::Query {
pos: Pos {
column: 16,

View File

@ -22,7 +22,7 @@ pub async fn test_fieldresult() {
let schema = Schema::new(Query, EmptyMutation, EmptySubscription);
assert_eq!(
schema.execute("{ error }").await.unwrap_err(),
schema.execute("{ error }").await.into_result().unwrap_err(),
Error::Query {
pos: Pos { line: 1, column: 3 },
path: Some(serde_json::json!(["error"])),
@ -34,7 +34,11 @@ pub async fn test_fieldresult() {
);
assert_eq!(
schema.execute("{ optError }").await.unwrap_err(),
schema
.execute("{ optError }")
.await
.into_result()
.unwrap_err(),
Error::Query {
pos: Pos { line: 1, column: 3 },
path: Some(serde_json::json!(["optError"])),
@ -46,7 +50,11 @@ pub async fn test_fieldresult() {
);
assert_eq!(
schema.execute("{ vecError }").await.unwrap_err(),
schema
.execute("{ vecError }")
.await
.into_result()
.unwrap_err(),
Error::Query {
pos: Pos { line: 1, column: 3 },
path: Some(serde_json::json!(["vecError", 1])),

View File

@ -90,6 +90,7 @@ pub async fn test_guard() {
schema
.execute(Request::new(query).data(Role::Guest))
.await
.into_result()
.unwrap_err(),
Error::Query {
pos: Pos { line: 1, column: 9 },
@ -117,6 +118,7 @@ pub async fn test_guard() {
schema
.execute(Request::new(query).data(Role::Guest))
.await
.into_result()
.unwrap_err(),
Error::Query {
pos: Pos { line: 1, column: 3 },
@ -131,8 +133,6 @@ pub async fn test_guard() {
assert_eq!(
schema
.execute_stream(Request::new("subscription { values }").data(Role::Admin))
.await
.unwrap()
.map(|item| item.data)
.collect::<Vec<_>>()
.await,
@ -146,9 +146,11 @@ pub async fn test_guard() {
assert_eq!(
schema
.execute_stream(Request::new("subscription { values }").data(Role::Guest))
.next()
.await
.map(|_| ())
.unwrap_err(),
.unwrap()
.error
.unwrap(),
Error::Query {
pos: Pos {
line: 1,
@ -195,6 +197,7 @@ pub async fn test_multiple_guards() {
.data(Username("test".to_string()))
)
.await
.into_result()
.unwrap_err(),
Error::Query {
pos: Pos { line: 1, column: 3 },
@ -215,6 +218,7 @@ pub async fn test_multiple_guards() {
.data(Username("test1".to_string()))
)
.await
.into_result()
.unwrap_err(),
Error::Query {
pos: Pos { line: 1, column: 3 },
@ -235,6 +239,7 @@ pub async fn test_multiple_guards() {
.data(Username("test1".to_string()))
)
.await
.into_result()
.unwrap_err(),
Error::Query {
pos: Pos { line: 1, column: 3 },
@ -290,6 +295,7 @@ pub async fn test_guard_forward_arguments() {
schema
.execute(Request::new(query).data(ID::from("aaa")))
.await
.into_result()
.unwrap_err(),
Error::Query {
pos: Pos { line: 1, column: 3 },

View File

@ -194,6 +194,7 @@ pub async fn test_inputobject_flatten_recursive() {
}"#
)
.await
.into_result()
.unwrap()
.data,
serde_json::json!({
@ -209,6 +210,7 @@ pub async fn test_inputobject_flatten_recursive() {
}"#
)
.await
.into_result()
.unwrap()
.data,
serde_json::json!({
@ -224,6 +226,7 @@ pub async fn test_inputobject_flatten_recursive() {
}"#
)
.await
.into_result()
.unwrap()
.data,
serde_json::json!({

View File

@ -63,6 +63,7 @@ pub async fn test_input_validator_string_min_length() {
schema
.execute(&field_query)
.await
.into_result()
.expect_err(&should_fail_msg),
Error::Rule {
errors: vec!(RuleError {
@ -79,6 +80,7 @@ pub async fn test_input_validator_string_min_length() {
schema
.execute(&object_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -96,6 +98,7 @@ pub async fn test_input_validator_string_min_length() {
schema
.execute(&field_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"fieldParameter": true}),
@ -107,6 +110,7 @@ pub async fn test_input_validator_string_min_length() {
schema
.execute(&object_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"inputObject": true}),
@ -169,6 +173,7 @@ pub async fn test_input_validator_string_max_length() {
schema
.execute(&field_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -185,6 +190,7 @@ pub async fn test_input_validator_string_max_length() {
schema
.execute(&object_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -202,6 +208,7 @@ pub async fn test_input_validator_string_max_length() {
schema
.execute(&field_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"fieldParameter": true}),
@ -213,6 +220,7 @@ pub async fn test_input_validator_string_max_length() {
schema
.execute(&object_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"inputObject": true}),
@ -302,6 +310,7 @@ pub async fn test_input_validator_string_email() {
schema
.execute(&field_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -319,6 +328,7 @@ pub async fn test_input_validator_string_email() {
schema
.execute(&object_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -338,6 +348,7 @@ pub async fn test_input_validator_string_email() {
schema
.execute(&field_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"fieldParameter": true}),
@ -349,6 +360,7 @@ pub async fn test_input_validator_string_email() {
schema
.execute(&object_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"inputObject": true}),
@ -446,6 +458,7 @@ pub async fn test_input_validator_string_mac() {
schema_without_colon
.execute(&field_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -463,6 +476,7 @@ pub async fn test_input_validator_string_mac() {
schema_without_colon
.execute(&object_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -479,6 +493,7 @@ pub async fn test_input_validator_string_mac() {
schema_with_colon
.execute(&field_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -496,6 +511,7 @@ pub async fn test_input_validator_string_mac() {
schema_with_colon
.execute(&object_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -528,6 +544,7 @@ pub async fn test_input_validator_string_mac() {
schema_with_colon
.execute(&field_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"fieldParameter": true}),
@ -539,6 +556,7 @@ pub async fn test_input_validator_string_mac() {
schema_with_colon
.execute(&object_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"inputObject": true}),
@ -550,6 +568,7 @@ pub async fn test_input_validator_string_mac() {
schema_without_colon
.execute(&field_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -567,6 +586,7 @@ pub async fn test_input_validator_string_mac() {
schema_without_colon
.execute(&object_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -583,6 +603,7 @@ pub async fn test_input_validator_string_mac() {
schema_without_colon
.execute(&field_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"fieldParameter": true}),
@ -594,6 +615,7 @@ pub async fn test_input_validator_string_mac() {
schema_without_colon
.execute(&object_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"inputObject": true}),
@ -605,6 +627,7 @@ pub async fn test_input_validator_string_mac() {
schema_with_colon
.execute(&field_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -622,6 +645,7 @@ pub async fn test_input_validator_string_mac() {
schema_with_colon
.execute(&object_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -681,6 +705,7 @@ pub async fn test_input_validator_int_range() {
schema
.execute(&field_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -697,6 +722,7 @@ pub async fn test_input_validator_int_range() {
schema
.execute(&object_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -714,6 +740,7 @@ pub async fn test_input_validator_int_range() {
schema
.execute(&field_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"fieldParameter": true}),
@ -725,6 +752,7 @@ pub async fn test_input_validator_int_range() {
schema
.execute(&object_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"inputObject": true}),
@ -782,6 +810,7 @@ pub async fn test_input_validator_int_less_than() {
schema
.execute(&field_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -798,6 +827,7 @@ pub async fn test_input_validator_int_less_than() {
schema
.execute(&object_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -815,6 +845,7 @@ pub async fn test_input_validator_int_less_than() {
schema
.execute(&field_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"fieldParameter": true}),
@ -826,6 +857,7 @@ pub async fn test_input_validator_int_less_than() {
schema
.execute(&object_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"inputObject": true}),
@ -885,6 +917,7 @@ pub async fn test_input_validator_int_greater_than() {
schema
.execute(&field_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -901,6 +934,7 @@ pub async fn test_input_validator_int_greater_than() {
schema
.execute(&object_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -918,6 +952,7 @@ pub async fn test_input_validator_int_greater_than() {
schema
.execute(&field_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"fieldParameter": true}),
@ -929,6 +964,7 @@ pub async fn test_input_validator_int_greater_than() {
schema
.execute(&object_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"inputObject": true}),
@ -981,6 +1017,7 @@ pub async fn test_input_validator_int_nonzero() {
schema
.execute(&field_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -997,6 +1034,7 @@ pub async fn test_input_validator_int_nonzero() {
schema
.execute(&object_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -1014,6 +1052,7 @@ pub async fn test_input_validator_int_nonzero() {
schema
.execute(&field_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"fieldParameter": true}),
@ -1025,6 +1064,7 @@ pub async fn test_input_validator_int_nonzero() {
schema
.execute(&object_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"inputObject": true}),
@ -1059,7 +1099,7 @@ pub async fn test_input_validator_int_equal() {
let schema = Schema::new(QueryRoot, EmptyMutation, EmptySubscription);
let equal_to = 5;
for case in -10..10 {
for case in -10i32..10 {
let field_query = format!("{{fieldParameter(id: {})}}", case);
let object_query = format!("{{inputObject(input: {{id: {}}})}}", case);
if case != equal_to {
@ -1078,6 +1118,7 @@ pub async fn test_input_validator_int_equal() {
schema
.execute(&field_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -1094,6 +1135,7 @@ pub async fn test_input_validator_int_equal() {
schema
.execute(&object_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -1111,6 +1153,7 @@ pub async fn test_input_validator_int_equal() {
schema
.execute(&field_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"fieldParameter": true}),
@ -1122,6 +1165,7 @@ pub async fn test_input_validator_int_equal() {
schema
.execute(&object_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"inputObject": true}),
@ -1190,6 +1234,7 @@ pub async fn test_input_validator_list_max_length() {
schema
.execute(&field_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -1206,6 +1251,7 @@ pub async fn test_input_validator_list_max_length() {
schema
.execute(&object_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -1223,6 +1269,7 @@ pub async fn test_input_validator_list_max_length() {
schema
.execute(&field_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"fieldParameter": true}),
@ -1234,6 +1281,7 @@ pub async fn test_input_validator_list_max_length() {
schema
.execute(&object_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"inputObject": true}),
@ -1302,6 +1350,7 @@ pub async fn test_input_validator_list_min_length() {
schema
.execute(&field_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -1318,6 +1367,7 @@ pub async fn test_input_validator_list_min_length() {
schema
.execute(&object_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -1335,6 +1385,7 @@ pub async fn test_input_validator_list_min_length() {
schema
.execute(&field_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"fieldParameter": true}),
@ -1346,6 +1397,7 @@ pub async fn test_input_validator_list_min_length() {
schema
.execute(&object_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"inputObject": true}),
@ -1422,6 +1474,7 @@ pub async fn test_input_validator_operator_or() {
schema
.execute(&field_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -1438,6 +1491,7 @@ pub async fn test_input_validator_operator_or() {
schema
.execute(&object_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -1455,6 +1509,7 @@ pub async fn test_input_validator_operator_or() {
schema
.execute(&field_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"fieldParameter": true}),
@ -1466,6 +1521,7 @@ pub async fn test_input_validator_operator_or() {
schema
.execute(&object_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"inputObject": true}),
@ -1535,6 +1591,7 @@ pub async fn test_input_validator_operator_and() {
schema
.execute(&field_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -1551,6 +1608,7 @@ pub async fn test_input_validator_operator_and() {
schema
.execute(&object_query)
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -1568,6 +1626,7 @@ pub async fn test_input_validator_operator_and() {
schema
.execute(&field_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"fieldParameter": true}),
@ -1579,6 +1638,7 @@ pub async fn test_input_validator_operator_and() {
schema
.execute(&object_query)
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"inputObject": true}),
@ -1654,6 +1714,7 @@ pub async fn test_input_validator_variable() {
schema
.execute(Request::new(field_query).variables(variables.clone()))
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -1670,6 +1731,7 @@ pub async fn test_input_validator_variable() {
schema
.execute(Request::new(object_query).variables(variables.clone()))
.await
.into_result()
.expect_err(&should_fail_msg[..]),
Error::Rule {
errors: vec!(RuleError {
@ -1687,6 +1749,7 @@ pub async fn test_input_validator_variable() {
schema
.execute(Request::new(field_query).variables(variables.clone()))
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"fieldParameter": true}),
@ -1698,6 +1761,7 @@ pub async fn test_input_validator_variable() {
schema
.execute(Request::new(object_query).variables(variables.clone()))
.await
.into_result()
.expect(&error_msg[..])
.data,
serde_json::json!({"inputObject": true}),

View File

@ -14,7 +14,7 @@ pub async fn test_input_value_custom_error() {
let schema = Schema::new(Query, EmptyMutation, EmptySubscription);
let query = r#"{ parseInt(n:289) }"#;
assert_eq!(
schema.execute(query).await.unwrap_err(),
schema.execute(query).await.into_result().unwrap_err(),
Error::Query {
pos: Pos {
line: 1,

View File

@ -35,7 +35,7 @@ pub async fn test_interface_simple_object() {
}"#;
let schema = Schema::new(Query, EmptyMutation, EmptySubscription);
assert_eq!(
schema.execute(query).await.unwrap().data,
schema.execute(query).await.into_result().unwrap().data,
serde_json::json!({
"node": {
"id": 33,
@ -79,7 +79,7 @@ pub async fn test_interface_simple_object2() {
}"#;
let schema = Schema::new(Query, EmptyMutation, EmptySubscription);
assert_eq!(
schema.execute(query).await.unwrap().data,
schema.execute(query).await.into_result().unwrap().data,
serde_json::json!({
"node": {
"id": 33,
@ -143,7 +143,7 @@ pub async fn test_multiple_interfaces() {
}
}"#;
assert_eq!(
schema.execute(query).await.unwrap().data,
schema.execute(query).await.into_result().unwrap().data,
serde_json::json!({
"myObj": {
"valueA": 1,
@ -219,7 +219,7 @@ pub async fn test_multiple_objects_in_multiple_interfaces() {
}
}"#;
assert_eq!(
schema.execute(query).await.unwrap().data,
schema.execute(query).await.into_result().unwrap().data,
serde_json::json!({
"myObj": [{
"valueA": 1,
@ -266,7 +266,7 @@ pub async fn test_interface_field_result() {
}"#;
let schema = Schema::new(Query, EmptyMutation, EmptySubscription);
assert_eq!(
schema.execute(query).await.unwrap().data,
schema.execute(query).await.into_result().unwrap().data,
serde_json::json!({
"node": {
"value": 10,
@ -315,7 +315,7 @@ pub async fn test_interface_field_method() {
let query = "{ test { created_at } }";
let schema = Schema::new(Query, EmptyMutation, EmptySubscription);
assert_eq!(
schema.execute(query).await.unwrap().data,
schema.execute(query).await.into_result().unwrap().data,
serde_json::json!({
"test": {
"created_at": 1,

View File

@ -349,7 +349,7 @@ pub async fn test_introspection_deprecation() {
}
});
let mut res = schema.execute(&query).await.unwrap().data;
let mut res = schema.execute(&query).await.into_result().unwrap().data;
assert_eq!(res, res_json);
@ -408,7 +408,7 @@ pub async fn test_introspection_deprecation() {
}
});
res = schema.execute(&query).await.unwrap().data;
res = schema.execute(&query).await.into_result().unwrap().data;
assert_eq!(res, res_json);
@ -427,7 +427,7 @@ pub async fn test_introspection_deprecation() {
}
});
res = schema.execute(&query).await.unwrap().data;
res = schema.execute(&query).await.into_result().unwrap().data;
assert_eq!(res, res_json);
@ -440,7 +440,7 @@ pub async fn test_introspection_deprecation() {
}
});
res = schema.execute(&query).await.unwrap().data;
res = schema.execute(&query).await.into_result().unwrap().data;
assert_eq!(res, res_json);
@ -481,7 +481,7 @@ pub async fn test_introspection_deprecation() {
}
});
res = schema.execute(&query).await.unwrap().data;
res = schema.execute(&query).await.into_result().unwrap().data;
assert_eq!(res, res_json);
@ -500,7 +500,7 @@ pub async fn test_introspection_deprecation() {
}
});
res = schema.execute(&query).await.unwrap().data;
res = schema.execute(&query).await.into_result().unwrap().data;
assert_eq!(res, res_json);
}
@ -531,7 +531,7 @@ pub async fn test_introspection_type_kind() {
}
});
let mut res = schema.execute(&query).await.unwrap().data;
let mut res = schema.execute(&query).await.into_result().unwrap().data;
assert_eq!(res, res_json);
@ -545,7 +545,7 @@ pub async fn test_introspection_type_kind() {
}
});
res = schema.execute(&query).await.unwrap().data;
res = schema.execute(&query).await.into_result().unwrap().data;
assert_eq!(res, res_json);
@ -559,7 +559,7 @@ pub async fn test_introspection_type_kind() {
}
});
res = schema.execute(&query).await.unwrap().data;
res = schema.execute(&query).await.into_result().unwrap().data;
assert_eq!(res, res_json);
@ -573,7 +573,7 @@ pub async fn test_introspection_type_kind() {
}
});
res = schema.execute(&query).await.unwrap().data;
res = schema.execute(&query).await.into_result().unwrap().data;
assert_eq!(res, res_json);
@ -587,7 +587,7 @@ pub async fn test_introspection_type_kind() {
}
});
res = schema.execute(&query).await.unwrap().data;
res = schema.execute(&query).await.into_result().unwrap().data;
assert_eq!(res, res_json);
@ -626,7 +626,7 @@ pub async fn test_introspection_type_kind() {
}
});
res = schema.execute(&query).await.unwrap().data;
res = schema.execute(&query).await.into_result().unwrap().data;
assert_eq!(res, res_json);
@ -659,7 +659,7 @@ pub async fn test_introspection_type_kind() {
}
});
res = schema.execute(&query).await.unwrap().data;
res = schema.execute(&query).await.into_result().unwrap().data;
assert_eq!(res, res_json);
}
@ -686,7 +686,7 @@ pub async fn test_introspection_scalar() {
}
});
let res = schema.execute(query).await.unwrap().data;
let res = schema.execute(query).await.into_result().unwrap().data;
assert_eq!(res, res_json)
}
@ -722,7 +722,7 @@ pub async fn test_introspection_union() {
}
});
let res = schema.execute(query).await.unwrap().data;
let res = schema.execute(query).await.into_result().unwrap().data;
assert_eq!(res, res_json)
}
@ -765,7 +765,7 @@ pub async fn test_introspection_interface() {
}
});
let mut res = schema.execute(query).await.unwrap().data;
let mut res = schema.execute(query).await.into_result().unwrap().data;
assert_eq!(res, res_json);
@ -800,7 +800,7 @@ pub async fn test_introspection_interface() {
}
});
res = schema.execute(query).await.unwrap().data;
res = schema.execute(query).await.into_result().unwrap().data;
assert_eq!(res, res_json);
}
@ -847,7 +847,7 @@ pub async fn test_introspection_enum() {
}
});
let res = schema.execute(query).await.unwrap().data;
let res = schema.execute(query).await.into_result().unwrap().data;
println!("{}", serde_json::to_string_pretty(&res).unwrap());
@ -882,7 +882,7 @@ pub async fn test_introspection_input_object() {
}
});
let res = schema.execute(query).await.unwrap().data;
let res = schema.execute(query).await.into_result().unwrap().data;
assert_eq!(res, res_json)
}
@ -930,7 +930,7 @@ pub async fn test_introspection_mutation() {
}
});
let res = schema.execute(query).await.unwrap().data;
let res = schema.execute(query).await.into_result().unwrap().data;
assert_eq!(res, res_json)
}
@ -978,7 +978,7 @@ pub async fn test_introspection_subscription() {
}
});
let res = schema.execute(query).await.unwrap().data;
let res = schema.execute(query).await.into_result().unwrap().data;
assert_eq!(res, res_json)
}

View File

@ -45,7 +45,7 @@ pub async fn test_merged_object() {
let schema = Schema::new(Query, EmptyMutation, EmptySubscription);
let query = "{ obj { a b c } }";
assert_eq!(
schema.execute(query).await.unwrap().data,
schema.execute(query).await.into_result().unwrap().data,
serde_json::json!({
"obj": {
"a": 10,
@ -73,7 +73,7 @@ pub async fn test_merged_object_macro() {
let schema = Schema::new(Query, EmptyMutation, EmptySubscription);
let query = "{ obj { a b c } }";
assert_eq!(
schema.execute(query).await.unwrap().data,
schema.execute(query).await.into_result().unwrap().data,
serde_json::json!({
"obj": {
"a": 10,
@ -101,7 +101,7 @@ pub async fn test_merged_object_derive() {
let schema = Schema::new(Query, EmptyMutation, EmptySubscription);
let query = "{ obj { a b c } }";
assert_eq!(
schema.execute(query).await.unwrap().data,
schema.execute(query).await.into_result().unwrap().data,
serde_json::json!({
"obj": {
"a": 10,
@ -150,7 +150,7 @@ pub async fn test_merged_object_default() {
let schema = Schema::new(Query::default(), EmptyMutation, EmptySubscription);
let query = "{ a b }";
assert_eq!(
schema.execute(query).await.unwrap().data,
schema.execute(query).await.into_result().unwrap().data,
serde_json::json!({
"a": 10,
"b": 20,
@ -193,9 +193,7 @@ pub async fn test_merged_subscription() {
{
let mut stream = schema
.execute_stream("subscription { events1 }")
.await
.unwrap()
.map(|resp| resp.unwrap().data);
.map(|resp| resp.into_result().unwrap().data);
for i in 0i32..10 {
assert_eq!(
Some(serde_json::json!({
@ -210,9 +208,7 @@ pub async fn test_merged_subscription() {
{
let mut stream = schema
.execute_stream("subscription { events2 }")
.await
.unwrap()
.map(|resp| resp.unwrap().data);
.map(|resp| resp.into_result().unwrap().data);
for i in 10i32..20 {
assert_eq!(
Some(serde_json::json!({

View File

@ -93,6 +93,7 @@ pub async fn test_post_guard() {
schema
.execute(Request::new(query).data(Username("test1".to_string())))
.await
.into_result()
.unwrap_err(),
Error::Query {
pos: Pos { line: 1, column: 3 },
@ -120,6 +121,7 @@ pub async fn test_post_guard() {
schema
.execute(Request::new(query).data(Username("test1".to_string())))
.await
.into_result()
.unwrap_err(),
Error::Query {
pos: Pos { line: 1, column: 9 },
@ -167,6 +169,7 @@ pub async fn test_multiple_post_guards() {
.data(Username("test".to_string()))
)
.await
.into_result()
.unwrap_err(),
Error::Query {
pos: Pos { line: 1, column: 3 },
@ -187,6 +190,7 @@ pub async fn test_multiple_post_guards() {
.data(Username("test1".to_string()))
)
.await
.into_result()
.unwrap_err(),
Error::Query {
pos: Pos { line: 1, column: 3 },
@ -207,6 +211,7 @@ pub async fn test_multiple_post_guards() {
.data(Username("test1".to_string()))
)
.await
.into_result()
.unwrap_err(),
Error::Query {
pos: Pos { line: 1, column: 3 },
@ -263,6 +268,7 @@ pub async fn test_post_guard_forward_arguments() {
schema
.execute(Request::new(query).data(ID::from("aaa")))
.await
.into_result()
.unwrap_err(),
Error::Query {
pos: Pos { line: 1, column: 3 },
@ -318,6 +324,7 @@ pub async fn test_post_guard_generic() {
schema
.execute(Request::new(query).data(ID::from("aaa")))
.await
.into_result()
.unwrap_err(),
Error::Query {
pos: Pos { line: 1, column: 3 },

View File

@ -53,7 +53,7 @@ pub async fn test_input_value_custom_error() {
enumValue(value: TYPE)
}"#;
assert_eq!(
schema.execute(query).await.unwrap().data,
schema.execute(query).await.into_result().unwrap().data,
serde_json::json!({
"type": 99,
"obj": { "i32": 88 },
@ -63,8 +63,6 @@ pub async fn test_input_value_custom_error() {
let mut stream = schema
.execute_stream("subscription { type }")
.await
.unwrap()
.map(|resp| resp.into_result())
.map_ok(|resp| resp.data);
for i in 0..10 {

View File

@ -32,9 +32,7 @@ pub async fn test_subscription() {
{
let mut stream = schema
.execute_stream("subscription { values(start: 10, end: 20) }")
.await
.unwrap()
.map(|resp| resp.unwrap().data);
.map(|resp| resp.into_result().unwrap().data);
for i in 10..20 {
assert_eq!(
Some(serde_json::json!({ "values": i })),
@ -47,9 +45,7 @@ pub async fn test_subscription() {
{
let mut stream = schema
.execute_stream("subscription { events(start: 10, end: 20) { a b } }")
.await
.unwrap()
.map(|resp| resp.unwrap().data);
.map(|resp| resp.into_result().unwrap().data);
for i in 10..20 {
assert_eq!(
Some(serde_json::json!({ "events": {"a": i, "b": i * 10} })),
@ -84,30 +80,27 @@ pub async fn test_simple_broker() {
#[Subscription]
impl SubscriptionRoot {
async fn events1(&self) -> impl Stream<Item = Event1> {
SimpleBroker::<Event1>::subscribe()
let stream = SimpleBroker::<Event1>::subscribe();
SimpleBroker::publish(Event1 { value: 10 });
SimpleBroker::publish(Event1 { value: 15 });
stream
}
async fn events2(&self) -> impl Stream<Item = Event2> {
SimpleBroker::<Event2>::subscribe()
let stream = SimpleBroker::<Event2>::subscribe();
SimpleBroker::publish(Event2 { value: 88 });
SimpleBroker::publish(Event2 { value: 99 });
stream
}
}
let schema = Schema::new(QueryRoot, EmptyMutation, SubscriptionRoot);
let mut stream1 = schema
.execute_stream("subscription { events1 { value } }")
.await
.unwrap()
.map(|resp| resp.unwrap().data);
.map(|resp| resp.into_result().unwrap().data);
let mut stream2 = schema
.execute_stream("subscription { events2 { value } }")
.await
.unwrap()
.map(|resp| resp.unwrap().data);
SimpleBroker::publish(Event1 { value: 10 });
SimpleBroker::publish(Event2 { value: 88 });
SimpleBroker::publish(Event1 { value: 15 });
SimpleBroker::publish(Event2 { value: 99 });
.map(|resp| resp.into_result().unwrap().data);
assert_eq!(
stream1.next().await,
@ -163,8 +156,6 @@ pub async fn test_subscription_with_ctx_data() {
{
let mut stream = schema
.execute_stream(Request::new("subscription { values objects { value } }").data(100i32))
.await
.unwrap()
.map(|resp| resp.data);
assert_eq!(
Some(serde_json::json!({ "values": 100 })),
@ -206,9 +197,7 @@ pub async fn test_subscription_with_token() {
.execute_stream(
Request::new("subscription { values }").data(Token("123456".to_string())),
)
.await
.unwrap()
.map(|resp| resp.unwrap().data);
.map(|resp| resp.into_result().unwrap().data);
assert_eq!(
Some(serde_json::json!({ "values": 100 })),
stream.next().await
@ -221,7 +210,9 @@ pub async fn test_subscription_with_token() {
.execute_stream(
Request::new("subscription { values }").data(Token("654321".to_string()))
)
.next()
.await
.unwrap()
.is_err());
}
}
@ -262,8 +253,6 @@ pub async fn test_subscription_inline_fragment() {
}
"#,
)
.await
.unwrap()
.map(|resp| resp.data);
for i in 10..20 {
assert_eq!(
@ -317,8 +306,6 @@ pub async fn test_subscription_fragment() {
}
"#,
)
.await
.unwrap()
.map(|resp| resp.data);
for i in 10..20 {
assert_eq!(
@ -373,8 +360,6 @@ pub async fn test_subscription_fragment2() {
}
"#,
)
.await
.unwrap()
.map(|resp| resp.data);
for i in 10..20 {
assert_eq!(
@ -419,8 +404,6 @@ pub async fn test_subscription_error() {
let schema = Schema::new(QueryRoot, EmptyMutation, SubscriptionRoot);
let mut stream = schema
.execute_stream("subscription { events { value } }")
.await
.unwrap()
.map(|resp| resp.into_result())
.map_ok(|resp| resp.data);
for i in 0i32..5 {
@ -470,8 +453,6 @@ pub async fn test_subscription_fieldresult() {
let schema = Schema::new(QueryRoot, EmptyMutation, SubscriptionRoot);
let mut stream = schema
.execute_stream("subscription { values }")
.await
.unwrap()
.map(|resp| resp.into_result())
.map_ok(|resp| resp.data);
for i in 0i32..5 {

View File

@ -35,7 +35,7 @@ pub async fn test_union_simple_object() {
}"#;
let schema = Schema::new(Query, EmptyMutation, EmptySubscription);
assert_eq!(
schema.execute(query).await.unwrap().data,
schema.execute(query).await.into_result().unwrap().data,
serde_json::json!({
"node": {
"id": 33,
@ -79,7 +79,7 @@ pub async fn test_union_simple_object2() {
}"#;
let schema = Schema::new(Query, EmptyMutation, EmptySubscription);
assert_eq!(
schema.execute(query).await.unwrap().data,
schema.execute(query).await.into_result().unwrap().data,
serde_json::json!({
"node": {
"id": 33,
@ -149,7 +149,7 @@ pub async fn test_multiple_unions() {
}
}"#;
assert_eq!(
schema.execute(query).await.unwrap().data,
schema.execute(query).await.into_result().unwrap().data,
serde_json::json!({
"unionA": {
"valueA": 1,
@ -229,7 +229,7 @@ pub async fn test_multiple_objects_in_multiple_unions() {
}
}"#;
assert_eq!(
schema.execute(query).await.unwrap().data,
schema.execute(query).await.into_result().unwrap().data,
serde_json::json!({
"myObj": [{
"valueA": 1,
@ -276,7 +276,7 @@ pub async fn test_union_field_result() {
}"#;
let schema = Schema::new(Query, EmptyMutation, EmptySubscription);
assert_eq!(
schema.execute(query).await.unwrap().data,
schema.execute(query).await.into_result().unwrap().data,
serde_json::json!({
"node": {
"value": 10,

View File

@ -88,6 +88,7 @@ pub async fn test_variable_no_value() {
"#,
))
.await
.into_result()
.unwrap();
assert_eq!(
resp.data,