{"id":28511130,"url":"https://github.com/xjectro/graphql-apollo-server","last_synced_at":"2026-03-06T09:02:24.207Z","repository":{"id":295481715,"uuid":"987808748","full_name":"Xjectro/graphql-apollo-server","owner":"Xjectro","description":"A modern GraphQL API server - showcasing best practices for building scalable and maintainable GraphQL services","archived":false,"fork":false,"pushed_at":"2025-06-11T12:42:10.000Z","size":28,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-06-22T11:35:52.772Z","etag":null,"topics":["graphql","node-js","nodejs","orm","postgresql","prisma","prisma-client","prisma-orm","typescript"],"latest_commit_sha":null,"homepage":"https://xjectro.com","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Xjectro.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-05-21T16:05:15.000Z","updated_at":"2025-05-30T22:30:00.000Z","dependencies_parsed_at":"2025-06-22T11:42:28.991Z","dependency_job_id":null,"html_url":"https://github.com/Xjectro/graphql-apollo-server","commit_stats":null,"previous_names":["xjectro/graphql-server","xjectro/graphql-apollo-server"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/Xjectro/graphql-apollo-server","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xjectro%2Fgraphql-apollo-server","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xjectro%2Fgraphql-apollo-server/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xjectro%2Fgraphql-apollo-server/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xjectro%2Fgraphql-apollo-server/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Xjectro","download_url":"https://codeload.github.com/Xjectro/graphql-apollo-server/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Xjectro%2Fgraphql-apollo-server/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30168608,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T07:56:45.623Z","status":"ssl_error","status_checked_at":"2026-03-06T07:55:55.621Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["graphql","node-js","nodejs","orm","postgresql","prisma","prisma-client","prisma-orm","typescript"],"created_at":"2025-06-08T23:07:16.448Z","updated_at":"2026-03-06T09:02:24.182Z","avatar_url":"https://github.com/Xjectro.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GraphQL Apollo Server ✨🚀\n\n\u003cdiv align=\"center\"\u003e\n  \n![GraphQL](https://img.shields.io/badge/-GraphQL-E10098?style=for-the-badge\u0026logo=graphql\u0026logoColor=white)\n![TypeScript](https://img.shields.io/badge/-TypeScript-007ACC?style=for-the-badge\u0026logo=typescript\u0026logoColor=white)\n![Prisma](https://img.shields.io/badge/-Prisma-2D3748?style=for-the-badge\u0026logo=prisma\u0026logoColor=white)\n![PostgreSQL](https://img.shields.io/badge/-PostgreSQL-336791?style=for-the-badge\u0026logo=postgresql\u0026logoColor=white)\n![Apollo GraphQL](https://img.shields.io/badge/-Apollo%20GraphQL-311C87?style=for-the-badge\u0026logo=apollo-graphql\u0026logoColor=white)\n![Docker](https://img.shields.io/badge/-Docker-2496ED?style=for-the-badge\u0026logo=docker\u0026logoColor=white)\n![Redis](https://img.shields.io/badge/-Redis-DC382D?style=for-the-badge\u0026logo=redis\u0026logoColor=white)\n\n\u003c/div\u003e\n\n\u003cp align=\"center\"\u003e🏗️ A modern GraphQL API server - showcasing best practices for building scalable and maintainable GraphQL services 🏗️\u003c/p\u003e\n\n## 📋 Table of Contents\n\n- [✨ Features](#-features)\n- [🛠️ Technology Stack](#️-technology-stack)\n- [🏗️ Architecture](#️-architecture)\n- [📁 Project Structure](#-project-structure)\n- [📝 GraphQL Schema](#-graphql-schema)\n- [🚀 Getting Started](#-getting-started)\n  - [🔧 Prerequisites](#-prerequisites)\n  - [⚙️ Installation](#️-installation)\n  - [🔑 Environment Variables](#-environment-variables)\n- [💻 Development](#-development)\n- [🗄️ Database Management](#️-database-management)\n- [🏭 Production Deployment](#-production-deployment)\n- [🐳 Docker Deployment](#-docker-deployment)\n- [📚 API Documentation](#-api-documentation)\n- [📄 License](#-license)\n\n## ✨ Features\n\n- **🔮 GraphQL API**: Robust GraphQL support with type checking powered by Apollo Server\n- **📝 TypeScript**: Fully typed codebase for improved developer experience and code quality\n- **🔐 Authentication \u0026 Authorization**: JWT-based authentication with role-based permissions\n- **🗃️ Database Integration**: PostgreSQL database with Prisma ORM for type-safe queries\n- **⚡ Caching**: Redis-based caching for improved performance\n- **📦 Docker Support**: Containerized deployment for consistent environments\n- **🧩 GraphQL Directives**: Custom directives for authentication and authorization control\n- **📈 Scalable Architecture**: Service-based architecture for maintainability and scalability\n\n## 🛠️ Technology Stack\n\n| Technology    | Description                                |\n| ------------- | ------------------------------------------ |\n| Node.js       | JavaScript runtime environment             |\n| TypeScript    | Typed JavaScript for better tooling        |\n| Apollo Server | GraphQL server implementation              |\n| Prisma        | Next-generation TypeScript ORM             |\n| PostgreSQL    | Powerful open-source relational database   |\n| Redis         | In-memory data structure store for caching |\n| Docker        | Containerization platform                  |\n| JWT           | JSON Web Token for authentication          |\n\n## 🏗️ Architecture\n\nThis API follows a layered architecture approach:\n\n```\nClient Request → GraphQL API → Resolvers → Services → Data Access (Prisma) → Database\n```\n\n- **📊 GraphQL Layer**: Handles incoming requests and response formatting\n- **🔄 Resolver Layer**: Maps GraphQL operations to service functions\n- **🧠 Service Layer**: Contains business logic and calls data access methods\n- **💾 Data Access Layer**: Interacts with the database via Prisma\n\n## 📁 Project Structure\n\n```\ngraphql/\n├── docker-compose.yml    # Docker compose configuration\n├── Dockerfile            # Docker configuration\n├── prisma/               # Prisma ORM configurations\n│   ├── schema.prisma     # Database schema\n│   └── migrations/       # Database migrations\n├── src/\n│   ├── graphql/          # GraphQL schemas and resolvers\n│   │   ├── directives/   # Custom GraphQL directives\n│   │   ├── resolvers/    # GraphQL resolvers\n│   │   └── schemas/      # GraphQL type definitions\n│   ├── models/           # Database client models\n│   │   ├── prisma.client.ts  # Prisma client\n│   │   └── redis.client.ts   # Redis client\n│   ├── services/         # Business logic services\n│   └── types/            # TypeScript type definitions\n└── ...\n```\n\n## 📝 GraphQL Schema\n\nThe GraphQL API provides the following core types and operations:\n\n### 📊 Types\n\n```graphql\n# User type\ntype User {\n  id: ID!\n  firstName: String!\n  lastName: String!\n  email: String!\n  password: String!\n  permission: Int!\n  createdAt: String!\n  updatedAt: String!\n}\n\n# Authentication response type\ntype AuthenticationResponse {\n  token: String\n}\n\n# Custom directives\ndirective @hasPermission(permission: Int!) on FIELD_DEFINITION\ndirective @authenticated on FIELD_DEFINITION\n```\n\n### 🔍 Queries\n\n```graphql\ntype Query {\n  currentUser: User @authenticated # Returns the currently logged-in user\n}\n```\n\n### 🔄 Mutations\n\n```graphql\ntype Mutation {\n  createUser(input: CreateUserInput!): CreateUserResponse! # Creates a new user\n  authentication(input: AuthenticationInput!): AuthenticationResponse! # Logs in a user and returns a token\n}\n\ninput CreateUserInput {\n  firstName: String!\n  lastName: String!\n  email: String!\n  password: String!\n}\n\ninput AuthenticationInput {\n  email: String!\n  password: String!\n}\n```\n\n## 🚀 Getting Started\n\n### 🔧 Prerequisites\n\n- Node.js 18+ ([Download](https://nodejs.org/))\n- PNPM 10+ ([Installation](https://pnpm.io/installation))\n- PostgreSQL ([Download](https://www.postgresql.org/download/))\n- Redis (optional, for caching) ([Download](https://redis.io/download))\n- Docker \u0026 Docker Compose (optional, for containerization) ([Download](https://www.docker.com/products/docker-desktop/))\n\n### ⚙️ Installation\n\n1. Clone the repository:\n\n   ```bash\n   git clone https://github.com/Xjectro/graphql-apollo-server\n   cd graphql-apollo-server\n   ```\n\n2. Install dependencies:\n\n   ```bash\n   pnpm install\n   ```\n\n3. Generate Prisma client:\n\n   ```bash\n   pnpm db:generate\n   ```\n\n### 🔑 Environment Variables\n\nCreate a `.env` file in the root directory:\n\n```dotenv\n# Database\nDATABASE_URL=\"postgresql://username:password@localhost:5432/database_name?schema=public\"\n\n# Authentication\nJWT_SECRET=\"your-secure-jwt-secret\"\nJWT_EXPIRES_IN=\"24h\"\n\n# Redis (Optional - for caching)\nREDIS_URL=\"redis://localhost:6379\"\nENABLE_CACHE=true\n\n# Server\nPORT=4000\nNODE_ENV=development\n```\n\n## 💻 Development\n\nRun the development server:\n\n```bash\npnpm dev\n```\n\nThe GraphQL playground will be available at: http://localhost:4000/graphql\n\n## 🗄️ Database Management\n\nThis project uses Prisma for database management. Available commands:\n\n```bash\n# Create and apply migrations based on schema changes\npnpm db:migrate\n\n# Apply existing migrations to the database\npnpm db:deploy\n\n# Check migration status\npnpm db:status\n\n# Regenerate Prisma client\npnpm db:generate\n\n# Reset database (caution: deletes all data)\npnpm db:reset\n\n# Push schema changes without migrations (for development)\npnpm db:push\n```\n\n## 🏭 Production Deployment\n\nBuild and start the production server:\n\n```bash\npnpm build\npnpm start\n```\n\n## 🐳 Docker Deployment\n\nBuild and run with Docker Compose:\n\n```bash\n# Start all services\npnpm docker\n\n# Stop all services\npnpm docker:stop\n\n# View logs\npnpm docker:logs\n```\n\nThe Docker setup includes:\n\n- GraphQL API server\n- PostgreSQL database\n- Redis cache\n\n## 📚 API Documentation\n\nWhen the server is running, you can access the GraphQL Playground at `http://localhost:4000/graphql`, which provides:\n\n- Interactive query builder\n- Schema documentation\n- Real-time testing of queries and mutations\n\n### 📝 Example Queries\n\n#### Create a new user\n\n```graphql\nmutation {\n  signUp(\n    input: {\n      firstName: \"John\"\n      lastName: \"Doe\"\n      email: \"john.doe@example.com\"\n      password: \"securePassword123\"\n    }\n  ) {\n    id\n    firstName\n    lastName\n    email\n  }\n}\n```\n\n#### Login\n\n```graphql\nmutation {\n  signIn(\n    input: { email: \"john.doe@example.com\", password: \"securePassword123\" }\n  ) {\n    token\n  }\n}\n```\n\n#### Get user profile (authentication required)\n\n```graphql\nquery {\n  currentUser {\n    id\n    firstName\n    lastName\n    email\n  }\n}\n```\n\n\u003e 🔐 Note: To use the `currentUser` query, you need to send a token in your HTTP headers as `Authorization: Bearer \u003ctoken\u003e`.\n\n## 📄 License\n\nThis project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxjectro%2Fgraphql-apollo-server","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxjectro%2Fgraphql-apollo-server","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxjectro%2Fgraphql-apollo-server/lists"}