1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
use crate::model::{__InputValue, __Type}; use crate::registry; use async_graphql_derive::Object; pub struct __Field<'a> { pub registry: &'a registry::Registry, pub field: &'a registry::Field, } #[Object( internal, desc = "Object and Interface types are described by a list of Fields, each of which has a name, potentially a list of arguments, and a return type." )] impl<'a> __Field<'a> { #[field] async fn name(&self) -> String { self.field.name.to_string() } #[field] async fn description(&self) -> Option<String> { self.field.description.map(|s| s.to_string()) } #[field] async fn args(&self) -> Vec<__InputValue<'a>> { self.field .args .values() .map(|input_value| __InputValue { registry: self.registry, input_value, }) .collect() } #[field(name = "type")] async fn ty(&self) -> __Type<'a> { __Type::new(self.registry, &self.field.ty) } #[field(name = "isDeprecated")] async fn is_deprecated(&self) -> bool { self.field.deprecation.is_some() } #[field(name = "deprecationReason")] async fn deprecation_reason(&self) -> Option<String> { self.field.deprecation.map(|s| s.to_string()) } }