banking-graphql-server-proxy
v1.3.8
Published
GraphQL server proxy for banking operations
Readme
Banking GraphQL Server Proxy
A GraphQL server for banking operations built with GraphQL Yoga 5.x, following enterprise-grade patterns and best practices.
Tech Stack
- Runtime: Node.js 22
- Language: TypeScript 5.3+
- GraphQL Server: GraphQL Yoga 5.x
- Schema Tools: @graphql-tools/schema
- Development: tsx with hot reload
Quick Start
Install dependencies:
npm installRun in development mode:
npm run devBuild for production:
npm run buildStart production server:
npm startDevelopment
The server will start on port 4000 by default. You can access:
- GraphiQL Interface: http://localhost:4000/graphql
- GraphQL Endpoint: http://localhost:4000/graphql
- Health Check: http://localhost:4000/_healthcheck
GraphQL Schema
The banking schema is defined explicitly in schema.graphql with comprehensive type definitions extracted from banking-schema.json:
Important: The BankingBalance type includes all 32 fields from the original schema, including:
- Float balances:
totalBalance,realBalance,lockedRealBalance,vaultBalance,cashierBalance - Money objects:
totalBalanceMoney,realBalanceMoney,lockedRealBalanceMoney, etc. lockedMethodBalances: Array ofBankingMethodBalancefor locked funds by payment method
Queries
banking- Root entry point for all banking operations
Mutations (14 operations)
bankingCancelWithdraw- Cancel a pending withdrawalbankingSubmitWithdraw- Submit withdrawal requestbankingSubmitCryptoWithdraw- Submit cryptocurrency withdrawalbankingSubmitExchangeTransfer- Exchange between currenciesbankingStartPaymentSession- Start payment sessionbankingSubmitFiatDeposit- Submit fiat depositbankingSubmitFiatWithdraw- Submit fiat withdrawalbankingDeleteFiatAccount- Delete fiat accountbankingSubmitPaymentProof- Submit payment proofbankingGetEncryptionScriptUrl- Get encryption script URLbankingBitlipaTopup- Bitlipa topup operationbankingLabTransferOut- Lab transfer outbankingSubmitVaultDeposit- Submit vault depositbankingSubmitVaultWithdraw- Submit vault withdrawal
Subscriptions (5 real-time events)
bankingMyDepositAdded- New deposit notificationbankingMyDepositChanged- Deposit update notificationbankingMyWithdrawAdded- New withdrawal notificationbankingMyWithdrawChanged- Withdrawal update notificationsportsbetNewGraphqlUpdateStatsWithdraws- Withdrawal stats update
Relay-Style Pagination
This service implements Relay-style cursor-based pagination for ALL list fields following the Relay Cursor Connections Specification.
Paginated Fields
All of these fields return Connection types with edges and nodes:
myBalances→BankingBalanceConnectionmyAllBalances→BankingBalanceConnectionmyDeposits→BankingDepositConnectionmyWithdraws→BankingWithdrawConnectionmyTransactions→BankingTransactionConnection
Pagination Arguments
All paginated fields support these arguments:
first: Int- Get first N items (forward pagination)after: String- Cursor to start from (forward pagination)last: Int- Get last N items (backward pagination)before: String- Cursor to end at (backward pagination)
Connection Response Structure
type Connection {
edges: [Edge!]! # List of edges containing cursor + node
pageInfo: PageInfo! # Pagination metadata
totalCount: Int! # Total number of items
}
type Edge {
cursor: String! # Opaque cursor for this item
node: Item! # The actual data item
}
type PageInfo {
hasNextPage: Boolean! # More items after endCursor?
hasPreviousPage: Boolean! # More items before startCursor?
startCursor: String # Cursor of first edge
endCursor: String # Cursor of last edge
}Example Query (Basic)
query GetBanking {
banking {
id
myBalances {
currency
available
locked
total
}
depositAndWithdrawLimits {
minDeposit
maxDeposit
minWithdraw
maxWithdraw
}
canUserWithdraw
hasAnyTransactions
}
}Example Query (With Pagination)
query GetBankingWithPagination {
banking {
id
# Get first 5 balances with edges and nodes
myBalances(first: 5) {
edges {
cursor
node {
id
currency
totalBalance
realBalance
lockedRealBalance
# Money objects
totalBalanceMoney {
amount
currency
}
# Locked method balances
lockedMethodBalances {
method
money {
amount
currency
}
targetCurrency
}
}
}
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
totalCount
}
# Get first 10 deposits
myDeposits(first: 10) {
edges {
cursor
node {
id
amount
currency
status
createTime
}
}
pageInfo {
hasNextPage
hasPreviousPage
startCursor
endCursor
}
totalCount
}
}
}
# Get next page using endCursor from previous query
query GetNextPage {
banking {
myDeposits(first: 10, after: "YXJyYXljb25uZWN0aW9uOjk=") {
edges {
cursor
node {
id
amount
}
}
pageInfo {
hasNextPage
endCursor
}
}
}
}Example Mutation
mutation SubmitWithdraw {
bankingSubmitWithdraw(amount: 100.50, currency: "USD") {
withdrawId
success
message
}
}Architecture
This project follows the patterns documented in PROJECT_GUIDELINES.md:
Code Style
- ✅ Arrow functions only - All functions use arrow syntax
- ✅ Async/await - No promise chains, consistent async patterns
- ✅ No errors field in responses - GraphQL framework handles errors
- ✅ Type safety - Full TypeScript types throughout
Project Structure
src/
├── index.ts # Server entry point with GraphQL Yoga
├── resolvers.ts # GraphQL resolvers (queries & mutations)
├── mocks.ts # Mock data generators
└── utils/
└── context.ts # GraphQL context extractionKey Features
- GraphQL Yoga 5.x - Modern, lightweight GraphQL server
- Type-safe resolvers - Full TypeScript support
- Health check endpoint - For load balancers and orchestrators
- Graceful shutdown - Handles SIGTERM/SIGINT signals
- CORS enabled - Configured for cross-origin requests
- GraphiQL interface - Built-in GraphQL playground
Environment Variables
Optional:
SERVICE_PORT- Server port (default: 4000)
NPM Scripts
npm run dev- Start development server with tsx hot reloadnpm run build- Compile TypeScript to JavaScriptnpm run compile- Alias for buildnpm start- Run compiled servernpm run typecheck- Run TypeScript type checking
Guidelines
This codebase follows strict architectural guidelines:
- Read
PROJECT_GUIDELINES.mdbefore making changes - Read
AGENTS.mdfor functional programming patterns - Use arrow functions exclusively
- Never include
errorsfield in resolver responses - Use async/await throughout
- Follow emoji logging conventions (🚀 ✅ 🔄 ❌ ⚠️)
Current Status
This is a working mock implementation. All mutations and queries return mock data. To integrate with a real banking backend:
- Replace mock responses in
src/mocks.tswith actual API calls - Add authentication/authorization logic in
src/utils/context.ts - Implement caching layer (Redis recommended per PROJECT_GUIDELINES.md)
- Add proper error handling and validation
- Configure environment variables for external APIs
License
ISC
