use super::super::super::ir_collection::{
element_type_at_path, has_non_string_scalar_elements_at_path, is_collection_path,
};
use super::super::super::types::FieldResolver;
impl FieldResolver {
pub fn is_collection_root(&self, field: &str) -> bool {
let prefix = format!("{field}[");
if self.array_fields.iter().any(|af| af.starts_with(&prefix))
|| self.optional_fields.iter().any(|of| of.starts_with(&prefix))
{
return true;
}
let resolved = self.resolve(field);
is_collection_path(&self.ir_collection_map, resolved)
}
pub fn collection_element_type(&self, field: &str) -> Option<String> {
let resolved = self.resolve(field);
element_type_at_path(&self.ir_collection_map, resolved)
}
pub fn collection_element_is_non_string_scalar(&self, field: &str) -> bool {
let resolved = self.resolve(field);
has_non_string_scalar_elements_at_path(
&self.ir_collection_map,
&self.non_string_scalar_collection_fields,
resolved,
)
}
}