feat: implement GraphQL member management API
Implement complete member management system with GraphQL API per OpenSpec proposal. Only firstName is required; all other fields are optional with conditional validation. Key features: - GraphQL CRUD operations (create, read, update, delete members) - SQLAlchemy 2.0 async with SQLite database - Alembic database migrations - Conditional validation (email/phone validated only when provided) - Member fields: firstName (required), lastName, address, email, phone (all optional) - Database seed script with sample member - FastAPI with Strawberry GraphQL integration Implementation details: - Python 3.11+ with uv package manager - Async database sessions throughout - Proper error handling and validation - Code quality: black, isort, ruff - Comprehensive end-to-end testing completed All 20 tasks from OpenSpec proposal completed successfully. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
from src.models.member import Member
|
||||
|
||||
__all__ = ["Member"]
|
||||
@@ -0,0 +1,43 @@
|
||||
from datetime import datetime
|
||||
from typing import Optional
|
||||
|
||||
from sqlalchemy import String, func
|
||||
from sqlalchemy.orm import Mapped, mapped_column
|
||||
|
||||
from src.database import Base
|
||||
|
||||
|
||||
class Member(Base):
|
||||
"""Member model for club/society management."""
|
||||
|
||||
__tablename__ = "members"
|
||||
|
||||
# Primary key
|
||||
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True)
|
||||
|
||||
# Required field
|
||||
first_name: Mapped[str] = mapped_column(String(100), nullable=False)
|
||||
|
||||
# Optional fields
|
||||
last_name: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
|
||||
street: Mapped[Optional[str]] = mapped_column(String(200), nullable=True)
|
||||
apartment_number: Mapped[Optional[str]] = mapped_column(String(20), nullable=True)
|
||||
zip: Mapped[Optional[str]] = mapped_column(String(20), nullable=True)
|
||||
city: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
|
||||
country: Mapped[Optional[str]] = mapped_column(String(100), nullable=True)
|
||||
email: Mapped[Optional[str]] = mapped_column(String(255), nullable=True)
|
||||
phone: Mapped[Optional[str]] = mapped_column(String(50), nullable=True)
|
||||
|
||||
# Timestamps
|
||||
created_at: Mapped[datetime] = mapped_column(
|
||||
default=func.now(), server_default=func.now(), nullable=False
|
||||
)
|
||||
updated_at: Mapped[datetime] = mapped_column(
|
||||
default=func.now(),
|
||||
server_default=func.now(),
|
||||
onupdate=func.now(),
|
||||
nullable=False,
|
||||
)
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return f"<Member(id={self.id}, first_name='{self.first_name}', last_name='{self.last_name}')>"
|
||||
Reference in New Issue
Block a user