Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 5 additions & 3 deletions bin/gateway/src/pipeline/error.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
use std::sync::Arc;
use std::{collections::HashMap, sync::Arc};

use axum::{body::Body, extract::rejection::QueryRejection, response::IntoResponse};
use executor::{execution::error::PlanExecutionError, response::graphql_error::GraphQLError};
use graphql_tools::validation::utils::ValidationError;
use http::{HeaderName, Method, Request, Response, StatusCode};
use query_planner::{ast::normalization::error::NormalizationError, planner::PlannerError};
use serde::{Deserialize, Serialize};
use sonic_rs::{object, Value};
use sonic_rs::Value;

use crate::pipeline::header::{RequestAccepts, APPLICATION_GRAPHQL_RESPONSE_JSON_STR};

Expand Down Expand Up @@ -156,8 +156,10 @@ impl IntoResponse for PipelineError {
let code = self.error.graphql_error_code();
let message = self.error.graphql_error_message();

let mut extensions = HashMap::new();
extensions.insert("code".to_string(), Value::from(code));
let graphql_error = GraphQLError {
extensions: Some(Value::from_iter(&object! {"code": code.to_string()})),
extensions: Some(extensions),
message,
path: None,
locations: None,
Expand Down
4 changes: 2 additions & 2 deletions bin/gateway/src/pipeline/execution_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use crate::shared_state::GatewaySharedState;
use axum::body::Body;
use axum::response::IntoResponse;
use executor::execute_query_plan;
use executor::execution::plan::QueryPlanExecutionContext;
use executor::execution::plan::ExecuteQueryPlanParams;
use executor::introspection::resolve::IntrospectionContext;
use http::{HeaderName, HeaderValue, Request, Response};
use tower::Service;
Expand Down Expand Up @@ -105,7 +105,7 @@ impl Service<Request<Body>> for ExecutionService {
metadata: &app_state.schema_metadata,
};

match execute_query_plan(QueryPlanExecutionContext {
match execute_query_plan(ExecuteQueryPlanParams {
query_plan: &query_plan_payload.query_plan,
projection_plan: &normalized_payload.projection_plan,
variable_values: &variable_payload.variables_map,
Expand Down
4 changes: 4 additions & 0 deletions lib/executor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ bumpalo = "3.19.0"
subgraphs = { path = "../../bench/subgraphs" }
criterion = { workspace = true }
tokio = { workspace = true }
async-graphql = "7.0.17"
tokio-test = "0.4.4"
insta = "1.42.1"
serde_json = "1.0.109"

[[bench]]
name = "executor_benches"
Expand Down
18 changes: 5 additions & 13 deletions lib/executor/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ use query_planner::planner::plan_nodes::{FetchNode, FetchRewrite, QueryPlan};

use crate::response::{graphql_error::GraphQLError, storage::ResponsesStorage, value::Value};

pub struct ExecutionContext<'a> {
pub struct QueryPlanExecutionContext<'a> {
pub response_storage: ResponsesStorage,
pub final_response: Value<'a>,
pub errors: Vec<GraphQLError>,
pub output_rewrites: OutputRewritesStorage,
}

impl<'a> Default for ExecutionContext<'a> {
impl<'a> Default for QueryPlanExecutionContext<'a> {
fn default() -> Self {
ExecutionContext {
QueryPlanExecutionContext {
response_storage: Default::default(),
output_rewrites: Default::default(),
errors: Vec::new(),
Expand All @@ -22,23 +22,15 @@ impl<'a> Default for ExecutionContext<'a> {
}
}

impl<'a> ExecutionContext<'a> {
impl<'a> QueryPlanExecutionContext<'a> {
pub fn new(query_plan: &QueryPlan, init_final_response: Value<'a>) -> Self {
ExecutionContext {
QueryPlanExecutionContext {
response_storage: ResponsesStorage::new(),
output_rewrites: OutputRewritesStorage::from_query_plan(query_plan),
errors: Vec::new(),
final_response: init_final_response,
}
}

pub fn handle_errors(&mut self, errors: Option<Vec<GraphQLError>>) {
if let Some(errors) = errors {
for error in errors {
self.errors.push(error);
}
}
}
}

#[derive(Default)]
Expand Down
Loading
Loading