Skip to content

Commit 1fde257

Browse files
authored
Formatting problem fix of scalar fields selected several times (#1585)
1 parent 1956b56 commit 1fde257

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

NEXT_CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,12 @@ Move the location of the `text` field when exposing the query plan and fill it w
172172

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

175+
### Formatting problem fix of scalar fields selected several times ([PR #1583](https://github.com/apollographql/router/issues/1583))
176+
177+
Fixed a bug where querying scalar fields several times would put `null`s instead of expected values.
178+
179+
By [@eole1712](https://github.com/eole1712) in https://github.com/apollographql/router/pull/1585
180+
175181
### Fix typo on HTTP errors from subgraph ([#1593](https://github.com/apollographql/router/pull/1593))
176182

177183
Remove the closed parenthesis at the end of error messages resulting from HTTP errors from subgraphs.

apollo-router/src/spec/query.rs

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ impl Query {
244244
// we cannot know about the expected format of custom scalars
245245
// so we must pass them directly to the client
246246
if schema.custom_scalars.contains(type_name) {
247-
*output = input.take();
247+
*output = input.clone();
248248
return Ok(());
249249
} else if let Some(enum_type) = schema.enums.get(type_name) {
250250
return match input.as_str() {
@@ -1339,6 +1339,32 @@ mod tests {
13391339
);
13401340
}
13411341

1342+
#[test]
1343+
fn reformat_response_array_of_scalar_duplicate_key() {
1344+
assert_format_response!(
1345+
"type Query {
1346+
get: Thing
1347+
}
1348+
type Thing {
1349+
array: [Int]
1350+
}
1351+
1352+
",
1353+
"{get {array array}}",
1354+
json! {{
1355+
"get": {
1356+
"array": [1,2,3,4],
1357+
},
1358+
}},
1359+
None,
1360+
json! {{
1361+
"get": {
1362+
"array": [1,2,3,4],
1363+
},
1364+
}},
1365+
);
1366+
}
1367+
13421368
#[test]
13431369
fn reformat_response_array_of_type_simple() {
13441370
assert_format_response!(

0 commit comments

Comments
 (0)