Skip to content

Commit

Permalink
Add test regarding inline fragments with type condition on interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
LukasKalbertodt committed Dec 9, 2020
1 parent 1fcea24 commit 4c9071c
Showing 1 changed file with 66 additions and 0 deletions.
66 changes: 66 additions & 0 deletions juniper/src/tests/query_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<Database>::new(),
EmptySubscription::<Database>::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![]
))
);
}

0 comments on commit 4c9071c

Please sign in to comment.