pub mod ast;
pub mod binding;
pub mod category;
pub mod error;
pub mod scope;
pub mod types;
pub mod write_set;
pub(crate) mod bind;
pub(crate) mod infer;
pub(crate) mod schema;
use selene_graph::GraphTypeDef;
use crate::{ProcedureRegistry, Statement};
pub use ast::{AnalyzedStatement, AnalyzedStatementKind};
pub use binding::{BindingDecl, BindingDeclKind, BindingId, BindingUse, BindingUseKind};
pub use category::StatementCategory;
pub use error::{
AnalysisError, ConditionClause, ExpectedType, InvalidLabelForm, PatternElementKind, Side,
TypeMismatchContext,
};
pub use scope::{BindingScope, BindingScopeTree, ScopeId, ScopeKind};
pub use types::{AnalyzedType, ExprId, ExprIdLookup, ExprTypeTable};
pub use write_set::{ElementKind, MutationWriteSet, WriteKind, WriteSetEntry};
#[tracing::instrument(
name = "selene.gql.analyze",
skip(stmt, registry, schema),
fields(schema_bound = schema.is_some())
)]
pub fn analyze(
stmt: Statement,
registry: &dyn ProcedureRegistry,
schema: Option<&GraphTypeDef>,
) -> Result<AnalyzedStatement, AnalysisError> {
let analyzed = bind::bind_statement(stmt, registry)?;
if let Some(graph_type) = schema {
self::schema::validate(&analyzed, graph_type)?;
}
Ok(analyzed)
}