Skip to content

Commit 4c9071c

Browse files
Add test regarding inline fragments with type condition on interfaces
1 parent 1fcea24 commit 4c9071c

File tree

1 file changed

+66
-0
lines changed

1 file changed

+66
-0
lines changed

juniper/src/tests/query_tests.rs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -731,3 +731,69 @@ async fn test_object_typename() {
731731
))
732732
);
733733
}
734+
735+
#[tokio::test]
736+
async fn interface_inline_fragment_friends() {
737+
let doc = r#"{
738+
human(id: "1002") {
739+
friends {
740+
name
741+
... on Human { homePlanet }
742+
... on Droid { primaryFunction }
743+
}
744+
}
745+
}"#;
746+
let database = Database::new();
747+
let schema = RootNode::new(
748+
Query,
749+
EmptyMutation::<Database>::new(),
750+
EmptySubscription::<Database>::new(),
751+
);
752+
753+
assert_eq!(
754+
crate::execute(doc, None, &schema, &Variables::new(), &database).await,
755+
Ok((
756+
Value::object(
757+
vec![(
758+
"human",
759+
Value::object(
760+
vec![(
761+
"friends",
762+
Value::list(vec![
763+
Value::object(
764+
vec![
765+
("name", Value::scalar("Luke Skywalker")),
766+
("homePlanet", Value::scalar("Tatooine")),
767+
]
768+
.into_iter()
769+
.collect(),
770+
),
771+
Value::object(
772+
vec![
773+
("name", Value::scalar("Leia Organa")),
774+
("homePlanet", Value::scalar("Alderaan")),
775+
]
776+
.into_iter()
777+
.collect(),
778+
),
779+
Value::object(
780+
vec![
781+
("name", Value::scalar("R2-D2")),
782+
("primaryFunction", Value::scalar("Astromech")),
783+
]
784+
.into_iter()
785+
.collect(),
786+
),
787+
]),
788+
)]
789+
.into_iter()
790+
.collect(),
791+
),
792+
)]
793+
.into_iter()
794+
.collect()
795+
),
796+
vec![]
797+
))
798+
);
799+
}

0 commit comments

Comments
 (0)