Skip to content

Commit e0383dd

Browse files
committed
feat(router): add a flag to disable the caching for query plans
1 parent 88d246a commit e0383dd

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

bin/router/src/pipeline/query_plan.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,19 @@ pub async fn plan_operation_with_cache(
2121
StableOverrideContext::new(&app_state.planner.supergraph, request_override_context);
2222

2323
let filtered_operation_for_plan = &normalized_operation.operation_for_plan;
24+
25+
if app_state.router_config.query_planner.no_plan_cache {
26+
let plan = app_state
27+
.planner
28+
.plan_from_normalized_operation(
29+
filtered_operation_for_plan,
30+
request_override_context.into(),
31+
)
32+
.map_err(|err| req.new_pipeline_error(PipelineErrorVariant::PlannerError(err)))?;
33+
return Ok(Arc::new(plan));
34+
}
2435
let plan_cache_key =
2536
calculate_cache_key(filtered_operation_for_plan.hash(), &stable_override_context);
26-
2737
let query_plan_arc = match app_state.plan_cache.get(&plan_cache_key).await {
2838
Some(plan) => plan,
2939
None => {

lib/router-config/src/query_planner.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,6 @@ pub struct QueryPlannerConfig {
77
/// When set to `true` and an incoming request has a `hive-expose-query-plan: true` header, the query plan will be exposed in the response, as part of `extensions`.
88
#[serde(default)]
99
pub allow_expose: bool,
10+
#[serde(default)]
11+
pub no_plan_cache: bool,
1012
}

0 commit comments

Comments
 (0)