62 lines
1.2 KiB
Markdown
62 lines
1.2 KiB
Markdown
|
|
# axum-async-graphql
|
||
|
|
|
||
|
|
## Setup and Running
|
||
|
|
|
||
|
|
1. Copy `.env_dev` to `.env` for local development:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
cp .env_dev .env
|
||
|
|
```
|
||
|
|
|
||
|
|
2. Update database connection string in `.env` file as needed
|
||
|
|
|
||
|
|
3. Run the application:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
cargo run
|
||
|
|
```
|
||
|
|
|
||
|
|
4. Access GraphiQL IDE at: "<http://localhost:8000>"
|
||
|
|
|
||
|
|
## Development Commands
|
||
|
|
|
||
|
|
- Run tests: `cargo test`
|
||
|
|
- Format code: `cargo fmt`
|
||
|
|
- Check types: `cargo check`
|
||
|
|
- Lint: `cargo clippy`
|
||
|
|
|
||
|
|
## Architecture
|
||
|
|
|
||
|
|
This is a Rust application using:
|
||
|
|
|
||
|
|
- `axum` for web framework
|
||
|
|
- `async-graphql` for GraphQL implementation
|
||
|
|
- `sqlx` for database access
|
||
|
|
- PostgreSQL as the database
|
||
|
|
|
||
|
|
The structure follows domain-driven design with separate modules for:
|
||
|
|
|
||
|
|
- `domain` - core business logic and entities
|
||
|
|
- `queries` - GraphQL query resolvers
|
||
|
|
- `mutations` - GraphQL mutation resolvers
|
||
|
|
- `dataloader` - data loading optimization
|
||
|
|
- `models` - shared data models
|
||
|
|
|
||
|
|
## Key Files
|
||
|
|
|
||
|
|
- `src/main.rs` - Entry point and application setup
|
||
|
|
- `src/database.rs` - Database connection management
|
||
|
|
- `src/config.rs` - Configuration handling
|
||
|
|
- `src/domain/` - Core business logic modules
|
||
|
|
|
||
|
|
## Testing
|
||
|
|
|
||
|
|
Integration tests can be run via the test script:
|
||
|
|
|
||
|
|
```bash
|
||
|
|
./test.sh
|
||
|
|
```
|
||
|
|
|
||
|
|
The test script contains example mutations to test the API.
|
||
|
|
|