Fix the problem when generating Federation SDL. #283
This commit is contained in:
parent
397650bb0d
commit
e9efad4479
|
@ -115,8 +115,14 @@ impl Registry {
|
||||||
description,
|
description,
|
||||||
..
|
..
|
||||||
} => {
|
} => {
|
||||||
if name == &self.query_type && self.is_empty_query {
|
if name == &self.query_type {
|
||||||
return;
|
if federation && fields.len() <= 4 {
|
||||||
|
// Is empty query root, only __schema, __type, _service, _entities fields
|
||||||
|
return;
|
||||||
|
} else if !federation && fields.len() <= 2 {
|
||||||
|
// Is empty query root, only __schema, __type
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(subscription_type) = &self.subscription_type {
|
if let Some(subscription_type) = &self.subscription_type {
|
||||||
|
|
|
@ -257,7 +257,6 @@ pub struct Registry {
|
||||||
pub directives: HashMap<String, MetaDirective>,
|
pub directives: HashMap<String, MetaDirective>,
|
||||||
pub implements: HashMap<String, HashSet<String>>,
|
pub implements: HashMap<String, HashSet<String>>,
|
||||||
pub query_type: String,
|
pub query_type: String,
|
||||||
pub is_empty_query: bool,
|
|
||||||
pub mutation_type: Option<String>,
|
pub mutation_type: Option<String>,
|
||||||
pub subscription_type: Option<String>,
|
pub subscription_type: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,12 +214,11 @@ where
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn create_registry() -> Registry {
|
pub fn create_registry() -> Registry {
|
||||||
let mut registry = Registry {
|
let mut registry = Registry {
|
||||||
types: Default::default(),
|
types: Default::default(),
|
||||||
directives: Default::default(),
|
directives: Default::default(),
|
||||||
implements: Default::default(),
|
implements: Default::default(),
|
||||||
is_empty_query: Query::is_empty(),
|
|
||||||
query_type: Query::type_name().to_string(),
|
query_type: Query::type_name().to_string(),
|
||||||
mutation_type: if Mutation::is_empty() {
|
mutation_type: if Mutation::is_empty() {
|
||||||
None
|
None
|
||||||
|
|
Loading…
Reference in New Issue
Block a user