From 93502dfffa94e5e4ed53c8bd4262d0eca54aa27d Mon Sep 17 00:00:00 2001 From: Sunli Date: Sat, 13 Nov 2021 09:05:29 +0800 Subject: [PATCH] Add test_entity_union --- tests/federation.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/tests/federation.rs b/tests/federation.rs index d335ad91..a57fc48c 100644 --- a/tests/federation.rs +++ b/tests/federation.rs @@ -252,3 +252,36 @@ pub async fn test_find_entity_with_context() { }] ); } + +#[tokio::test] +pub async fn test_entity_union() { + #[derive(SimpleObject)] + struct MyObj { + a: i32, + } + + struct Query; + + #[Object] + impl Query { + #[graphql(entity)] + async fn find_obj(&self, id: i32) -> MyObj { + todo!() + } + } + + let schema = Schema::new(Query, EmptyMutation, EmptySubscription); + let query = r#"{ + __type(name: "_Entity") { possibleTypes { name } } + }"#; + assert_eq!( + schema.execute(query).await.into_result().unwrap().data, + value!({ + "__type": { + "possibleTypes": [ + {"name": "MyObj"}, + ] + } + }) + ); +}