diff --git a/src/registry/mod.rs b/src/registry/mod.rs index 5793388e..0b833a77 100644 --- a/src/registry/mod.rs +++ b/src/registry/mod.rs @@ -522,4 +522,16 @@ impl Registry { names.into_iter().collect() } + + pub fn set_description(&mut self, desc: &'static str) { + match self.types.get_mut(&*T::type_name()) { + Some(MetaType::Scalar { description, .. }) => *description = Some(desc), + Some(MetaType::Object { description, .. }) => *description = Some(desc), + Some(MetaType::Interface { description, .. }) => *description = Some(desc), + Some(MetaType::Union { description, .. }) => *description = Some(desc), + Some(MetaType::Enum { description, .. }) => *description = Some(desc), + Some(MetaType::InputObject { description, .. }) => *description = Some(desc), + None => {} + } + } } diff --git a/src/schema.rs b/src/schema.rs index f744b5ed..17e7f130 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -106,6 +106,12 @@ impl SchemaBuilder self } + /// Override the description of the specified type. + pub fn override_description(mut self, desc: &'static str) -> Self { + self.registry.set_description::(desc); + self + } + /// Build schema. pub fn finish(mut self) -> Schema { // federation