This commit is contained in:
Sunli 2022-05-06 09:28:57 +08:00
parent de4f908812
commit 96e423ff31
2 changed files with 8 additions and 4 deletions

View File

@ -33,8 +33,8 @@ pub enum MetaTypeName<'a> {
Named(&'a str), Named(&'a str),
} }
impl<'a> std::fmt::Display for MetaTypeName<'a> { impl<'a> Display for MetaTypeName<'a> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut Formatter<'_>) -> fmt::Result {
match self { match self {
MetaTypeName::Named(name) => write!(f, "{}", name), MetaTypeName::Named(name) => write!(f, "{}", name),
MetaTypeName::NonNull(name) => write!(f, "{}!", name), MetaTypeName::NonNull(name) => write!(f, "{}!", name),
@ -388,7 +388,7 @@ impl MetaType {
pub struct MetaDirective { pub struct MetaDirective {
pub name: &'static str, pub name: &'static str,
pub description: Option<&'static str>, pub description: Option<&'static str>,
pub locations: Vec<model::__DirectiveLocation>, pub locations: Vec<__DirectiveLocation>,
pub args: IndexMap<String, MetaInputValue>, pub args: IndexMap<String, MetaInputValue>,
pub is_repeatable: bool, pub is_repeatable: bool,
pub visible: Option<MetaVisibleFn>, pub visible: Option<MetaVisibleFn>,

View File

@ -69,7 +69,11 @@ pub fn is_valid_input_value(
return None; return None;
} }
match registry.types.get(type_name).unwrap() { match registry
.types
.get(type_name)
.unwrap_or_else(|| panic!("Type `{}` not defined", type_name))
{
registry::MetaType::Scalar { is_valid, .. } => { registry::MetaType::Scalar { is_valid, .. } => {
if is_valid(&value) { if is_valid(&value) {
None None