Fix Federation entity union is empty during schema introspection. #700

This commit is contained in:
Sunli 2021-11-13 09:08:55 +08:00
parent e6505951af
commit ba66e1406e
2 changed files with 15 additions and 3 deletions

View File

@ -480,7 +480,7 @@ impl Registry {
}
fn create_entity_type(&mut self) {
let possible_types = self
let possible_types: IndexSet<String> = self
.types
.values()
.filter_map(|ty| match ty {
@ -503,7 +503,19 @@ impl Registry {
MetaType::Union {
name: "_Entity".to_string(),
description: None,
union_values: Default::default(),
union_values: possible_types
.clone()
.into_iter()
.map(|ty| {
(
ty.clone(),
MetaUnionValue {
name: ty,
visible: None,
},
)
})
.collect(),
possible_types,
visible: None,
rust_typename: "async_graphql::federation::Entity",

View File

@ -265,7 +265,7 @@ pub async fn test_entity_union() {
#[Object]
impl Query {
#[graphql(entity)]
async fn find_obj(&self, id: i32) -> MyObj {
async fn find_obj(&self, _id: i32) -> MyObj {
todo!()
}
}