Skip to content

Conversation

@clintjeff2
Copy link
Contributor

๐Ÿ“ Implement Order Module (CRUD + Status Update)

๐Ÿ› ๏ธ Issue

๐Ÿ“– Description

This pull request implements a full-featured GraphQL Order module using NestJS and Prisma. It includes all key CRUD operations and a robust order status update flow using enum-based validation.

โœ… Changes made

  • โœ… Created Order entity with GraphQL schema and Prisma model
  • โœ… Implemented CreateOrderInput, UpdateOrderStatusInput, and enum OrderStatus
  • โœ… Added query resolvers: getOrdersByBuyer, getOrdersBySeller, getOrder
  • โœ… Added mutation resolvers: createOrder, updateOrderStatus
  • โœ… Integrated GraphQL enum registration for OrderStatus
  • โœ… Fully tested mutations and queries via Postman
  • โœ… Implemented error handling and enum compatibility fixes

๐Ÿงช Testing Summary

All GraphQL queries and mutations were tested using Postman with variable-based requests, ensuring type safety and correct enum resolution in the schema.

๐Ÿ–ผ๏ธ Media (screenshots)

1. โœ… Order Test in Postman

Order TESTs

2. โœ… Complete Migration in Terminal

Migration Complete

3. โœ… Orders by Buyer Address

ORDER BY BUYER ADDRESSS

4. โœ… Orders by Seller Address

Order By seller address

5. โœ… Get Order by ID

Get order by id

6. โœ… Create Order

Create Order

7. โœ… Update Order Status

Update Order


@derianrddev derianrddev added backend ODHack13 This issue will be available ONLY during the ODHack13 labels Apr 26, 2025
@clintjeff2
Copy link
Contributor Author

Hello @derianrddev , I have already completed this task. I've just waiting for your review and hopefully a merge if everything is okay.

Copy link
Contributor

@derianrddev derianrddev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hello @clintjeff2

Please fix the linter errors, resolve the conflicts and apply the other requested changes โ€” and weโ€™ll be ready to merge!

You can check the linter issues by running:

npm run lint

APPROVED
}

model Order {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To keep consistency with the rest of the Prisma schema, the Order model should follow the same style:

  • Use camelCase field names in Prisma (productId, buyerAddress, etc.).
  • Use @map() to map to snake_case database columns (product_id, buyer_address, etc.).

Example:

model Order {
  id            String   @id @default(uuid())
  productId     String   @map("product_id")
  buyerAddress  String   @map("buyer_address")
  sellerAddress String   @map("seller_address")
  escrowId      String   @map("escrow_id")
  status        OrderStatus @default(PENDING)
  createdAt     DateTime @default(now()) @map("created_at")
  updatedAt     DateTime @updatedAt @map("updated_at")
  messages Message[]

  product        Product     @relation(fields: [productId], references: [id])

  @@map("orders")
}

This will match the style used in other models like Product and User.

Update the entity, service and tests to match the new field names.

@clintjeff2 clintjeff2 closed this Apr 27, 2025
@clintjeff2 clintjeff2 force-pushed the safeswap-order-graphql branch from ae9d4ff to be5c476 Compare April 27, 2025 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend ODHack13 This issue will be available ONLY during the ODHack13

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT]: Implement Orders Module (GraphQL API)

2 participants