diff --git a/juniper/src/tests/query_tests.rs b/juniper/src/tests/query_tests.rs index d671c5bf6..f5b7757dd 100644 --- a/juniper/src/tests/query_tests.rs +++ b/juniper/src/tests/query_tests.rs @@ -731,3 +731,69 @@ async fn test_object_typename() { )) ); } + +#[tokio::test] +async fn interface_inline_fragment_friends() { + let doc = r#"{ + human(id: "1002") { + friends { + name + ... on Human { homePlanet } + ... on Droid { primaryFunction } + } + } + }"#; + let database = Database::new(); + let schema = RootNode::new( + Query, + EmptyMutation::::new(), + EmptySubscription::::new(), + ); + + assert_eq!( + crate::execute(doc, None, &schema, &Variables::new(), &database).await, + Ok(( + Value::object( + vec![( + "human", + Value::object( + vec![( + "friends", + Value::list(vec![ + Value::object( + vec![ + ("name", Value::scalar("Luke Skywalker")), + ("homePlanet", Value::scalar("Tatooine")), + ] + .into_iter() + .collect(), + ), + Value::object( + vec![ + ("name", Value::scalar("Leia Organa")), + ("homePlanet", Value::scalar("Alderaan")), + ] + .into_iter() + .collect(), + ), + Value::object( + vec![ + ("name", Value::scalar("R2-D2")), + ("primaryFunction", Value::scalar("Astromech")), + ] + .into_iter() + .collect(), + ), + ]), + )] + .into_iter() + .collect(), + ), + )] + .into_iter() + .collect() + ), + vec![] + )) + ); +}