Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Geal committed Aug 22, 2024
1 parent 16e13f8 commit b1bdca8
Show file tree
Hide file tree
Showing 3 changed files with 725 additions and 2 deletions.
4 changes: 3 additions & 1 deletion apollo-router/src/graphql/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,9 @@ impl Request {
}
}

fn process_batch_values(value: &serde_json::Value) -> Result<Vec<Request>, serde_json::Error> {
pub(crate) fn process_batch_values(
value: &serde_json::Value,
) -> Result<Vec<Request>, serde_json::Error> {
let mut result = Request::allocate_result_array(value);

if value.is_array() {
Expand Down
5 changes: 4 additions & 1 deletion apollo-router/src/services/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ use serde_json_bytes::Value;
use static_assertions::assert_impl_all;
use tower::BoxError;

use crate::graphql;
use crate::http_ext::header_map;
use crate::http_ext::TryIntoHeaderName;
use crate::http_ext::TryIntoHeaderValue;
Expand Down Expand Up @@ -242,12 +243,14 @@ impl Response {
/// This is useful for things such as authentication errors.
#[builder(visibility = "pub")]
fn error_new(
errors: Vec<graphql::Error>,
status_code: Option<StatusCode>,
headers: MultiMap<TryIntoHeaderName, TryIntoHeaderValue>,
context: Context,
) -> Result<Self, BoxError> {
let res = graphql::Response::builder().errors(errors).build();
Response::new(
Value::Null,
serde_json_bytes::to_value(res).expect("JSON serialization should not fail"),
status_code,
headers,
context,
Expand Down
Loading

0 comments on commit b1bdca8

Please sign in to comment.