Database Compatibility
Relevant source files
The following files were used as context for generating this wiki page:
Seaography is built on top of SeaORM, inheriting its broad database compatibility. It serves as a bridge that transforms database schemas into fully-typed GraphQL APIs. By leveraging SeaORM's abstraction layer, Seaography supports multiple SQL dialects while providing a unified GraphQL interface for querying, filtering, and mutations.
The framework supports MySQL, PostgreSQL, and SQLite out-of-the-box. Additionally, it extends support to SQL Server through SeaORM X. This compatibility ensures that developers can generate a GraphQL backend from existing relational databases with minimal manual configuration.
Sources: README.md:43-47, src/lib.rs:36-40
Supported Database Systems
Seaography maintains specific integration paths for major relational database engines. The following table outlines the supported databases and their corresponding SQL library drivers used during project generation.
| Database | SQL Library (Driver) | CLI Protocol Scheme |
|---|---|---|
| MySQL | sqlx-mysql | mysql:// |
| PostgreSQL | sqlx-postgres | postgres:// or postgresql:// |
| SQLite | sqlx-sqlite | sqlite:// |
| SQL Server | SeaORM X | N/A (via SeaORM X) |
Sources: README.md:43-47, cli/src/main.rs:136-142, generator/src/writer.rs:138
Dialect-Specific Features
While Seaography provides a unified API, certain features are optimized for or exclusive to specific database dialects.
PostgreSQL Advanced Types
Seaography includes specific support for PostgreSQL-only features, such as array-based filtering. This includes operators like array_contains for columns defined as arrays in Postgres.
Sources: CHANGELOG.md:109-122, Cargo.toml:57
Enumerations
The framework handles native database enums for MySQL and PostgreSQL. It allows GraphQL queries to filter using these enum types directly in the schema.
Sources: README.md:154-165, CHANGELOG.md:144-149
SQLite Integration
SQLite is supported primarily for local development and embedded use cases. Seaography provides a sample sakila.db file for quick demonstrations and testing within the SQLite environment.
Sources: README.md:89-94, examples/sqlite/Cargo.toml
CLI Protocol Mapping
The seaography-cli is responsible for parsing database connection strings and mapping them to the correct internal project configurations. It validates the URI components (username, host, database name) based on the specific requirements of the protocol.
The diagram shows the logic used by the CLI to determine which SQL driver to include in the generated project's Cargo.toml.
Sources: cli/src/main.rs:136-142, generator/src/writer.rs:141-143
Schema and Data Type Mapping
Seaography maps standard SQL types to GraphQL scalars. Complex types are handled through feature flags and specific database drivers.
| SQL Type Category | Supported Types / Features |
|---|---|
| Numeric | Decimal (via with-decimal), Bigdecimal (via with-bigdecimal), Integer |
| Temporal | DateTime, Time (via with-time), Chrono (via with-chrono) |
| Identifiers | UUID (via with-uuid) |
| JSON | JSONB/JSON (via with-json) |
| Collections | Postgres Arrays (via with-postgres-array) |
Sources: Cargo.toml:47-58, README.md:52-54
Data Flow Overview
The interaction between the GraphQL layer and the underlying database follows a structured path through the SeaORM abstraction.
This diagram illustrates how Seaography abstracts the database-specific SQL dialect from the end user.
Sources: src/lib.rs:11-16, generator/src/writer.rs:65-71
Conclusion
Seaography's database compatibility is defined by its tight integration with SeaORM, enabling it to support the most common relational databases used in modern web development. By automating the mapping between SQL schemas and GraphQL types, it provides a consistent developer experience across MySQL, PostgreSQL, and SQLite.