-
Notifications
You must be signed in to change notification settings - Fork 275
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use OpTree concatenation in serial query planning (#5636)
- Loading branch information
1 parent
88523dd
commit dbbb549
Showing
6 changed files
with
348 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
135 changes: 135 additions & 0 deletions
135
apollo-federation/tests/query_plan/build_query_plan_tests/mutations.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
const SUBGRAPH_A: &str = r#" | ||
type Foo @key(fields: "id") { | ||
id: ID! | ||
bar: String | ||
} | ||
type Query { | ||
foo: Foo | ||
} | ||
type Mutation { | ||
updateFooInA: Foo | ||
} | ||
"#; | ||
|
||
const SUBGRAPH_B: &str = r#" | ||
type Mutation { | ||
updateFooInB: Foo | ||
} | ||
type Foo @key(fields: "id") { | ||
id: ID! | ||
baz: Int | ||
} | ||
"#; | ||
|
||
#[test] | ||
fn adjacent_mutations_get_merged() { | ||
let planner = planner!( | ||
SubgraphA: SUBGRAPH_A, | ||
SubgraphB: SUBGRAPH_B, | ||
); | ||
assert_plan!( | ||
&planner, | ||
r#" | ||
mutation TestMutation { | ||
updateInAOne: updateFooInA { | ||
id | ||
bar | ||
} | ||
updateInATwo: updateFooInA { | ||
id | ||
bar | ||
} | ||
updateInBOne: updateFooInB { | ||
id | ||
baz | ||
} | ||
} | ||
"#, | ||
@r###" | ||
QueryPlan { | ||
Sequence { | ||
Fetch(service: "SubgraphA") { | ||
{ | ||
updateInAOne: updateFooInA { | ||
id | ||
bar | ||
} | ||
updateInATwo: updateFooInA { | ||
id | ||
bar | ||
} | ||
} | ||
}, | ||
Fetch(service: "SubgraphB") { | ||
{ | ||
updateInBOne: updateFooInB { | ||
id | ||
baz | ||
} | ||
} | ||
}, | ||
}, | ||
} | ||
"### | ||
); | ||
} | ||
|
||
#[test] | ||
fn non_adjacent_mutations_do_not_get_merged() { | ||
let planner = planner!( | ||
SubgraphA: SUBGRAPH_A, | ||
SubgraphB: SUBGRAPH_B, | ||
); | ||
assert_plan!( | ||
&planner, | ||
r#" | ||
mutation TestMutation { | ||
updateInAOne: updateFooInA { | ||
id | ||
bar | ||
} | ||
updateInBOne: updateFooInB { | ||
id | ||
baz | ||
} | ||
updateInATwo: updateFooInA { | ||
id | ||
bar | ||
} | ||
} | ||
"#, | ||
@r###" | ||
QueryPlan { | ||
Sequence { | ||
Fetch(service: "SubgraphA") { | ||
{ | ||
updateInAOne: updateFooInA { | ||
id | ||
bar | ||
} | ||
} | ||
}, | ||
Fetch(service: "SubgraphB") { | ||
{ | ||
updateInBOne: updateFooInB { | ||
id | ||
baz | ||
} | ||
} | ||
}, | ||
Fetch(service: "SubgraphA") { | ||
{ | ||
updateInATwo: updateFooInA { | ||
id | ||
bar | ||
} | ||
} | ||
}, | ||
}, | ||
} | ||
"### | ||
); | ||
} |
67 changes: 67 additions & 0 deletions
67
apollo-federation/tests/query_plan/supergraphs/adjacent_mutations_get_merged.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
# Composed from subgraphs with hash: 2655e7da6754e73955fece01d7cbb5f21085bdbb | ||
schema | ||
@link(url: "https://specs.apollo.dev/link/v1.0") | ||
@link(url: "https://specs.apollo.dev/join/v0.3", for: EXECUTION) | ||
{ | ||
query: Query | ||
mutation: Mutation | ||
} | ||
|
||
directive @join__enumValue(graph: join__Graph!) repeatable on ENUM_VALUE | ||
|
||
directive @join__field(graph: join__Graph, requires: join__FieldSet, provides: join__FieldSet, type: String, external: Boolean, override: String, usedOverridden: Boolean) repeatable on FIELD_DEFINITION | INPUT_FIELD_DEFINITION | ||
|
||
directive @join__graph(name: String!, url: String!) on ENUM_VALUE | ||
|
||
directive @join__implements(graph: join__Graph!, interface: String!) repeatable on OBJECT | INTERFACE | ||
|
||
directive @join__type(graph: join__Graph!, key: join__FieldSet, extension: Boolean! = false, resolvable: Boolean! = true, isInterfaceObject: Boolean! = false) repeatable on OBJECT | INTERFACE | UNION | ENUM | INPUT_OBJECT | SCALAR | ||
|
||
directive @join__unionMember(graph: join__Graph!, member: String!) repeatable on UNION | ||
|
||
directive @link(url: String, as: String, for: link__Purpose, import: [link__Import]) repeatable on SCHEMA | ||
|
||
type Foo | ||
@join__type(graph: SUBGRAPHA, key: "id") | ||
@join__type(graph: SUBGRAPHB, key: "id") | ||
{ | ||
id: ID! | ||
bar: String @join__field(graph: SUBGRAPHA) | ||
baz: Int @join__field(graph: SUBGRAPHB) | ||
} | ||
|
||
scalar join__FieldSet | ||
|
||
enum join__Graph { | ||
SUBGRAPHA @join__graph(name: "SubgraphA", url: "none") | ||
SUBGRAPHB @join__graph(name: "SubgraphB", url: "none") | ||
} | ||
|
||
scalar link__Import | ||
|
||
enum link__Purpose { | ||
""" | ||
`SECURITY` features provide metadata necessary to securely resolve fields. | ||
""" | ||
SECURITY | ||
|
||
""" | ||
`EXECUTION` features provide metadata necessary for operation execution. | ||
""" | ||
EXECUTION | ||
} | ||
|
||
type Mutation | ||
@join__type(graph: SUBGRAPHA) | ||
@join__type(graph: SUBGRAPHB) | ||
{ | ||
updateFooInA: Foo @join__field(graph: SUBGRAPHA) | ||
updateFooInB: Foo @join__field(graph: SUBGRAPHB) | ||
} | ||
|
||
type Query | ||
@join__type(graph: SUBGRAPHA) | ||
@join__type(graph: SUBGRAPHB) | ||
{ | ||
foo: Foo @join__field(graph: SUBGRAPHA) | ||
} |
Oops, something went wrong.