Skip to content

Commit 5cb49ed

Browse files
authored
fix(composition): Enable and debug tests for post-merge validations (#8719)
1 parent d86bf88 commit 5cb49ed

File tree

4 files changed

+191
-169
lines changed

4 files changed

+191
-169
lines changed

apollo-federation/src/composition/satisfiability/satisfiability_error.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,10 +100,7 @@ pub(super) fn shareable_field_non_intersecting_runtime_types_error(
100100
{}.\n\
101101
This is not allowed as shared fields must resolve the same way in all subgraphs, and that \
102102
implies at least some common runtime types between the subgraphs.",
103-
operation,
104-
field_definition_position,
105-
field.ty.inner_named_type(),
106-
type_strings,
103+
operation, field_definition_position, field.ty, type_strings,
107104
);
108105
errors.push(CompositionError::ShareableHasMismatchedRuntimeTypes { message });
109106
Ok(())

apollo-federation/src/query_graph/graph_path/transition.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,15 @@ impl TransitionGraphPath {
149149
let Selection::Field(field) = field else {
150150
return None;
151151
};
152-
if !field
152+
// Check if the field definition in the schema has @external
153+
// We need to look up the actual field definition because the parsed
154+
// field set doesn't include directives from the schema
155+
let field_def = field
153156
.field
154-
.directives
155-
.has(external_directive_definition_name)
156-
{
157+
.field_position
158+
.get(subgraph_schema.schema())
159+
.ok()?;
160+
if !field_def.directives.has(external_directive_definition_name) {
157161
return None;
158162
}
159163
Some(field.field.name().clone())

apollo-federation/tests/composition/mod.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub(crate) mod test_helpers {
2828
use apollo_federation::composition::compose;
2929
use apollo_federation::error::CompositionError;
3030
use apollo_federation::error::FederationError;
31+
use apollo_federation::subgraph::test_utils::remove_indentation;
3132
use apollo_federation::subgraph::typestate::Subgraph;
3233
use apollo_federation::supergraph::CompositionHint;
3334
use apollo_federation::supergraph::Satisfiable;
@@ -114,6 +115,9 @@ pub(crate) mod test_helpers {
114115
for (i, (expected_code, expected_message)) in expected_errors.iter().enumerate() {
115116
let (error_code, error_str) = &error_strings[i];
116117

118+
let error_str = remove_indentation(error_str);
119+
let expected_message = remove_indentation(expected_message);
120+
117121
// Check error code
118122
assert!(
119123
error_code == expected_code,

0 commit comments

Comments
 (0)