From e569476bcc6f281ab05955ffa144ec334c1b957c Mon Sep 17 00:00:00 2001
From: tyranron <tyranron@gmail.com>
Date: Mon, 27 Feb 2023 18:10:51 +0200
Subject: [PATCH] Consider also testing spreading interface fragment on
 interface (#922)

---
 tests/integration/tests/issue_922.rs | 52 +++++++++++++++++++++++++++-
 1 file changed, 51 insertions(+), 1 deletion(-)

diff --git a/tests/integration/tests/issue_922.rs b/tests/integration/tests/issue_922.rs
index 1a89a68e..b592f392 100644
--- a/tests/integration/tests/issue_922.rs
+++ b/tests/integration/tests/issue_922.rs
@@ -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"},
+            ],
+        }),
+    );
+}