Consider also testing spreading interface fragment on interface (#922)

This commit is contained in:
tyranron 2023-02-27 18:10:51 +02:00
parent 42420c7ee1
commit e569476bcc
No known key found for this signature in database
GPG key ID: 762E144FB230A4F0

View file

@ -48,7 +48,7 @@ struct Droid {
type Schema = juniper::RootNode<'static, Query, EmptyMutation, EmptySubscription>;
#[tokio::test]
async fn fragment_on_interface() {
async fn object_fragment_on_interface() {
let query = r#"
query Query {
characters {
@ -100,3 +100,53 @@ async fn fragment_on_interface() {
}),
);
}
#[tokio::test]
async fn interface_fragment_on_interface() {
let query = r#"
query Query {
characters {
...CharacterFragment
}
}
fragment CharacterFragment on Character {
__typename
... on Character {
id
name
}
}
"#;
let schema = Schema::new(Query, EmptyMutation::new(), EmptySubscription::new());
let (res, errors) = juniper::execute(query, None, &schema, &graphql_vars! {}, &())
.await
.unwrap();
assert_eq!(errors.len(), 0);
assert_eq!(
res,
graphql_value!({
"characters": [
{"__typename": "Human", "id": 0, "name": "human-32"},
{"__typename": "Droid", "id": 1, "name": "R2-D2"},
],
}),
);
let (res, errors) =
juniper::execute_sync(query, None, &schema, &graphql_vars! {}, &()).unwrap();
assert_eq!(errors.len(), 0);
assert_eq!(
res,
graphql_value!({
"characters": [
{"__typename": "Human", "id": 0, "name": "human-32"},
{"__typename": "Droid", "id": 1, "name": "R2-D2"},
],
}),
);
}