Skip to content

Commit 7093221

Browse files
committed
fix one more test
1 parent aa9f029 commit 7093221

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

apollo-router/src/graphql/mod.rs

+10-6
Original file line numberDiff line numberDiff line change
@@ -136,12 +136,16 @@ impl Error {
136136
reason: format!("invalid `extensions` within error: {}", err),
137137
})?
138138
.unwrap_or_default();
139-
let message = extract_key_value_from_object!(object, "message", Value::String(s) => s)
140-
.map_err(|err| MalformedResponseError {
141-
reason: format!("invalid `message` within error: {}", err),
142-
})?
143-
.map(|s| s.as_str().to_string())
144-
.unwrap_or_default();
139+
let message =
140+
match extract_key_value_from_object!(object, "message", Value::String(s) => s) {
141+
Ok(Some(s)) => Ok(s.as_str().to_string()),
142+
Ok(None) => Err(MalformedResponseError {
143+
reason: "missing required `message` property within error".to_owned(),
144+
}),
145+
Err(err) => Err(MalformedResponseError {
146+
reason: format!("invalid `message` within error: {}", err),
147+
}),
148+
}?;
145149
let locations = extract_key_value_from_object!(object, "locations")
146150
.map(skip_invalid_locations)
147151
.map(serde_json_bytes::from_value)

apollo-router/src/plugins/coprocessor/test.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ mod tests {
33
use std::collections::HashMap;
44
use std::sync::Arc;
55

6+
use crate::json_ext::Object;
7+
use crate::json_ext::Value;
68
use futures::future::BoxFuture;
79
use http::HeaderMap;
810
use http::HeaderValue;
@@ -19,8 +21,6 @@ mod tests {
1921
use tower::ServiceExt;
2022

2123
use super::super::*;
22-
use crate::json_ext::Object;
23-
use crate::json_ext::Value;
2424
use crate::plugin::test::MockInternalHttpClientService;
2525
use crate::plugin::test::MockRouterService;
2626
use crate::plugin::test::MockSubgraphService;
@@ -332,7 +332,7 @@ mod tests {
332332
let request = subgraph::Request::fake_builder().build();
333333

334334
assert_eq!(
335-
"couldn't deserialize coprocessor output body: missing field `message`",
335+
"couldn't deserialize coprocessor output body: GraphQL response was malformed: missing required `message` property within error",
336336
service
337337
.oneshot(request)
338338
.await

0 commit comments

Comments
 (0)