Skip to content

Commit

Permalink
feat(federation): started query plan correctness checker
Browse files Browse the repository at this point in the history
- implemented ResponseShape computation from an operation
  • Loading branch information
duckki committed Dec 21, 2024
1 parent d01fa60 commit a910d24
Show file tree
Hide file tree
Showing 5 changed files with 1,462 additions and 4 deletions.
11 changes: 7 additions & 4 deletions apollo-federation/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,13 @@ fn cmd_plan(

let query_doc =
ExecutableDocument::parse_and_validate(planner.api_schema().schema(), query, query_path)?;
print!(
"{}",
planner.build_query_plan(&query_doc, None, Default::default())?
);
let query_plan = planner.build_query_plan(&query_doc, None, Default::default())?;
println!("{query_plan}");
apollo_federation::query_plan::correctness::check_plan(
planner.api_schema(),
&query_doc,
&query_plan,
)?;
Ok(())
}

Expand Down
23 changes: 23 additions & 0 deletions apollo-federation/src/query_plan/correctness/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
pub mod response_shape;
#[cfg(test)]
pub mod response_shape_test;

use apollo_compiler::validation::Valid;
use apollo_compiler::ExecutableDocument;

use crate::query_plan::QueryPlan;
use crate::schema::ValidFederationSchema;
use crate::FederationError;

//==================================================================================================
// check_plan

pub fn check_plan(
schema: &ValidFederationSchema,
operation_doc: &Valid<ExecutableDocument>,
_plan: &QueryPlan,
) -> Result<(), FederationError> {
let rs = response_shape::compute_response_shape(operation_doc, schema)?;
println!("\nResponse shape from operation:\n{rs}");
Ok(())
}
Loading

0 comments on commit a910d24

Please sign in to comment.