Skip to content

Commit

Permalink
added a test
Browse files Browse the repository at this point in the history
  • Loading branch information
duckki committed Oct 4, 2024
1 parent 135e89c commit 1809331
Showing 1 changed file with 101 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,104 @@ fn add_back_sibling_typename_to_interface_object() {
"###
);
}

#[test]
fn test_indirect_branch_merging_with_typename_sibling() {
let planner = planner!(
Subgraph1: r#"
type Query {
test: T
}
interface T {
id: ID!
}
type A implements T @key(fields: "id") {
id: ID!
}
type B implements T @key(fields: "id") {
id: ID!
}
"#,
Subgraph2: r#"
interface T {
id: ID!
f: Int!
}
type A implements T @key(fields: "id") {
id: ID!
f: Int!
}
type B implements T @key(fields: "id") {
id: ID!
f: Int!
}
"#,
);
// This operation has two `f` selection instances: One with __typename sibling and one without.
// It creates multiple identical branches in the form of `... on A { f }` with different `f`.
// The query plan must chose one over the other, which is implementation specific.
// Currently, the last one is chosen.
assert_plan!(
&planner,
r#"
{
test {
__typename
f # <= This will have a sibling typename value.
... on A {
f # <= This one will have no sibling typename.
}
}
}
"#,
@r###"
QueryPlan {
Sequence {
Fetch(service: "Subgraph1") {
{
test {
__typename
... on A {
__typename
id
}
... on B {
__typename
id
}
}
}
},
Flatten(path: "test") {
Fetch(service: "Subgraph2") {
{
... on A {
__typename
id
}
... on B {
__typename
id
}
} =>
{
... on A {
f
}
... on B {
__typename
f
}
}
},
},
},
}
"###
);
}

0 comments on commit 1809331

Please sign in to comment.