Skip to content

Commit

Permalink
Added an option to disable graphql validations: `DISABLE_GRAPHQL_VALI…
Browse files Browse the repository at this point in the history
…DATIONS`
  • Loading branch information
dotansimha committed Dec 26, 2021
1 parent 737e53b commit 6a7e299
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions graphql/src/runner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ lazy_static! {
u64::from_str(&s)
.unwrap_or_else(|_| panic!("failed to parse env var GRAPH_GRAPHQL_QUERY_TIMEOUT"))
));
static ref DISABLE_GRAPHQL_VALIDATIONS: bool = std::env::var("DISABLE_GRAPHQL_VALIDATIONS")
.unwrap_or_else(|_| "false".into())
.parse::<bool>()
.unwrap_or_else(|_| false);
static ref GRAPHQL_MAX_COMPLEXITY: Option<u64> = env::var("GRAPH_GRAPHQL_MAX_COMPLEXITY")
.ok()
.map(|s| u64::from_str(&s)
Expand Down Expand Up @@ -143,12 +147,14 @@ where
let result_size = Arc::new(ResultSizeMetrics::new(registry));
let mut graphql_validation_plan = ValidationPlan { rules: Vec::new() };

graphql_validation_plan.add_rule(Box::new(LoneAnonymousOperation {}));
graphql_validation_plan.add_rule(Box::new(FragmentsOnCompositeTypes {}));
graphql_validation_plan.add_rule(Box::new(OverlappingFieldsCanBeMerged {}));
graphql_validation_plan.add_rule(Box::new(KnownFragmentNamesRule {}));
graphql_validation_plan.add_rule(Box::new(NoUnusedFragments {}));
graphql_validation_plan.add_rule(Box::new(LeafFieldSelections {}));
if !(*DISABLE_GRAPHQL_VALIDATIONS) {
graphql_validation_plan.add_rule(Box::new(LoneAnonymousOperation {}));
graphql_validation_plan.add_rule(Box::new(FragmentsOnCompositeTypes {}));
graphql_validation_plan.add_rule(Box::new(OverlappingFieldsCanBeMerged {}));
graphql_validation_plan.add_rule(Box::new(KnownFragmentNamesRule {}));
graphql_validation_plan.add_rule(Box::new(NoUnusedFragments {}));
graphql_validation_plan.add_rule(Box::new(LeafFieldSelections {}));
}

GraphQlRunner {
logger,
Expand Down

0 comments on commit 6a7e299

Please sign in to comment.