diff --git a/CHANGELOG.md b/CHANGELOG.md index 4543ba02..1d6e5614 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Implement `From>>` for `MaybeUndefined`. - Add `MaybeUndefined::as_opt_ref`, `MaybeUndefined::as_opt_deref`, `MaybeUndefined::map`, `MaybeUndefined::map_value`, `MaybeUndefined::contains`, `MaybeUndefined::contains_value`, and `MaybeUndefined::transpose` methods. - Made `MaybeUndefined::is_undefined`, `MaybeUndefined::is_null`, `MaybeUndefined::is_value`, `MaybeUndefined::value` and `MaybeUndefined::as_opt_ref` const. -- Add `Failure` type. [#671](https://github.com/async-graphql/async-graphql/issues/671) +- Add `ResolverError` type. [#671](https://github.com/async-graphql/async-graphql/issues/671) - [async-graphql-axum] Bump axum from `0.2.5` to `0.3`. - [async-graphql-poem] Export the HTTP headers in the `Context`. diff --git a/src/error.rs b/src/error.rs index 6c79bf40..871c7c61 100644 --- a/src/error.rs +++ b/src/error.rs @@ -27,9 +27,9 @@ impl ErrorExtensionValues { pub struct ServerError { /// An explanatory message of the error. pub message: String, - /// The concrete error type, comes from [`Failure`]. + /// The source of the error, comes from [`ResolverError`]. #[serde(skip)] - pub error: Option>, + pub source: Option>, /// Where the error occurred. #[serde(skip_serializing_if = "Vec::is_empty", default)] pub locations: Vec, @@ -70,28 +70,28 @@ impl ServerError { pub fn new(message: impl Into, pos: Option) -> Self { Self { message: message.into(), - error: None, + source: None, locations: pos.map(|pos| vec![pos]).unwrap_or_default(), path: Vec::new(), extensions: None, } } - /// Downcast the error object by reference. + /// Get the source of the error. /// /// # Examples /// /// ```rust /// use std::string::FromUtf8Error; - /// use async_graphql::{Failure, Error, ServerError, Pos}; + /// use async_graphql::{ResolverError, Error, ServerError, Pos}; /// /// let bytes = vec![0, 159]; - /// let err: Error = String::from_utf8(bytes).map_err(Failure::new).unwrap_err().into(); + /// let err: Error = String::from_utf8(bytes).map_err(ResolverError::new).unwrap_err().into(); /// let server_err: ServerError = err.into_server_error(Pos { line: 1, column: 1 }); - /// assert!(server_err.concrete_error::().is_some()); + /// assert!(server_err.source::().is_some()); /// ``` - pub fn concrete_error(&self) -> Option<&T> { - self.error.as_ref().map(|err| err.downcast_ref()).flatten() + pub fn source(&self) -> Option<&T> { + self.source.as_ref().map(|err| err.downcast_ref()).flatten() } #[doc(hidden)] @@ -116,7 +116,7 @@ impl From for ServerError { fn from(e: parser::Error) -> Self { Self { message: e.to_string(), - error: None, + source: None, locations: e.positions().collect(), path: Vec::new(), extensions: None, @@ -209,9 +209,9 @@ pub type InputValueResult = Result>; pub struct Error { /// The error message. pub message: String, - /// The concrete error type, comes from [`Failure`]. + /// The source of the error, comes from [`ResolverError`]. #[serde(skip)] - pub error: Option>, + pub source: Option>, /// Extensions to the error. #[serde(skip_serializing_if = "error_extensions_is_empty")] pub extensions: Option, @@ -237,7 +237,7 @@ impl Error { pub fn new(message: impl Into) -> Self { Self { message: message.into(), - error: None, + source: None, extensions: None, } } @@ -247,7 +247,7 @@ impl Error { pub fn into_server_error(self, pos: Pos) -> ServerError { ServerError { message: self.message, - error: self.error, + source: self.source, locations: vec![pos], path: Vec::new(), extensions: self.extensions, @@ -259,17 +259,17 @@ impl From for Error { fn from(e: T) -> Self { Self { message: e.to_string(), - error: None, + source: None, extensions: None, } } } -impl From for Error { - fn from(e: Failure) -> Self { +impl From for Error { + fn from(e: ResolverError) -> Self { Self { message: e.message, - error: Some(e.error), + source: Some(e.error), extensions: None, } } @@ -355,7 +355,7 @@ pub trait ErrorExtensions: Sized { let Error { message, - error, + source, extensions, } = self.extend(); @@ -364,7 +364,7 @@ pub trait ErrorExtensions: Sized { Error { message, - error, + source, extensions: Some(extensions), } } @@ -382,13 +382,13 @@ impl ErrorExtensions for &E { fn extend(self) -> Error { Error { message: self.to_string(), - error: None, + source: None, extensions: None, } } } -impl ErrorExtensions for Failure { +impl ErrorExtensions for ResolverError { #[inline] fn extend(self) -> Error { Error::from(self) @@ -430,14 +430,14 @@ where } } -/// A wrapper around a dynamic error type. +/// A wrapper around a dynamic error type for resolver. #[derive(Debug)] -pub struct Failure { +pub struct ResolverError { message: String, error: Arc, } -impl From for Failure { +impl From for ResolverError { fn from(err: T) -> Self { Self { message: err.to_string(), @@ -446,7 +446,7 @@ impl From for Failure { } } -impl Failure { +impl ResolverError { /// Create a new failure. #[inline] pub fn new(err: T) -> Self { diff --git a/src/lib.rs b/src/lib.rs index a65539fa..37da9c4d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -209,8 +209,8 @@ pub use base::{ Type, UnionType, }; pub use error::{ - Error, ErrorExtensionValues, ErrorExtensions, Failure, InputValueError, InputValueResult, - ParseRequestError, PathSegment, Result, ResultExt, ServerError, ServerResult, + Error, ErrorExtensionValues, ErrorExtensions, InputValueError, InputValueResult, + ParseRequestError, PathSegment, ResolverError, Result, ResultExt, ServerError, ServerResult, }; pub use look_ahead::Lookahead; pub use registry::CacheControl; diff --git a/src/validation/visitor.rs b/src/validation/visitor.rs index a44469f7..96c37717 100644 --- a/src/validation/visitor.rs +++ b/src/validation/visitor.rs @@ -851,7 +851,7 @@ impl From for ServerError { fn from(e: RuleError) -> Self { Self { message: e.message, - error: None, + source: None, locations: e.locations, path: Vec::new(), extensions: e.extensions, diff --git a/tests/error_ext.rs b/tests/error_ext.rs index b723f823..4ca56a19 100644 --- a/tests/error_ext.rs +++ b/tests/error_ext.rs @@ -92,23 +92,23 @@ pub async fn test_failure() { #[Object] impl Query { async fn failure(&self) -> Result { - Err(Failure::new(MyError::Error1).into()) + Err(ResolverError::new(MyError::Error1).into()) } async fn failure2(&self) -> Result { - Err(Failure::new(MyError::Error2))?; + Err(ResolverError::new(MyError::Error2))?; Ok(1) } async fn failure3(&self) -> Result { - Err(Failure::new(MyError::Error1) + Err(ResolverError::new(MyError::Error1) .extend_with(|_, values| values.set("a", 1)) .extend_with(|_, values| values.set("b", 2)))?; Ok(1) } async fn failure4(&self) -> Result { - Err(Failure::new(MyError::Error2)) + Err(ResolverError::new(MyError::Error2)) .extend_err(|_, values| values.set("a", 1)) .extend_err(|_, values| values.set("b", 2))?; Ok(1) @@ -122,7 +122,7 @@ pub async fn test_failure() { .into_result() .unwrap_err() .remove(0); - assert_eq!(err.concrete_error::().unwrap(), &MyError::Error1); + assert_eq!(err.source::().unwrap(), &MyError::Error1); let err = schema .execute("{ failure2 }") @@ -130,7 +130,7 @@ pub async fn test_failure() { .into_result() .unwrap_err() .remove(0); - assert_eq!(err.concrete_error::().unwrap(), &MyError::Error2); + assert_eq!(err.source::().unwrap(), &MyError::Error2); let err = schema .execute("{ failure3 }") @@ -138,7 +138,7 @@ pub async fn test_failure() { .into_result() .unwrap_err() .remove(0); - assert_eq!(err.concrete_error::().unwrap(), &MyError::Error1); + assert_eq!(err.source::().unwrap(), &MyError::Error1); assert_eq!( err.extensions, Some({ @@ -155,7 +155,7 @@ pub async fn test_failure() { .into_result() .unwrap_err() .remove(0); - assert_eq!(err.concrete_error::().unwrap(), &MyError::Error2); + assert_eq!(err.source::().unwrap(), &MyError::Error2); assert_eq!( err.extensions, Some({ @@ -179,7 +179,7 @@ pub async fn test_failure2() { #[Object] impl Query { - async fn failure(&self) -> Result { + async fn failure(&self) -> Result { Err(MyError::Error1)? } } diff --git a/tests/federation.rs b/tests/federation.rs index 33b6fdc9..d335ad91 100644 --- a/tests/federation.rs +++ b/tests/federation.rs @@ -242,7 +242,7 @@ pub async fn test_find_entity_with_context() { schema.execute(query).await.into_result().unwrap_err(), vec![ServerError { message: "Not found".to_string(), - error: None, + source: None, locations: vec![Pos { line: 2, column: 13 diff --git a/tests/field_features.rs b/tests/field_features.rs index ce10c995..0329cb47 100644 --- a/tests/field_features.rs +++ b/tests/field_features.rs @@ -85,7 +85,7 @@ pub async fn test_field_features() { vec![ServerError { message: r#"Unknown field "valueAbc" on type "QueryRoot". Did you mean "value"?"# .to_owned(), - error: None, + source: None, locations: vec![Pos { column: 3, line: 1 }], path: Vec::new(), extensions: None, @@ -114,7 +114,7 @@ pub async fn test_field_features() { vec![ServerError { message: r#"Unknown field "valueAbc" on type "MyObj". Did you mean "value"?"# .to_owned(), - error: None, + source: None, locations: vec![Pos { column: 9, line: 1 }], path: Vec::new(), extensions: None, @@ -150,7 +150,7 @@ pub async fn test_field_features() { .errors, vec![ServerError { message: r#"Unknown field "valuesAbc" on type "SubscriptionRoot". Did you mean "values", "valuesBson"?"#.to_owned(), - error: None, + source: None, locations: vec![Pos { column: 16, line: 1 diff --git a/tests/guard.rs b/tests/guard.rs index 7ef868c8..829eb586 100644 --- a/tests/guard.rs +++ b/tests/guard.rs @@ -99,7 +99,7 @@ pub async fn test_guard_simple_rule() { .unwrap_err(), vec![ServerError { message: "Forbidden".to_string(), - error: None, + source: None, locations: vec![Pos { line: 1, column: 3 }], path: vec![PathSegment::Field("value".to_owned())], extensions: None, @@ -128,7 +128,7 @@ pub async fn test_guard_simple_rule() { .errors, vec![ServerError { message: "Forbidden".to_string(), - error: None, + source: None, locations: vec![Pos { line: 1, column: 16 @@ -178,7 +178,7 @@ pub async fn test_guard_and_operator() { .unwrap_err(), vec![ServerError { message: "Forbidden".to_string(), - error: None, + source: None, locations: vec![Pos { line: 1, column: 3 }], path: vec![PathSegment::Field("value".to_owned())], extensions: None, @@ -198,7 +198,7 @@ pub async fn test_guard_and_operator() { .unwrap_err(), vec![ServerError { message: "Forbidden".to_string(), - error: None, + source: None, locations: vec![Pos { line: 1, column: 3 }], path: vec![PathSegment::Field("value".to_owned())], extensions: None, @@ -218,7 +218,7 @@ pub async fn test_guard_and_operator() { .unwrap_err(), vec![ServerError { message: "Forbidden".to_string(), - error: None, + source: None, locations: vec![Pos { line: 1, column: 3 }], path: vec![PathSegment::Field("value".to_owned())], extensions: None, @@ -288,7 +288,7 @@ pub async fn test_guard_or_operator() { .unwrap_err(), vec![ServerError { message: "Forbidden".to_string(), - error: None, + source: None, locations: vec![Pos { line: 1, column: 3 }], path: vec![PathSegment::Field("value".to_owned())], extensions: None, @@ -338,7 +338,7 @@ pub async fn test_guard_chain_operator() { .unwrap_err(), vec![ServerError { message: "Forbidden".to_string(), - error: None, + source: None, locations: vec![Pos { line: 1, column: 3 }], path: vec![PathSegment::Field("value".to_owned())], extensions: None, @@ -359,7 +359,7 @@ pub async fn test_guard_chain_operator() { .unwrap_err(), vec![ServerError { message: "Forbidden".to_string(), - error: None, + source: None, locations: vec![Pos { line: 1, column: 3 }], path: vec![PathSegment::Field("value".to_owned())], extensions: None, @@ -380,7 +380,7 @@ pub async fn test_guard_chain_operator() { .unwrap_err(), vec![ServerError { message: "Forbidden".to_string(), - error: None, + source: None, locations: vec![Pos { line: 1, column: 3 }], path: vec![PathSegment::Field("value".to_owned())], extensions: None, @@ -401,7 +401,7 @@ pub async fn test_guard_chain_operator() { .unwrap_err(), vec![ServerError { message: "Forbidden".to_string(), - error: None, + source: None, locations: vec![Pos { line: 1, column: 3 }], path: vec![PathSegment::Field("value".to_owned())], extensions: None, @@ -493,7 +493,7 @@ pub async fn test_guard_race_operator() { .unwrap_err(), vec![ServerError { message: "Forbidden".to_string(), - error: None, + source: None, locations: vec![Pos { line: 1, column: 3 }], path: vec![PathSegment::Field("value".to_owned())], extensions: None, @@ -549,7 +549,7 @@ pub async fn test_guard_use_params() { .unwrap_err(), vec![ServerError { message: "Forbidden".to_string(), - error: None, + source: None, locations: vec![Pos { line: 1, column: 3 }], path: vec![PathSegment::Field("get".to_owned())], extensions: None, diff --git a/tests/input_validators.rs b/tests/input_validators.rs index eb0cd1b6..6cbd9743 100644 --- a/tests/input_validators.rs +++ b/tests/input_validators.rs @@ -67,7 +67,7 @@ pub async fn test_input_validator_string_min_length() { .expect_err(&should_fail_msg), vec![ServerError { message: field_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 17 @@ -85,7 +85,7 @@ pub async fn test_input_validator_string_min_length() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: object_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 14 @@ -179,7 +179,7 @@ pub async fn test_input_validator_string_max_length() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: field_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 17 @@ -197,7 +197,7 @@ pub async fn test_input_validator_string_max_length() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: object_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 14 @@ -290,7 +290,7 @@ pub async fn test_input_validator_chars_min_length() { .expect_err(&should_fail_msg), vec![ServerError { message: field_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 17 @@ -308,7 +308,7 @@ pub async fn test_input_validator_chars_min_length() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: object_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 14 @@ -403,7 +403,7 @@ pub async fn test_input_validator_chars_max_length() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: field_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 17 @@ -421,7 +421,7 @@ pub async fn test_input_validator_chars_max_length() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: object_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 14 @@ -542,7 +542,7 @@ pub async fn test_input_validator_string_email() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: field_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 17 @@ -561,7 +561,7 @@ pub async fn test_input_validator_string_email() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: object_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 14 @@ -692,7 +692,7 @@ pub async fn test_input_validator_string_mac() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: field_error_msg.clone(), - error: None, + source: None, locations: vec!(Pos { line: 1, column: 17 @@ -711,7 +711,7 @@ pub async fn test_input_validator_string_mac() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: object_error_msg.clone(), - error: None, + source: None, locations: vec!(Pos { line: 1, column: 14 @@ -729,7 +729,7 @@ pub async fn test_input_validator_string_mac() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: field_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 17 @@ -748,7 +748,7 @@ pub async fn test_input_validator_string_mac() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: object_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 14 @@ -806,7 +806,7 @@ pub async fn test_input_validator_string_mac() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: field_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 17 @@ -825,7 +825,7 @@ pub async fn test_input_validator_string_mac() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: object_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 14 @@ -867,7 +867,7 @@ pub async fn test_input_validator_string_mac() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: field_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 17 @@ -886,7 +886,7 @@ pub async fn test_input_validator_string_mac() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: object_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 14 @@ -947,7 +947,7 @@ pub async fn test_input_validator_int_range() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: field_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 17 @@ -965,7 +965,7 @@ pub async fn test_input_validator_int_range() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: object_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 14 @@ -1054,7 +1054,7 @@ pub async fn test_input_validator_int_less_than() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: field_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 17 @@ -1072,7 +1072,7 @@ pub async fn test_input_validator_int_less_than() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: object_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 14 @@ -1163,7 +1163,7 @@ pub async fn test_input_validator_int_greater_than() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: field_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 17 @@ -1181,7 +1181,7 @@ pub async fn test_input_validator_int_greater_than() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: object_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 14 @@ -1265,7 +1265,7 @@ pub async fn test_input_validator_int_nonzero() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: field_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 17 @@ -1283,7 +1283,7 @@ pub async fn test_input_validator_int_nonzero() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: object_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 14 @@ -1371,7 +1371,7 @@ pub async fn test_input_validator_int_equal() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: field_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 17 @@ -1389,7 +1389,7 @@ pub async fn test_input_validator_int_equal() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: object_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 14 @@ -1489,7 +1489,7 @@ pub async fn test_input_validator_list_max_length() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: field_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 17 @@ -1507,7 +1507,7 @@ pub async fn test_input_validator_list_max_length() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: object_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 14 @@ -1607,7 +1607,7 @@ pub async fn test_input_validator_list_min_length() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: field_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 17 @@ -1625,7 +1625,7 @@ pub async fn test_input_validator_list_min_length() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: object_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 14 @@ -1733,7 +1733,7 @@ pub async fn test_input_validator_operator_or() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: field_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 17 @@ -1751,7 +1751,7 @@ pub async fn test_input_validator_operator_or() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: object_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 14 @@ -1852,7 +1852,7 @@ pub async fn test_input_validator_operator_and() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: field_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 17 @@ -1870,7 +1870,7 @@ pub async fn test_input_validator_operator_and() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: object_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 14 @@ -1974,7 +1974,7 @@ pub async fn test_input_validator_variable() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: field_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 37 @@ -1992,7 +1992,7 @@ pub async fn test_input_validator_variable() { .expect_err(&should_fail_msg[..]), vec![ServerError { message: object_error_msg, - error: None, + source: None, locations: vec!(Pos { line: 1, column: 34 @@ -2079,7 +2079,7 @@ pub async fn test_custom_input_validator_with_extensions() { .expect_err(should_fail_msg), vec![ServerError { message: field_error_msg.into(), - error: None, + source: None, locations: vec!(Pos { line: 1, column: 17 diff --git a/tests/input_value.rs b/tests/input_value.rs index 1387f042..6ea3f871 100644 --- a/tests/input_value.rs +++ b/tests/input_value.rs @@ -18,7 +18,7 @@ pub async fn test_input_value_custom_error() { vec![ServerError { message: "Failed to parse \"Int\": Only integers from -128 to 127 are accepted." .to_owned(), - error: None, + source: None, locations: vec![Pos { line: 1, column: 14, diff --git a/tests/list.rs b/tests/list.rs index de2afe98..90a62a09 100644 --- a/tests/list.rs +++ b/tests/list.rs @@ -167,7 +167,7 @@ pub async fn test_array_type() { vec![ServerError { message: r#"Failed to parse "[Int!]": Expected input type "[Int; 6]", found [Int; 5]."# .to_owned(), - error: None, + source: None, locations: vec![Pos { line: 1, column: 22, diff --git a/tests/result.rs b/tests/result.rs index 2487cc22..c4608ae9 100644 --- a/tests/result.rs +++ b/tests/result.rs @@ -34,14 +34,14 @@ pub async fn test_fieldresult() { errors: vec![ ServerError { message: "TestError".to_string(), - error: None, + source: None, locations: vec![Pos { line: 1, column: 3 }], path: vec![PathSegment::Field("error1".to_owned())], extensions: None, }, ServerError { message: "TestError".to_string(), - error: None, + source: None, locations: vec![Pos { line: 1, column: 19, @@ -62,7 +62,7 @@ pub async fn test_fieldresult() { .unwrap_err(), vec![ServerError { message: "TestError".to_string(), - error: None, + source: None, locations: vec![Pos { line: 1, column: 3 }], path: vec![PathSegment::Field("optError".to_owned())], extensions: None, @@ -77,7 +77,7 @@ pub async fn test_fieldresult() { .unwrap_err(), vec![ServerError { message: "TestError".to_string(), - error: None, + source: None, locations: vec![Pos { line: 1, column: 3 }], path: vec![ PathSegment::Field("vecError".to_owned()), @@ -192,7 +192,7 @@ pub async fn test_error_propagation() { cache_control: Default::default(), errors: vec![ServerError { message: "myerror".to_string(), - error: None, + source: None, locations: vec![Pos { line: 1, column: 20, @@ -220,7 +220,7 @@ pub async fn test_error_propagation() { cache_control: Default::default(), errors: vec![ServerError { message: "myerror".to_string(), - error: None, + source: None, locations: vec![Pos { line: 1, column: 23, @@ -244,7 +244,7 @@ pub async fn test_error_propagation() { cache_control: Default::default(), errors: vec![ServerError { message: "myerror".to_string(), - error: None, + source: None, locations: vec![Pos { line: 1, column: 23, @@ -274,7 +274,7 @@ pub async fn test_error_propagation() { cache_control: Default::default(), errors: vec![ServerError { message: "myerror".to_string(), - error: None, + source: None, locations: vec![Pos { line: 1, column: 23, diff --git a/tests/subscription.rs b/tests/subscription.rs index e948a5a6..750c9405 100644 --- a/tests/subscription.rs +++ b/tests/subscription.rs @@ -345,7 +345,7 @@ pub async fn test_subscription_error() { stream.next().await, Some(Err(vec![ServerError { message: "TestError".to_string(), - error: None, + source: None, locations: vec![Pos { line: 1, column: 25 @@ -391,7 +391,7 @@ pub async fn test_subscription_fieldresult() { cache_control: Default::default(), errors: vec![ServerError { message: "StreamErr".to_string(), - error: None, + source: None, locations: vec![Pos { line: 1, column: 16