- Introduction
- Features
- Tech Stack
- GraphQL Overview
- Project Structure
- Setup and Installation
- Usage
- API Endpoints
- Docker Configuration
- License
The GraphQL Thread Application is a very basic and simple backend project built to demonstrate the implementation of GraphQL with Apollo Server, Prisma, and Express.js. This application provides APIs to manage users and todos. This readme file also contains some useful info about GraphQL.
- 🚀 GraphQL API with Queries and Mutations.
- 🛠 Prisma ORM for database management.
- 🌐 Mock data integration using JSONPlaceholder.
- 🔒 Secure API access with JWT-based authentication.
- 🐳 Dockerized PostgreSQL database for streamlined development.
- ⚡ Real-time capabilities via GraphQL subscriptions.
- Backend Framework: Node.js with Express.js
- GraphQL Server: Apollo Server
- Database: PostgreSQL (via Prisma ORM)
- Authentication: JSON Web Tokens (JWT)
- Development Tools: TypeScript, Docker, and Nodemon
GraphQL is a query language for APIs and a runtime for executing those queries against your data. It enables clients to request only the data they need, making it highly efficient and flexible.
- Efficient Data Fetching: Clients can fetch multiple resources in a single request.
- Strong Typing: Schema defines data types, ensuring API reliability.
- Versionless API: Avoid breaking changes by evolving the schema instead of creating new endpoints.
- Real-time Functionality: Easily supports subscriptions for real-time updates.
- When your client needs precise control over the data it fetches.
- When working with complex relationships between data entities.
- When building applications with multiple frontends (e.g., mobile and web) consuming the same backend.
- For real-time applications needing subscriptions.
- For simple, flat data models where REST can suffice.
- When caching is critical, as REST APIs work more naturally with HTTP caching.
- When your project lacks experienced developers familiar with GraphQL’s learning curve.
- If over-fetching is not a concern and REST endpoints already exist.
GraphQL_ThreadApp/
|-- basics/
|-- server/
|-- index.js
|-- package.json
|-- thread-app-backend/
|-- src/
|-- graphql/
|-- services/
|-- db.ts
|-- index.ts
|-- prisma/
|-- package.json
|-- docker-compose.yml
|-- README.md
- 🖥 Node.js (v16 or higher)
- 🐳 Docker (for PostgreSQL setup)
- pnpm (Preferred package manager)
-
Clone the repository:
git clone https://github.com/ThisChirag/GraphQL_ThreadApp.git cd GraphQL_ThreadApp
-
Install dependencies:
pnpm install
-
Setup the database with Docker:
docker-compose up -d
-
Apply Prisma migrations:
pnpm prisma migrate dev
-
Start the backend server:
pnpm dev
The server exposes a GraphQL endpoint at:
http://localhost:8000/graphql
getTodos
: Fetch all todos.getAllUsers
: Fetch all users.getUser(id: ID!)
: Fetch a single user by ID.
createUser(firstName: String!, lastName: String!, email: String!, password: String!): String
: Create a new user.
This project includes a docker-compose.yml
file for setting up a PostgreSQL database.
- Postgres Service:
- Image:
postgres
- Port:
5432
- Image:
To start the services:
docker-compose up -d
To stop the services:
docker-compose down
This project is licensed under the MIT License. See the LICENSE file for more details.
Thank you for exploring the GraphQL Thread Application. Happy coding! 🎉