Skip to content

Commit

Permalink
Correct parent type used for top-level fields
Browse files Browse the repository at this point in the history
  • Loading branch information
goto-bus-stop committed Oct 22, 2024
1 parent 536d9f6 commit 877eb2c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
7 changes: 6 additions & 1 deletion apollo-router/src/spec/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,11 @@ impl Query {
continue;
}

let root_type = apollo_compiler::ast::Type::Named(
// Unchecked name instantiation is always safe, and we know the name is
// valid here
apollo_compiler::Name::new_unchecked(root_type_name),
);
let field_name = alias.as_ref().unwrap_or(name);
let field_name_str = field_name.as_str();
if let Some(input_value) = input.get_mut(field_name_str) {
Expand All @@ -961,7 +966,7 @@ impl Query {
input_value,
output_value,
path,
&field_type.0,
&root_type,
FieldOrIndex::Field(field_name_str),
selection_set,
);
Expand Down
7 changes: 1 addition & 6 deletions apollo-router/src/spec/query/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1377,7 +1377,7 @@ fn reformat_response_expected_int() {
},
{
"message": "Invalid value found for field Query.g",
"path": ["f"],
"path": ["g"],
"extensions": { "code": "RESPONSE_VALIDATION_FAILED" }
},
]))
Expand Down Expand Up @@ -1620,11 +1620,6 @@ fn reformat_response_expected_id() {
"path": ["e"],
"extensions": { "code": "RESPONSE_VALIDATION_FAILED" }
},
{
"message": "Invalid value found for field Query.f",
"path": ["f"],
"extensions": { "code": "RESPONSE_VALIDATION_FAILED" }
},
{
"message": "Invalid value found for field Query.g",
"path": ["g"],
Expand Down

0 comments on commit 877eb2c

Please sign in to comment.