A modern GraphQL API built with Fastify, GraphQL Yoga y Pothos, siguiendo los más altos estándares de ingeniería de software: SOLID, KISS, DRY y Clean Code.
Repository: https://github.com/jodurpar/GraphQlTest
This API allows querying SQL Server instances to retrieve information from databases and tables in a dynamic and secure way.
- SOLID Architecture: Total decoupling using Dependency Injection (
tsyringe). - Code-First Architecture: The GraphQL schema is automatically generated from TypeScript code with Pothos.
- Security: Protection against SQL Injection using typed repositories and input sanitization (
[dbSafe]). - Flexible & Dynamic: Retrieve data from any table with support for pagination (
limit,offset) and optional column filtering (field). - Docker Ready: Optimized multi-stage Dockerfile for Node.js 20 with root-level configuration.
- VS Code Ready: Includes debug configurations, recommended extensions, and formatting settings.
./GraphQlTest: Main TypeScript source code folder../.vscode: Editor configurations, recommended extensions, and debugging.docker-compose.yml&dockerfile: Deployment configuration at the root.TestMe.md: Quick manual testing guide.
- Node.js v20+ (or Docker)
- SQL Server
# Enter the project folder
cd GraphQlTest
# Install dependencies
npm install
# Start in development mode (tsx watch)
npm run devThe project includes an optimized .vscode folder:
- Debugging: Press F5 or use the "Run and Debug" tab to start the local server with breakpoints.
- Formatting: Prettier and ESLint configured to run automatically on save.
- Extensions: Automatic recommendations for GraphQL, Docker, and ESLint.
The application is ready to run in containers from the root directory.
# From the main directory (where this README is located)
docker-compose up -d --buildThe API will be available at http://localhost:15250/graphql.
query {
allDatabases {
name
}
}query {
oneDatabase(name: "Test") {
name
tables {
name
totalRows
}
}
}query {
oneDatabase(name: "Test") {
tables {
name
rows(field: "Name", limit: 5, offset: 0)
}
}
}cd GraphQlTest
npm testRemastered with ❤️ to comply with SOLID and Clean Code.