From 5065349b4023d33f0fe050e05e37faa4b471e8b8 Mon Sep 17 00:00:00 2001 From: Duckki Oe Date: Thu, 13 Jun 2024 13:22:24 -0700 Subject: [PATCH] fix(fed): bring in commit --- .../src/query_plan/fetch_dependency_graph.rs | 6 +++++- .../build_query_plan_tests/interface_object.rs | 14 ++++---------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/apollo-federation/src/query_plan/fetch_dependency_graph.rs b/apollo-federation/src/query_plan/fetch_dependency_graph.rs index 3f16e048e1..67a506f879 100644 --- a/apollo-federation/src/query_plan/fetch_dependency_graph.rs +++ b/apollo-federation/src/query_plan/fetch_dependency_graph.rs @@ -3062,6 +3062,10 @@ fn compute_nodes_for_key_resolution<'a>( let dest = stack_item.tree.graph.node_weight(dest_id)?; // We shouldn't have a key on a non-composite type let source_type: CompositeTypeDefinitionPosition = source.type_.clone().try_into()?; + let source_schema: ValidFederationSchema = dependency_graph + .federated_query_graph + .schema_by_source(&source.source)? + .clone(); let dest_type: CompositeTypeDefinitionPosition = dest.type_.clone().try_into()?; let dest_schema: ValidFederationSchema = dependency_graph .federated_query_graph @@ -3153,7 +3157,7 @@ fn compute_nodes_for_key_resolution<'a>( let node = FetchDependencyGraph::node_weight_mut(&mut dependency_graph.graph, stack_item.node_id)?; let typename_field = Arc::new(OpPathElement::Field(Field::new_introspection_typename( - &dependency_graph.supergraph_schema, + &source_schema, &source_type, None, ))); diff --git a/apollo-federation/tests/query_plan/build_query_plan_tests/interface_object.rs b/apollo-federation/tests/query_plan/build_query_plan_tests/interface_object.rs index d7e8c682ef..ec803987dc 100644 --- a/apollo-federation/tests/query_plan/build_query_plan_tests/interface_object.rs +++ b/apollo-federation/tests/query_plan/build_query_plan_tests/interface_object.rs @@ -93,10 +93,6 @@ fn can_use_a_key_on_an_interface_object_type() { } #[test] -#[should_panic( - expected = r#"Cannot add selection of field "I.__typename" to selection set of parent type "I" that is potentially an interface object type at runtime"# -)] -// TODO: investigate this failure fn can_use_a_key_on_an_interface_object_from_an_interface_object_type() { let planner = planner!( S1: SUBGRAPH1, @@ -229,9 +225,10 @@ fn does_not_rely_on_an_interface_object_directly_for_typename() { #[test] #[should_panic( - expected = r#"Cannot add selection of field "I.__typename" to selection set of parent type "I" that is potentially an interface object type at runtime"# + expected = r#"Cannot add selection of field "I.id" to selection set of parent type "A""# )] // TODO: investigate this failure +// - Fails to rebase on an interface object type in a subgraph. fn does_not_rely_on_an_interface_object_directly_if_a_specific_implementation_is_requested() { let planner = planner!( S1: SUBGRAPH1, @@ -374,10 +371,6 @@ fn can_use_a_key_on_an_interface_object_type_even_for_a_concrete_implementation( } #[test] -#[should_panic( - expected = r#"Cannot add selection of field "I.__typename" to selection set of parent type "I" that is potentially an interface object type at runtime"# -)] -// TODO: investigate this failure fn handles_query_of_an_interface_field_for_a_specific_implementation_when_query_starts_with_interface_object( ) { let planner = planner!( @@ -434,9 +427,10 @@ fn handles_query_of_an_interface_field_for_a_specific_implementation_when_query_ #[test] #[should_panic( - expected = r#"Cannot add selection of field "I.__typename" to selection set of parent type "I" that is potentially an interface object type at runtime"# + expected = r#"Cannot add selection of field "I.id" to selection set of parent type "A""# )] // TODO: investigate this failure +// - Fails to rebase on an interface object type in a subgraph. fn it_avoids_buffering_interface_object_results_that_may_have_to_be_filtered_with_lists() { let planner = planner!( S1: r#"