This commit is contained in:
sunli 2020-03-30 11:32:19 +08:00
parent daf0665a18
commit eebb5ac119

View File

@ -79,8 +79,7 @@ pub fn is_valid_input_value(
registry::Type::InputObject { input_fields, .. } => match value {
Value::Object(values) => {
for field in input_fields {
let value = values.get(field.name).unwrap_or(&Value::Null);
if let Some(value) = values.get(field.name) {
if let Some(validator) = &field.validator {
if let Some(reason) = validator.is_valid(value) {
return Some(valid_error(
@ -104,6 +103,18 @@ pub fn is_valid_input_value(
) {
return Some(reason);
}
} else if registry::TypeName::create(&field.ty).is_non_null()
&& field.default_value.is_none()
{
return Some(valid_error(
&path_node,
format!(
"field \"{}\" of type \"{}\" is required but not provided",
field.name,
ty.name(),
),
));
}
}
None
}