Add `SchemaBuilder::enable_subscription_in_federation` method. #449
This commit is contained in:
parent
ed620698a6
commit
6e2fe32be0
|
@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
|||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
||||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [2.6.2] - 2021-03-20
|
||||
|
||||
- Add `SchemaBuilder::enable_subscription_in_federation` method. [#449](https://github.com/async-graphql/async-graphql/issues/449)
|
||||
|
||||
## [2.6.1] - 2021-03-19
|
||||
|
||||
Fix tracing extension doesn't work with async code. [#448](https://github.com/async-graphql/async-graphql/issues/448)
|
||||
|
|
|
@ -116,6 +116,12 @@ impl Registry {
|
|||
return;
|
||||
}
|
||||
|
||||
if let Some(subscription_type) = &self.subscription_type {
|
||||
if name == subscription_type && !self.federation_subscription {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if description.is_some() {
|
||||
writeln!(sdl, "\"\"\"\n{}\n\"\"\"", description.unwrap()).ok();
|
||||
}
|
||||
|
|
|
@ -341,6 +341,7 @@ pub struct Registry {
|
|||
pub subscription_type: Option<String>,
|
||||
pub disable_introspection: bool,
|
||||
pub enable_federation: bool,
|
||||
pub federation_subscription: bool,
|
||||
}
|
||||
|
||||
impl Registry {
|
||||
|
|
|
@ -105,6 +105,14 @@ impl<Query, Mutation, Subscription> SchemaBuilder<Query, Mutation, Subscription>
|
|||
self
|
||||
}
|
||||
|
||||
/// Make the Federation SDL include subscriptions.
|
||||
///
|
||||
/// Note: Not included by default, in order to be compatible with Apollo Server.
|
||||
pub fn enable_subscription_in_federation(mut self) -> Self {
|
||||
self.registry.federation_subscription = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// Override the name of the specified type.
|
||||
pub fn override_description<T: Type>(mut self, desc: &'static str) -> Self {
|
||||
self.registry.set_description::<T>(desc);
|
||||
|
@ -251,6 +259,7 @@ where
|
|||
},
|
||||
disable_introspection: false,
|
||||
enable_federation: false,
|
||||
federation_subscription: false,
|
||||
};
|
||||
|
||||
registry.add_directive(MetaDirective {
|
||||
|
|
Loading…
Reference in New Issue