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
8 changes: 8 additions & 0 deletions .cargo/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,11 @@ subgraphs = "run --package subgraphs"
test_all = "test --workspace"
test_qp = "test --package query-planner -- --nocapture"
"clippy:fix" = "clippy --all --fix --allow-dirty --allow-staged"

[build]
rustdocflags = ["-C", "target-cpu=native"]
rustflags = ["-g", "-C", "target-cpu=native"]

[bench]
rustdocflags = ["-C", "target-cpu=native"]
rustflags = ["-g", "-C", "target-cpu=native"]
175 changes: 172 additions & 3 deletions Cargo.lock

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

12 changes: 8 additions & 4 deletions bench/k6.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,16 @@ import { check } from "k6";
import { textSummary } from "https://jslib.k6.io/k6-summary/0.0.1/index.js";
import { githubComment } from "https://raw.githubusercontent.com/dotansimha/k6-github-pr-comment/master/lib.js";

const endpoint = __ENV.GATEWAY_ENDPOINT || "http://0.0.0.0:4000/graphql";
const vus = __ENV.BENCH_VUS ? parseInt(__ENV.BENCH_VUS) : 50;
const time = __ENV.BENCH_OVER_TIME || "30s";
const duration = __ENV.BENCH_OVER_TIME || "30s";

// Apollo: 642.824925/s
// Hive: 832.384019/s

export const options = {
vus: vus,
duration: time,
vus,
duration,
};

export function setup() {
Expand Down Expand Up @@ -158,7 +162,7 @@ function handleBenchmarkSummary(data, additionalContext = {}) {

function sendGraphQLRequest() {
const res = http.post(
__ENV.GATEWAY_ENDPOINT || "http://0.0.0.0:4000/graphql",
endpoint,
graphqlRequest.payload,
graphqlRequest.params,
);
Expand Down
2 changes: 1 addition & 1 deletion bin/dev-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ query-planner = { path = "../../lib/query-planner" }
graphql-parser = "0.4.1"
tracing-subscriber = { version = "0.3.19", features = ["env-filter"] }
tracing-tree = "0.4.0"
serde_json = { version = "1.0.120", features = ["preserve_order"] }
serde_json = "1.0.140"
2 changes: 1 addition & 1 deletion bin/gateway/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ graphql-tools = "0.4.0" # Using version from original file

# Serialization
serde = { version = "1.0.203", features = ["derive"] }
serde_json = { version = "1.0.120", features = ["preserve_order"] }
sonic-rs = "0.5.1"

# HTTP client and caching
moka = { version = "0.12.8", features = ["future"] }
Expand Down
2 changes: 1 addition & 1 deletion bin/gateway/src/pipeline/coerce_variables_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use axum::body::Body;
use http::Request;
use query_plan_executor::variables::collect_variables;
use query_plan_executor::ExecutionRequest;
use serde_json::Value;
use sonic_rs::Value;
use tracing::{trace, warn};

use crate::pipeline::error::{PipelineError, PipelineErrorVariant};
Expand Down
17 changes: 7 additions & 10 deletions bin/gateway/src/pipeline/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use graphql_tools::validation::utils::ValidationError;
use http::{Response, StatusCode};
use query_plan_executor::{ExecutionResult, GraphQLError};
use query_planner::{ast::normalization::error::NormalizationError, planner::PlannerError};
use serde_json::Value;
use sonic_rs::Value;

use crate::pipeline::http_request_params::APPLICATION_JSON;

Expand Down Expand Up @@ -55,11 +55,11 @@ pub enum PipelineErrorVariant {

// GraphQL-specific errors
#[error("Failed to parse GraphQL request payload")]
FailedToParseBody(serde_json::Error),
FailedToParseBody(sonic_rs::Error),
#[error("Failed to parse GraphQL variables JSON")]
FailedToParseVariables(serde_json::Error),
FailedToParseVariables(sonic_rs::Error),
#[error("Failed to parse GraphQL extensions JSON")]
FailedToParseExtensions(serde_json::Error),
FailedToParseExtensions(sonic_rs::Error),
#[error("Failed to parse GraphQL operation")]
FailedToParseOperation(graphql_parser::query::ParseError),
#[error("Failed to normalize GraphQL operation")]
Expand Down Expand Up @@ -149,7 +149,7 @@ impl IntoResponse for PipelineError {

return (
StatusCode::OK,
serde_json::to_string(&validation_error_result).unwrap(),
sonic_rs::to_string(&validation_error_result).unwrap(),
)
.into_response();
}
Expand All @@ -158,10 +158,7 @@ impl IntoResponse for PipelineError {
let message = self.error.graphql_error_message();

let graphql_error = GraphQLError {
extensions: Some(HashMap::from([(
"code".to_string(),
Value::String(code.to_string()),
)])),
extensions: Some(HashMap::from([("code".to_string(), Value::from(code))])),
message,
path: None,
locations: None,
Expand All @@ -173,6 +170,6 @@ impl IntoResponse for PipelineError {
extensions: None,
};

(status, serde_json::to_string(&result).unwrap()).into_response()
(status, sonic_rs::to_string(&result).unwrap()).into_response()
}
}
Loading