POC to create ecommerce apis using Rust and graphql.
- Dataloaders are used to optimize the queries and overcome the N+1 query problem.
- The project uses async-graphql and axum for the apis.
- Install PostgreSQL on your system
- Create a database for the rust-store project
# 1. Copy environment file
cp .env.example .env
# 2. Edit .env with your database credentials
# DATABASE_URL=postgresql://username:password@localhost/rust_store
# 3. Create database (if it doesn't exist)
createdb rust_store
# 4. Run migrations
diesel migration run
# 5. Generate schema (if needed)
diesel print-schema > src/schema.rsYou can use the provided docker-compose file for the database:
# Start PostgreSQL container
docker-compose -f docker-compose-db.yaml up -d
# Use this DATABASE_URL in your .env
DATABASE_URL=postgresql://postgres:password@localhost:5432/rust_store# Run all pending migrations
diesel migration run
# Rollback the last migration
diesel migration revert
# Check migration status
diesel migration pending
# Generate a new migration
diesel migration generate migration_name