A full-featured GraphQL e-commerce API with product catalog, inventory management, orders, and reviews system.
- Product Management: Complete CRUD for products and categories
- Advanced Filtering: Filter products by category, price range, and availability
- Order System: Complete order lifecycle management
- Review System: Product reviews and ratings
- Inventory Tracking: Real-time inventory management
git clone
npm install
npm run dev# Search and filter products
query GetProducts($filter: ProductFilter) {
products(filter: $filter) {
id
name
price
inventory
category {
name
}
reviews {
rating
comment
}
}
}
# Variables:
{
"filter": {
"categoryId": "1",
"minPrice": 100,
"maxPrice": 1000,
"inStock": true
}
}# Place new order
mutation PlaceOrder($input: PlaceOrderInput!) {
placeOrder(input: $input) {
id
total
status
items {
product {
name
}
quantity
price
}
}
}
# Update order status
mutation UpdateOrder($id: ID!, $status: OrderStatus!) {
updateOrderStatus(id: $id, status: $status) {
id
status
}
}# Add new product
mutation CreateProduct($input: CreateProductInput!) {
createProduct(input: $input) {
id
name
price
inventory
}
}- Inventory Validation: Prevents overselling
- Price Calculation: Automatic total calculation
- Order Status Flow: Enforces valid status transitions
- Search Functionality: Full-text product search
graphql-ecommerce-api/
├── schema.graphql # E-commerce type definitions
├── resolvers.js # Business logic resolvers
├── server.js # Server configuration
├── data/ # Mock data (in production use DB)
│ ├── products.js
│ ├── categories.js
│ └── orders.js
├── package.json
└── README.md
- ✅ Product catalog browsing
- ✅ Advanced product filtering
- ✅ Order creation and management
- ✅ Inventory management
- ✅ Product reviews and ratings
- ✅ Category management
- ✅ Search functionality
Saad Abdur Razzaq
Machine Learning Engineer | Effixly AI