pub struct Compiler { /* private fields */ }Expand description
Schema compiler.
Transforms authoring-time schema definitions into runtime-optimized
CompiledSchema with pre-generated SQL templates.
§Example
use fraiseql_core::compiler::{Compiler, CompilerConfig, DatabaseTarget};
let config = CompilerConfig {
database_target: DatabaseTarget::PostgreSQL,
optimize_sql: true,
..Default::default()
};
let compiler = Compiler::with_config(config);
let compiled = compiler.compile(r#"{"types": [], "queries": []}"#)?;Implementations§
Source§impl Compiler
impl Compiler
Sourcepub const fn with_config(config: CompilerConfig) -> Self
pub const fn with_config(config: CompilerConfig) -> Self
Create new compiler with custom configuration.
Sourcepub fn compile(&self, schema_json: &str) -> Result<CompiledSchema>
pub fn compile(&self, schema_json: &str) -> Result<CompiledSchema>
Compile schema from JSON.
§Arguments
schema_json- JSON schema emitted by the authoring-language decorators
§Returns
Compiled schema with pre-generated SQL templates
§Errors
Returns error if:
- JSON parsing fails
- Schema validation fails
- SQL template generation fails
§Example
use fraiseql_core::compiler::Compiler;
let compiler = Compiler::new();
let schema_json = r#"{"types": [], "queries": []}"#;
let compiled = compiler.compile(schema_json)?;Sourcepub const fn config(&self) -> &CompilerConfig
pub const fn config(&self) -> &CompilerConfig
Get compiler configuration.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Compiler
impl RefUnwindSafe for Compiler
impl Send for Compiler
impl Sync for Compiler
impl Unpin for Compiler
impl UnsafeUnpin for Compiler
impl UnwindSafe for Compiler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more