Skip to content

Commit 18e8620

Browse files
committed
update to latest
1 parent ffebf09 commit 18e8620

File tree

6 files changed

+35
-22
lines changed

6 files changed

+35
-22
lines changed

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

graph/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ http = "0.2.3"
2121
fail = { version = "0.5", features = ["failpoints"] }
2222
futures = "0.1.21"
2323
graphql-parser = "0.4.0"
24-
graphql-tools = "0.0.4"
24+
graphql-tools = "0.0.5"
2525
lazy_static = "1.4.0"
2626
mockall = "0.8.3"
2727
num-bigint = { version = "^0.2.6", features = ["serde"] }

graph/src/data/query/result.rs

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use super::error::{QueryError, QueryExecutionError};
22
use crate::prelude::{r, CacheWeight, DeploymentHash};
3+
use graphql_tools::validation::utils::ValidationError;
34
use http::header::{
45
ACCESS_CONTROL_ALLOW_HEADERS, ACCESS_CONTROL_ALLOW_METHODS, ACCESS_CONTROL_ALLOW_ORIGIN,
56
CONTENT_TYPE,
@@ -9,7 +10,6 @@ use serde::Serialize;
910
use std::collections::BTreeMap;
1011
use std::convert::TryFrom;
1112
use std::sync::Arc;
12-
use graphql_tools::validation::utils::{ValidationError};
1313

1414
fn serialize_data<S>(data: &Option<Data>, serializer: S) -> Result<S::Ok, S::Error>
1515
where
@@ -253,17 +253,23 @@ impl From<QueryExecutionError> for QueryResult {
253253
}
254254

255255
impl From<Vec<ValidationError>> for QueryResult {
256-
fn from(errors: Vec<ValidationError>) -> Self {
257-
let execution_errors = errors.iter().map(|e| {
258-
QueryError::ExecutionError(QueryExecutionError::ValidationError(e.locations.clone().into_iter().nth(0), e.message.clone()))
259-
}).collect::<Vec<QueryError>>();
260-
261-
QueryResult {
262-
data: None,
263-
errors: execution_errors,
264-
deployment: None,
265-
}
266-
}
256+
fn from(errors: Vec<ValidationError>) -> Self {
257+
let execution_errors = errors
258+
.iter()
259+
.map(|e| {
260+
QueryError::ExecutionError(QueryExecutionError::ValidationError(
261+
e.locations.clone().into_iter().nth(0),
262+
e.message.clone(),
263+
))
264+
})
265+
.collect::<Vec<QueryError>>();
266+
267+
QueryResult {
268+
data: None,
269+
errors: execution_errors,
270+
deployment: None,
271+
}
272+
}
267273
}
268274

269275
impl From<QueryError> for QueryResult {

graphql/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ crossbeam = "0.8"
88
futures01 = { package="futures", version="0.1.29" }
99
graph = { path = "../graph" }
1010
graphql-parser = "0.4.0"
11-
graphql-tools = "0.0.4"
11+
graphql-tools = "0.0.5"
1212
indexmap = "1.7"
1313
Inflector = "0.11.3"
1414
lazy_static = "1.2.0"

graphql/src/runner.rs

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ use graph::{
2121
data::query::{QueryResults, QueryTarget},
2222
prelude::QueryStore,
2323
};
24+
use graphql_tools::validation::rules::default_rules_validation_plan;
2425
use graphql_tools::validation::validate::{validate, ValidationPlan};
25-
use graphql_tools::validation::rules::{OverlappingFieldsCanBeMerged};
2626

2727
use lazy_static::lazy_static;
2828

@@ -138,16 +138,19 @@ where
138138
) -> Self {
139139
let logger = logger.new(o!("component" => "GraphQlRunner"));
140140
let result_size = Arc::new(ResultSizeMetrics::new(registry));
141-
let mut graphql_validation_plan = ValidationPlan { rules: Vec::new() };
142-
graphql_validation_plan.add_rule(Box::new(OverlappingFieldsCanBeMerged {}));
141+
// This is created only once, and includes the following rules at the moment:
142+
// LoneAnonymousOperation
143+
// FragmentsOnCompositeTypes
144+
// OverlappingFieldsCanBeMerged
145+
let graphql_validation_plan = default_rules_validation_plan();
143146

144147
GraphQlRunner {
145148
logger,
146149
store,
147150
subscription_manager,
148151
load_manager,
149152
result_size,
150-
graphql_validation_plan
153+
graphql_validation_plan,
151154
}
152155
}
153156

@@ -204,7 +207,11 @@ where
204207
let state = store.deployment_state().await?;
205208
let network = Some(store.network_name().to_string());
206209
let schema = store.api_schema()?;
207-
let validation_errors = validate(&schema.document(), &query.document, &self.graphql_validation_plan);
210+
let validation_errors = validate(
211+
&schema.document(),
212+
&query.document,
213+
&self.graphql_validation_plan,
214+
);
208215

209216
if validation_errors.len() > 0 {
210217
return Ok(QueryResults::from(QueryResult::from(validation_errors)));

node/src/manager/commands/query.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ pub async fn run(
3333
let document = graphql_parser::parse_query(&query)?.into_static();
3434
// Ideally, `validate` phase should happen here, but we don't have the schema at this point,
3535
// so we call it in `graphql/runner.rs` instead, where we have the api schema loaded.
36-
36+
3737
let vars: Vec<(String, r::Value)> = vars
3838
.into_iter()
3939
.map(|v| {

0 commit comments

Comments
 (0)