Add another test for null handling in lists
This commit is contained in:
parent
d0e9202f41
commit
23105259de
1 changed files with 49 additions and 2 deletions
|
@ -452,6 +452,7 @@ mod propagates_errors_to_nullable_fields {
|
|||
graphql_object!(Schema: () |&self| {
|
||||
field inner() -> Inner { Inner }
|
||||
field inners() -> Vec<Inner> { (0..5).map(|_| Inner).collect() }
|
||||
field nullable_inners() -> Vec<Option<Inner>> { (0..5).map(|_| Some(Inner)).collect() }
|
||||
});
|
||||
|
||||
graphql_object!(Inner: () |&self| {
|
||||
|
@ -610,8 +611,54 @@ mod propagates_errors_to_nullable_fields {
|
|||
errs,
|
||||
vec![
|
||||
ExecutionError::new(
|
||||
SourcePosition::new(10, 0, 10),
|
||||
&["inner", "nonNullableErrorField"],
|
||||
SourcePosition::new(11, 0, 11),
|
||||
&["inners", "nonNullableErrorField"],
|
||||
FieldError::new("Error for nonNullableErrorField", Value::null()),
|
||||
),
|
||||
]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn non_null_list_of_nullable() {
|
||||
let schema = RootNode::new(Schema, EmptyMutation::<()>::new());
|
||||
let doc = r"{ nullableInners { nonNullableErrorField } }";
|
||||
|
||||
let vars = vec![].into_iter().collect();
|
||||
|
||||
let (result, errs) = ::execute(doc, None, &schema, &vars, &()).expect("Execution failed");
|
||||
|
||||
println!("Result: {:?}", result);
|
||||
|
||||
assert_eq!(
|
||||
result,
|
||||
graphql_value!({ "nullableInners": [None, None, None, None, None] }));
|
||||
|
||||
assert_eq!(
|
||||
errs,
|
||||
vec![
|
||||
ExecutionError::new(
|
||||
SourcePosition::new(19, 0, 19),
|
||||
&["nullableInners", "nonNullableErrorField"],
|
||||
FieldError::new("Error for nonNullableErrorField", Value::null()),
|
||||
),
|
||||
ExecutionError::new(
|
||||
SourcePosition::new(19, 0, 19),
|
||||
&["nullableInners", "nonNullableErrorField"],
|
||||
FieldError::new("Error for nonNullableErrorField", Value::null()),
|
||||
),
|
||||
ExecutionError::new(
|
||||
SourcePosition::new(19, 0, 19),
|
||||
&["nullableInners", "nonNullableErrorField"],
|
||||
FieldError::new("Error for nonNullableErrorField", Value::null()),
|
||||
),
|
||||
ExecutionError::new(
|
||||
SourcePosition::new(19, 0, 19),
|
||||
&["nullableInners", "nonNullableErrorField"],
|
||||
FieldError::new("Error for nonNullableErrorField", Value::null()),
|
||||
),
|
||||
ExecutionError::new(
|
||||
SourcePosition::new(19, 0, 19),
|
||||
&["nullableInners", "nonNullableErrorField"],
|
||||
FieldError::new("Error for nonNullableErrorField", Value::null()),
|
||||
),
|
||||
]);
|
||||
|
|
Loading…
Reference in a new issue