1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
use crate::query_planner::{
tests::testkit::{build_query_plan_with_defaults, init_logger},
utils::parsing::parse_operation,
};
use std::error::Error;
#[test]
fn requires_with_fragments_on_interfaces() -> Result<(), Box<dyn Error>> {
init_logger();
let document = parse_operation(
r#"
query {
userFromA {
permissions
}
}
"#,
);
let query_plan = build_query_plan_with_defaults(
"fixture/tests/requires-with-fragments.supergraph.graphql",
document,
)?;
insta::assert_snapshot!(format!("{}", query_plan), @r#"
QueryPlan {
Sequence {
Fetch(service: "a") {
{
userFromA {
__typename
id
profile {
displayName
__typename
... on GuestAccount {
guestToken
accountType
}
... on AdminAccount {
adminLevel
accountType
}
}
}
}
},
Flatten(path: "userFromA") {
Fetch(service: "b") {
{
... on User {
__typename
profile {
displayName
... on AdminAccount {
accountType
adminLevel
}
... on GuestAccount {
accountType
guestToken
}
}
id
}
} =>
{
... on User {
permissions
}
}
},
},
},
},
"#);
Ok(())
}