Consider also testing spreading interface fragment on interface (#922)
This commit is contained in:
parent
42420c7ee1
commit
e569476bcc
1 changed files with 51 additions and 1 deletions
|
@ -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"},
|
||||
],
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue