Skip to content

Commit

Permalink
Formatting problem fix of scalar fields selected several times (#1585)
Browse files Browse the repository at this point in the history
  • Loading branch information
eole1712 committed Aug 26, 2022
1 parent 1956b56 commit 1fde257
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
6 changes: 6 additions & 0 deletions NEXT_CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ Move the location of the `text` field when exposing the query plan and fill it w

By [@bnjjj](https://github.com/bnjjj) in https://github.com/apollographql/router/pull/1557

### Formatting problem fix of scalar fields selected several times ([PR #1583](https://github.com/apollographql/router/issues/1583))

Fixed a bug where querying scalar fields several times would put `null`s instead of expected values.

By [@eole1712](https://github.com/eole1712) in https://github.com/apollographql/router/pull/1585

### Fix typo on HTTP errors from subgraph ([#1593](https://github.com/apollographql/router/pull/1593))

Remove the closed parenthesis at the end of error messages resulting from HTTP errors from subgraphs.
Expand Down
28 changes: 27 additions & 1 deletion apollo-router/src/spec/query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl Query {
// we cannot know about the expected format of custom scalars
// so we must pass them directly to the client
if schema.custom_scalars.contains(type_name) {
*output = input.take();
*output = input.clone();
return Ok(());
} else if let Some(enum_type) = schema.enums.get(type_name) {
return match input.as_str() {
Expand Down Expand Up @@ -1339,6 +1339,32 @@ mod tests {
);
}

#[test]
fn reformat_response_array_of_scalar_duplicate_key() {
assert_format_response!(
"type Query {
get: Thing
}
type Thing {
array: [Int]
}
",
"{get {array array}}",
json! {{
"get": {
"array": [1,2,3,4],
},
}},
None,
json! {{
"get": {
"array": [1,2,3,4],
},
}},
);
}

#[test]
fn reformat_response_array_of_type_simple() {
assert_format_response!(
Expand Down

0 comments on commit 1fde257

Please sign in to comment.