Add SchemaBuilder::override_description
function.
This commit is contained in:
parent
b3ac34a372
commit
e34f1351bd
|
@ -522,4 +522,16 @@ impl Registry {
|
||||||
|
|
||||||
names.into_iter().collect()
|
names.into_iter().collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn set_description<T: Type>(&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 => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -106,6 +106,12 @@ impl<Query, Mutation, Subscription> SchemaBuilder<Query, Mutation, Subscription>
|
||||||
self
|
self
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Override the description of the specified type.
|
||||||
|
pub fn override_description<T: Type>(mut self, desc: &'static str) -> Self {
|
||||||
|
self.registry.set_description::<T>(desc);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
/// Build schema.
|
/// Build schema.
|
||||||
pub fn finish(mut self) -> Schema<Query, Mutation, Subscription> {
|
pub fn finish(mut self) -> Schema<Query, Mutation, Subscription> {
|
||||||
// federation
|
// federation
|
||||||
|
|
Loading…
Reference in New Issue
Block a user