Fix input_objects api so it won't return empty objects
@@ -373,30 +373,79 @@ impl Schema for SchemaWrapper {
}
fn input_objects<'a>(&'a self) -> Box<dyn Iterator<Item = &'a InputObject> + 'a> {
+ if self.input_objects.map.is_empty() {
+ for i in 0..self.flatbuffer_schema().input_objects.len() {
+ let id = InputObjectID(i.try_into().unwrap());
+ self.input_object(id);
+ }
+ }
+
Box::new(self.input_objects.map.iter().map(|ref_| *ref_.value()))
}
fn enums<'a>(&'a self) -> Box<dyn Iterator<Item = &'a Enum> + 'a> {
+ if self.enums.map.is_empty() {
+ for i in 0..self.flatbuffer_schema().enums.len() {
+ let id = EnumID(i.try_into().unwrap());
+ self.enum_(id);
+ }
+ }
+
Box::new(self.enums.map.iter().map(|ref_| *ref_.value()))
}
fn scalars<'a>(&'a self) -> Box<dyn Iterator<Item = &'a Scalar> + 'a> {
+ if self.scalars.map.is_empty() {
+ for i in 0..self.flatbuffer_schema().scalars.len() {
+ let id = ScalarID(i.try_into().unwrap());
+ self.scalar(id);
+ }
+ }
+
Box::new(self.scalars.map.iter().map(|ref_| *ref_.value()))
}
fn fields<'a>(&'a self) -> Box<dyn Iterator<Item = &'a Field> + 'a> {
+ if self.fields.map.is_empty() {
+ for i in 0..self.flatbuffer_schema().fields.len() {
+ let id = FieldID(i.try_into().unwrap());
+ self.field(id);
+ }
+ }
+
Box::new(self.fields.map.iter().map(|ref_| *ref_.value()))
}
fn objects<'a>(&'a self) -> Box<dyn Iterator<Item = &'a Object> + 'a> {
+ if self.objects.map.is_empty() {
+ for i in 0..self.flatbuffer_schema().objects.len() {
+ let id = ObjectID(i.try_into().unwrap());
+ self.object(id);
+ }
+ }
+
Box::new(self.objects.map.iter().map(|ref_| *ref_.value()))
}
fn unions<'a>(&'a self) -> Box<dyn Iterator<Item = &'a Union> + 'a> {
+ if self.unions.map.is_empty() {
+ for i in 0..self.flatbuffer_schema().unions.len() {
+ let id = UnionID(i.try_into().unwrap());
+ self.union(id);
+ }
+ }
+
Box::new(self.unions.map.iter().map(|ref_| *ref_.value()))
}
fn interfaces<'a>(&'a self) -> Box<dyn Iterator<Item = &'a Interface> + 'a> {
+ if self.interfaces.map.is_empty() {
+ for i in 0..self.flatbuffer_schema().interfaces.len() {
+ let id = InterfaceID(i.try_into().unwrap());
+ self.interface(id);
+ }
+ }
+
Box::new(self.interfaces.map.iter().map(|ref_| *ref_.value()))
}
}
