Skip to content

update seed.ts, resolvers and typeDefs based on latest schema#1

Merged
Prajjawalk merged 1 commit intomainfrom
feat/backend-port
Mar 7, 2026
Merged

update seed.ts, resolvers and typeDefs based on latest schema#1
Prajjawalk merged 1 commit intomainfrom
feat/backend-port

Conversation

@Prajjawalk
Copy link
Copy Markdown
Contributor

@Prajjawalk Prajjawalk commented Mar 7, 2026

Summary by CodeRabbit

Release Notes

  • New Features
    • Added email verification workflow to enhance account security.
    • Introduced notification system with customizable preferences (in-app, email, SMS) and read status tracking.
    • Enabled full profile management, including name, phone number, and notification settings.
    • Expanded data management capabilities with create, update, and delete operations for alerts, detections, signals, events, data sources, and locations.
    • Added alert and event linking to improve content organization and relationship tracking.

@Prajjawalk Prajjawalk merged commit 205ac6b into main Mar 7, 2026
0 of 2 checks passed
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 7, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4535f91a-c0a0-49f9-9a4b-b58da86e4c55

📥 Commits

Reviewing files that changed from the base of the PR and between c0136ad and e68424a.

📒 Files selected for processing (24)
  • prisma/seed.ts
  • src/resolvers/alert.resolver.ts
  • src/resolvers/apiKey.resolver.ts
  • src/resolvers/auth.resolver.ts
  • src/resolvers/dataSource.resolver.ts
  • src/resolvers/detection.resolver.ts
  • src/resolvers/event.resolver.ts
  • src/resolvers/index.ts
  • src/resolvers/location.resolver.ts
  • src/resolvers/notification.resolver.ts
  • src/resolvers/signal.resolver.ts
  • src/resolvers/user.resolver.ts
  • src/schema/index.ts
  • src/schema/typeDefs/mutation.ts
  • src/schema/typeDefs/query.ts
  • src/schema/typeDefs/types/alert.ts
  • src/schema/typeDefs/types/apiKey.ts
  • src/schema/typeDefs/types/dataSource.ts
  • src/schema/typeDefs/types/detection.ts
  • src/schema/typeDefs/types/event.ts
  • src/schema/typeDefs/types/location.ts
  • src/schema/typeDefs/types/notification.ts
  • src/schema/typeDefs/types/signal.ts
  • src/schema/typeDefs/types/user.ts

📝 Walkthrough

Walkthrough

This pull request migrates the application's data model from a US-centric geography to Sudan-focused locations with updated data sources (ACLED, Social Media Monitor, FEWS NET). It refactors all entity IDs from Int to String across the schema and resolvers, introduces three new GraphQL entities (Signal, Event, Notification) with complete CRUD operations, adds email verification workflows, implements role-based access control on mutations, and extends user profiles with notification preferences and phone number fields.

Changes

Cohort / File(s) Summary
Data Migration to Sudan-centric Model
prisma/seed.ts
Replaces US locations with Sudan hierarchy (country, states, localities); updates data sources to ACLED Conflict Data, Social Media Monitor, and FEWS NET; relinks detections, alerts, and user feedback to new Sudan-based locations and sources.
ID Type System Refactoring (Schema)
src/schema/typeDefs/types/alert.ts, src/schema/typeDefs/types/apiKey.ts, src/schema/typeDefs/types/dataSource.ts, src/schema/typeDefs/types/detection.ts, src/schema/typeDefs/types/location.ts
Changes all entity id fields from Int! to String! across alert, detection, location, dataSource, and apiKey types.
New Entity Type Definitions
src/schema/typeDefs/types/signal.ts, src/schema/typeDefs/types/event.ts, src/schema/typeDefs/types/notification.ts, src/schema/typeDefs/types/user.ts
Introduces Signal and Event types with signal-to-detection and event-to-signal relationships; adds Notification type with status tracking; extends User with phoneNumber, notification preferences, and notifications relation.
Mutation & Query Schema Updates
src/schema/typeDefs/mutation.ts, src/schema/typeDefs/query.ts
Adds 22+ new mutations for CRUD operations on Alert, Detection, DataSource, Location, Signal, Event, and Notification entities; adds queries for signals, events, notifications; changes query argument types from Int! to String!; adds email verification and profile update mutations.
Core Entity CRUD Resolvers
src/resolvers/alert.resolver.ts, src/resolvers/detection.resolver.ts, src/resolvers/location.resolver.ts, src/resolvers/dataSource.resolver.ts
Implements createX, updateX, deleteX mutations with role-based access control; updates field resolvers to use string IDs; introduces input type validation (CreateAlertInput, UpdateDetectionInput, etc.); adds GraphQLError handling for not-found cases.
New Entity Resolvers
src/resolvers/signal.resolver.ts, src/resolvers/event.resolver.ts, src/resolvers/notification.resolver.ts
Implements full resolver suites for three new entities with queries, mutations (admin/analyst-gated), and field resolvers; Signal connects detections to events; Event aggregates signals and links to alerts; Notification includes per-user queries and ownership validation.
Authentication & User Features
src/resolvers/auth.resolver.ts, src/resolvers/user.resolver.ts, src/resolvers/apiKey.resolver.ts
Adds email verification workflow (requestEmailVerification, verifyEmail with token validation); implements updateProfile mutation with phone number E.164 validation and SMS notification enablement logic; changes revokeApiKey argument type to string; replaces User.feedback with User.notifications resolver.
Resolver & Schema Integration
src/resolvers/index.ts, src/schema/index.ts
Imports and registers new signal, event, and notification resolvers; imports new type definitions; annotates resolvers export with IResolvers[] type.

Sequence Diagram(s)

sequenceDiagram
    actor Client
    participant AuthResolver
    participant Prisma as Prisma Client
    participant Database

    Client->>AuthResolver: requestEmailVerification()
    AuthResolver->>AuthResolver: Validate user authenticated
    AuthResolver->>AuthResolver: Check email not verified
    AuthResolver->>AuthResolver: Generate 32-byte hex token
    AuthResolver->>AuthResolver: Set 24-hour expiry
    AuthResolver->>Prisma: Create emailVerification record
    Prisma->>Database: INSERT emailVerification
    Database-->>Prisma: Confirmation
    Prisma-->>AuthResolver: Record created
    AuthResolver-->>Client: Return true

    Note over Client,Database: Email with token sent to user

    Client->>AuthResolver: verifyEmail(token)
    AuthResolver->>Prisma: Find emailVerification by token
    Prisma->>Database: SELECT emailVerification
    Database-->>Prisma: Record with expiry
    Prisma-->>AuthResolver: Verification record
    AuthResolver->>AuthResolver: Validate not expired
    AuthResolver->>Prisma: Update user (emailVerified=true)
    Prisma->>Database: UPDATE user
    AuthResolver->>Prisma: Delete emailVerification record
    Prisma->>Database: DELETE emailVerification
    AuthResolver-->>Client: Return true (email verified)
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Poem

🐰 Whiskers twitching with delight,
Sudan seeds now shine so bright!
Strings of ID dance anew,
Signals, Events, Notifications too!
Hopping through mutations with verified grace,
Our schema blooms in this grand place!

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/backend-port

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant