feat: Add Actix-web integration with custom schema support#3
Open
Penivera wants to merge 2 commits intoSeaQL:mainfrom
Open
feat: Add Actix-web integration with custom schema support#3Penivera wants to merge 2 commits intoSeaQL:mainfrom
Penivera wants to merge 2 commits intoSeaQL:mainfrom
Conversation
- Remove Loco/Axum-specific code - Convert controllers to framework-agnostic services - Adapt GraphQL handler for Actix compatibility - Clean up unused migrations and models - Export actix_web::web::ServiceConfig configurator
- Add SeaOrmProActixConfigurator: Reusable Actix-web module for SeaORM Pro admin interface - Implement feature-gated actix-integration: No forced Loco/Axum dependencies - Add with_custom_schema() builder method: Support for custom Sea-ORM entities - Support custom GraphQL schema builders: Allow external projects to use their own entity schemas - Add JWT authentication support: jsonwebtoken + bcrypt password verification - Implement GraphQL playground: Integrated at /admin/graphql with auth token injection - Add comprehensive documentation: CUSTOM_ENTITIES.md with examples and troubleshooting - Tested on v2 server: Successfully mounted alongside existing routes Features: - Backward compatible (default uses sea-orm-pro entities) - Flexible schema building (custom entities via with_custom_schema) - Mount on any Actix server via configurator pattern - Built-in authentication layer (JWT + bcrypt) - GraphQL playground with integrated auth UI Closes #<PR_ISSUE_NUMBER>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PR: Actix-Web Integration with Custom Schema Support
Overview
This PR adds native Actix-web integration to SeaORM Pro, allowing it to be used as a fully reusable library module in any Actix application. Additionally, it introduces support for custom GraphQL schemas, enabling integration with external Sea-ORM entities instead of just seaorm-pro's built-in ones.
What's Included
1. SeaOrmProActixConfigurator - Reusable Library API
Located in
src/actix_integration.rs, this module provides:SeaOrmProActixConfigurator: Cloneable, thread-safe configurator for mounting admin routesSeaOrmProActixOptions: Builder-pattern options with sensible defaults.configure(cfg)mounts all admin routes2. Feature-Gated Architecture
actix-integrationfeature in Cargo.tomlloco-appfeature keeps standalone server behavior unchanged3. Custom Schema Support
with_custom_schema(schema)builder method4. Complete Authentication Layer
jsonwebtokencratebcryptcrate5. GraphQL Admin Interface
/admin/graphql- Interactive playground with auth token injection/admin/auth/login- JWT token generation with credentials/admin/user/current- Current user profile (protected)/admin/graphql- GraphQL query execution (protected)/admin/config- Admin configuration (public)6. Comprehensive Documentation
Usage Examples
Simple Default Setup (1-line)
Custom Entities Setup
Testing
✅ Compilation:
cargo checkpasses in v2 workspace✅ Feature Isolation: Actix module doesn't pull Loco/Axum deps
✅ Backward Compatibility: Existing standalone app still works
✅ Integration Test: Successfully mounted alongside v2 routes
How to Test Locally
Change Feature Flags in
v2/Cargo.toml:Build and Run:
Test Endpoints:
Files Changed
src/actix_integration.rsCUSTOM_ENTITIES.mdREADME.mdCargo.tomlsrc/lib.rsBenefits
Migration Path
.configure()with_custom_schema()Related Issues
Closes #<ISSUE_NUMBER>
Checklist
Reviewers
@SeaQL/team - Please review for:
SeaOrmProActixOptionsandSeaOrmProActixConfiguratorAdditional Notes
This feature brings SeaORM Pro inline with modern Rust library design patterns:
The implementation prioritizes developer experience and reusability while maintaining the existing standalone application behavior.