Expand description
Schema parsing and AST types.
This module provides everything needed to work with Prax schema files:
parse_schema- Parse a schema stringparse_schema_file- Parse a schema from a filevalidate_schema- Parse and validate a schemaPraxConfig- Configuration fromprax.tomlSchema- The parsed schema representation
§Example
ⓘ
use prax::schema::{parse_schema, validate_schema, PraxConfig};
// Parse a schema
let schema = parse_schema(r#"
model User {
id Int @id @auto
email String @unique
}
"#)?;
// Access schema information
println!("Models: {:?}", schema.model_names().collect::<Vec<_>>());
// Load configuration
let config = PraxConfig::from_file("prax.toml")?;
println!("Database: {}", config.database.provider);Modules§
- ast
- Abstract Syntax Tree (AST) types for Prax schemas.
- cache
- Schema caching for improved performance.
- config
- Configuration file parsing for
prax.toml. - error
- Error types for schema parsing and validation.
- parser
- Schema parser for
.praxfiles. - prelude
- Prelude module for convenient imports.
- validator
- Schema validation and semantic analysis.
Structs§
- Attribute
- An attribute applied to a field, model, or enum.
- Attribute
Arg - An attribute argument (named or positional).
- Cache
Stats - Statistics for the schema cache.
- Composite
Type - A composite type definition (for embedded documents / JSON).
- Deprecation
Info - Information about a deprecated field.
- DocString
- An interned documentation string.
- DocTag
- A documentation tag (like @example, @deprecated, @see).
- Documentation
- A documentation comment.
- Enhanced
Documentation - Enhanced documentation with embedded validation directives.
- Enum
- An enum definition.
- Enum
Variant - An enum variant.
- Federation
Config - Federation 2.0 configuration for a model.
- Federation
Key - Federation entity key configuration.
- Field
- A field in a model or composite type.
- Field
Attributes - Common field attributes.
- Field
Attrs Cache - Cached field attribute values.
- Field
Metadata - Comprehensive metadata for a field controlling visibility, deprecation, and API behavior.
- Field
Permissions - API operation permissions for a field.
- Field
Validation - A collection of validation rules for a field.
- GraphQL
Argument - A GraphQL directive argument.
- GraphQL
Config - GraphQL-specific configuration for a model or type.
- GraphQL
Directive - A GraphQL directive with arguments.
- GraphQL
Field Config - GraphQL-specific configuration for a field.
- Ident
- An identifier with source location.
- Index
- Index definition for a model.
- Index
Field - A field in an index.
- Lazy
Field Attrs - Lazily computed field attributes.
- Model
- A model definition (maps to a database table).
- Native
Type - Native database type specification.
- Prax
Config - Main configuration structure for
prax.toml. - RawSql
- A raw SQL definition.
- Relation
- A resolved relation between two models.
- Relation
Attribute - Relation attribute details.
- Schema
- A complete Prax schema.
- Schema
Cache - A cache for parsed schemas.
- Schema
Stats - Schema statistics for debugging/info.
- Server
- An individual server within a server group.
- Server
Group - A server group containing multiple database servers.
- Server
Property - A server property key-value pair.
- Span
- A span in the source code for error reporting.
- Subscription
Config - GraphQL subscription configuration.
- Validation
Rule - A validation rule for a field.
- Validation
Type Pool - Pool of commonly used validation types.
- Validator
- Schema validator for semantic analysis.
- View
- A view definition (read-only model mapping to a database view).
Enums§
- Attribute
Value - An attribute argument value.
- Complexity
Config - Query complexity configuration.
- Field
Type - A field type in the schema.
- GraphQL
Value - A GraphQL value for directive arguments.
- Index
Type - Index type.
- Load
Balance Strategy - Load balancing strategy for distributing queries.
- Model
Style - Style of model code generation.
- Referential
Action - Referential actions for relations.
- Relation
Type - The type of relation between two models.
- Scalar
Type - Scalar types supported by Prax.
- Schema
Error - Errors that can occur during schema parsing and validation.
- Server
Group Strategy - Server group strategy.
- Server
Property Value - Server property value types.
- Server
Role - Server role within a group.
- Sort
Order - Sort order for index fields.
- Type
Modifier - Modifier for field types.
- Validation
Type - Types of validation rules.
- Validation
Value - A value that can be used in validation rules.
- Visibility
- Visibility level for a field or model.
Functions§
- parse_
graphql_ config_ from_ tags - Parse GraphQL configuration from doc tags.
- parse_
graphql_ field_ config_ from_ tags - Parse field GraphQL configuration from doc tags.
- parse_
schema - Parse a schema from a string.
- parse_
schema_ file - Parse a schema from a file.
- validate_
schema - Validate a schema string and return the validated schema.
Type Aliases§
- Schema
Result - Result type for schema operations.