Backport accepting explicit null argument for nullable list input parameter (#1086, #1085)

This commit is contained in:
tyranron 2022-07-22 10:12:42 +02:00
parent 82761736ce
commit c650713997
No known key found for this signature in database
GPG key ID: 762E144FB230A4F0
4 changed files with 38 additions and 2 deletions

View file

@ -1,6 +1,6 @@
# master
- No changes yet
- Fix incorrect error when explicit `null` provided for `null`able list input parameter. ([#1086](https://github.com/graphql-rust/juniper/pull/1086))
# [[0.15.9] 2022-02-02](https://github.com/graphql-rust/juniper/releases/tag/juniper-v0.15.9)

View file

@ -25,6 +25,7 @@ where
}
}
TypeType::List(ref inner) => match *arg_value {
InputValue::Null | InputValue::Variable(_) => true,
InputValue::List(ref items) => items
.iter()
.all(|i| is_valid_literal_value(schema, inner, &i.item)),

View file

@ -85,7 +85,7 @@ mod tests {
};
#[test]
fn good_null_value() {
fn null_into_nullable_int() {
expect_passes_rule::<_, _, DefaultScalarValue>(
factory,
r#"
@ -98,6 +98,20 @@ mod tests {
);
}
#[test]
fn null_into_nullable_list() {
expect_passes_rule::<_, _, DefaultScalarValue>(
factory,
r#"
{
complicatedArgs {
stringListArgField(stringListArg: null)
}
}
"#,
);
}
#[test]
fn null_into_int() {
expect_fails_rule::<_, _, DefaultScalarValue>(
@ -116,6 +130,24 @@ mod tests {
);
}
#[test]
fn null_into_list() {
expect_fails_rule::<_, _, DefaultScalarValue>(
factory,
r#"
{
complicatedArgs {
nonNullStringListArgField(nonNullStringListArg: null)
}
}
"#,
&[RuleError::new(
&error_message("nonNullStringListArg", "[String!]!"),
&[SourcePosition::new(111, 3, 64)],
)],
);
}
#[test]
fn good_int_value() {
expect_passes_rule::<_, _, DefaultScalarValue>(

View file

@ -666,6 +666,9 @@ where
registry
.field::<Option<String>>("stringListArgField", i)
.argument(registry.arg::<Option<Vec<Option<String>>>>("stringListArg", i)),
registry
.field::<Option<String>>("nonNullStringListArgField", i)
.argument(registry.arg::<Vec<String>>("nonNullStringListArg", i)),
registry
.field::<Option<String>>("complexArgField", i)
.argument(registry.arg::<Option<ComplexInput>>("complexArg", i)),