MCPcopy Create free account
hub / github.com/GraphLite-AI/GraphLite / validate_query

Function validate_query

graphlite/src/ast/validator.rs:629–784  ·  view source on GitHub ↗

Validate a GQL query document

(
    document: &Document,
    has_graph_context: bool,
)

Source from the content-addressed store, hash-verified

627
628/// Validate a GQL query document
629pub fn validate_query(
630 document: &Document,
631 has_graph_context: bool,
632) -> Result<(), Vec<ValidationError>> {
633 let mut errors = Vec::new();
634 let mut ctx = ValidationContext::new();
635 ctx.has_graph_context = has_graph_context;
636
637 match &document.statement {
638 Statement::Query(query) => {
639 // 1. Structural validations
640 validate_query_structure(query, &mut errors);
641
642 // 2. Variable declarations and scope
643 validate_variable_declarations(query, &mut ctx, &mut errors);
644
645 // 3. Path pattern validations
646 validate_path_patterns(query, &mut ctx, &mut errors);
647
648 // 4. Expression validations
649 validate_expressions(query, &mut ctx, &mut errors);
650
651 // 5. Temporal validations
652 validate_temporal_literals(query, &mut errors);
653
654 // 6. Edge pattern validations
655 validate_edge_patterns(query, &mut errors);
656 }
657 Statement::Select(select_stmt) => {
658 validate_select_statement(select_stmt, &mut ctx, &mut errors);
659 }
660 Statement::Call(call_stmt) => {
661 validate_call_statement(call_stmt, &mut ctx, &mut errors);
662 }
663 Statement::CatalogStatement(catalog_stmt) => {
664 validate_catalog_statement(catalog_stmt, &mut ctx, &mut errors);
665 }
666 Statement::DataStatement(_) => {
667 // TODO: Add data statement validation
668 }
669 Statement::SessionStatement(_) => {
670 // TODO: Add session statement validation
671 }
672 Statement::Declare(_) => {
673 // TODO: Add DECLARE statement validation
674 }
675 Statement::Next(_) => {
676 // TODO: Add NEXT statement validation
677 }
678 Statement::AtLocation(_) => {
679 // TODO: Add AT location statement validation
680 }
681 Statement::TransactionStatement(_) => {
682 // TODO: Add transaction statement validation
683 }
684 Statement::ProcedureBody(procedure_body) => {
685 // Validate procedure body: validate initial statement and all chained statements
686 // First validate variable definitions

Callers 2

validate_queryMethod · 0.85

Calls 13

validate_query_structureFunction · 0.85
validate_path_patternsFunction · 0.85
validate_expressionsFunction · 0.85
validate_edge_patternsFunction · 0.85
validate_call_statementFunction · 0.85
validate_expressionFunction · 0.85
cloneMethod · 0.80

Tested by

no test coverage detected