diff --git a/apollo-federation/tests/query_plan/build_query_plan_tests/named_fragments_preservation.rs b/apollo-federation/tests/query_plan/build_query_plan_tests/named_fragments_preservation.rs index 231609b845..f5f1a0cf52 100644 --- a/apollo-federation/tests/query_plan/build_query_plan_tests/named_fragments_preservation.rs +++ b/apollo-federation/tests/query_plan/build_query_plan_tests/named_fragments_preservation.rs @@ -290,25 +290,7 @@ fn it_avoid_fragments_usable_only_once() { ); } -#[test] -#[should_panic(expected = "not yet implemented")] -// TODO: investigate this failure - -fn respects_query_planner_option_reuse_query_fragments_true() { - respects_query_planner_option_reuse_query_fragments(true) -} -#[test] -#[should_panic(expected = "not yet implemented")] -// TODO: investigate this failure - -fn respects_query_planner_option_reuse_query_fragments_false() { - respects_query_planner_option_reuse_query_fragments(false) -} - -fn respects_query_planner_option_reuse_query_fragments(reuse_query_fragments: bool) { - let planner = planner!( - config = QueryPlannerConfig {reuse_query_fragments, ..Default::default()}, - Subgraph1: r#" +const SUBGRAPH: &str = r#" type Query { t: T } @@ -322,9 +304,9 @@ fn respects_query_planner_option_reuse_query_fragments(reuse_query_fragments: bo x: Int y: Int } - "#, - ); - let query = r#" +"#; + +const QUERY: &str = r#" query { t { a1 { @@ -340,12 +322,21 @@ fn respects_query_planner_option_reuse_query_fragments(reuse_query_fragments: bo x y } - "#; - if reuse_query_fragments { - assert_plan!( - &planner, - query, - @r#" +"#; + +#[test] +#[should_panic(expected = "not yet implemented")] +// TODO: investigate this failure + +fn respects_query_planner_option_reuse_query_fragments_true() { + let planner = planner!( + config = QueryPlannerConfig { reuse_query_fragments: true, ..Default::default()}, + Subgraph1: SUBGRAPH, + ); + assert_plan!( + &planner, + QUERY, + @r#" QueryPlan { Fetch(service: "Subgraph1") { { @@ -365,13 +356,23 @@ fn respects_query_planner_option_reuse_query_fragments(reuse_query_fragments: bo } }, } - "# - ); - } else { - assert_plan!( - &planner, - query, - @r#" + "# + ); +} + +#[test] +#[should_panic(expected = "not yet implemented")] +// TODO: investigate this failure + +fn respects_query_planner_option_reuse_query_fragments_false() { + let planner = planner!( + config = QueryPlannerConfig { reuse_query_fragments: false, ..Default::default()}, + Subgraph1: SUBGRAPH, + ); + assert_plan!( + &planner, + QUERY, + @r#" QueryPlan { Fetch(service: "Subgraph1") { { @@ -388,9 +389,8 @@ fn respects_query_planner_option_reuse_query_fragments(reuse_query_fragments: bo } }, } - "# - ); - } + "# + ); } #[test] @@ -464,7 +464,7 @@ fn it_works_with_nested_fragments_when_only_the_nested_fragment_gets_preserved() #[test] #[should_panic( - expected = "Error: variable `$if` of type `Boolean` cannot be used for argument `if` of type `Boolean!`" + expected = "variable `$if` of type `Boolean` cannot be used for argument `if` of type `Boolean!`" )] // TODO: investigate this failure fn it_preserves_directives_when_fragment_not_used() { diff --git a/apollo-federation/tests/query_plan/supergraphs/respects_query_planner_option_reuse_query_fragments.graphql b/apollo-federation/tests/query_plan/supergraphs/respects_query_planner_option_reuse_query_fragments_false.graphql similarity index 95% rename from apollo-federation/tests/query_plan/supergraphs/respects_query_planner_option_reuse_query_fragments.graphql rename to apollo-federation/tests/query_plan/supergraphs/respects_query_planner_option_reuse_query_fragments_false.graphql index 8831cd4888..11c5d8c279 100644 --- a/apollo-federation/tests/query_plan/supergraphs/respects_query_planner_option_reuse_query_fragments.graphql +++ b/apollo-federation/tests/query_plan/supergraphs/respects_query_planner_option_reuse_query_fragments_false.graphql @@ -1,4 +1,4 @@ -# Composed from subgraphs with hash: 4b0a2b41b9cbccb8bde234dc0285c3372e220fa1 +# Composed from subgraphs with hash: ca8bc5b745ab72ecb5d72159ed30d089d2084d77 schema @link(url: "https://specs.apollo.dev/link/v1.0") @link(url: "https://specs.apollo.dev/join/v0.3", for: EXECUTION) diff --git a/apollo-federation/tests/query_plan/supergraphs/respects_query_planner_option_reuse_query_fragments_true.graphql b/apollo-federation/tests/query_plan/supergraphs/respects_query_planner_option_reuse_query_fragments_true.graphql new file mode 100644 index 0000000000..11c5d8c279 --- /dev/null +++ b/apollo-federation/tests/query_plan/supergraphs/respects_query_planner_option_reuse_query_fragments_true.graphql @@ -0,0 +1,61 @@ +# Composed from subgraphs with hash: ca8bc5b745ab72ecb5d72159ed30d089d2084d77 +schema + @link(url: "https://specs.apollo.dev/link/v1.0") + @link(url: "https://specs.apollo.dev/join/v0.3", for: EXECUTION) +{ + query: Query +} + +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 A + @join__type(graph: SUBGRAPH1) +{ + x: Int + y: Int +} + +scalar join__FieldSet + +enum join__Graph { + SUBGRAPH1 @join__graph(name: "Subgraph1", 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 Query + @join__type(graph: SUBGRAPH1) +{ + t: T +} + +type T + @join__type(graph: SUBGRAPH1) +{ + a1: A + a2: A +}