graphql: add is_derived in DirectiveFinder and its implementors
@@ -250,6 +250,7 @@ impl ValueExt for Value {
pub trait DirectiveFinder {
fn find_directive(&self, name: &str) -> Option<&Directive>;
+ fn is_derived(&self) -> bool;
}
impl DirectiveFinder for ObjectType {
@@ -258,6 +259,12 @@ impl DirectiveFinder for ObjectType {
.iter()
.find(|directive| directive.name.eq(&name))
}
+
+ fn is_derived(&self) -> bool {
+ let is_derived = |directive: &Directive| directive.name.eq("derivedFrom");
+
+ self.directives.iter().any(is_derived)
+ }
}
impl DirectiveFinder for Field {
@@ -266,10 +273,22 @@ impl DirectiveFinder for Field {
.iter()
.find(|directive| directive.name.eq(name))
}
+
+ fn is_derived(&self) -> bool {
+ let is_derived = |directive: &Directive| directive.name.eq("derivedFrom");
+
+ self.directives.iter().any(is_derived)
+ }
}
impl DirectiveFinder for Vec<Directive> {
fn find_directive(&self, name: &str) -> Option<&Directive> {
self.iter().find(|directive| directive.name.eq(&name))
}
+
+ fn is_derived(&self) -> bool {
+ let is_derived = |directive: &Directive| directive.name.eq("derivedFrom");
+
+ self.iter().any(is_derived)
+ }
}
