avimehenwal / express-graphql

schema-first graphQL api built using ts and expressjs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

express-graphql

sample graphQL using schema-first approach

How to run

Install the project dependencies using correct nodejs version. Install nvm to get the right nodejs version

nvm use
npm install --

start local postgres instance in a docker container and initialize it with sample data

npm run dev:db
npx prisma db seed

once database is up and running you can see and play with data from browser using the following command

npx prisma studio

NOTE: Kindly create a copy of .env file from sample .env-template file and update values as per needs. Finally, start the graphQL server using

npm start

this would expose the following 2 API Endpoints

endpoint description
http://localhost:4000/graphql without authorization check
http://localhost:4000/auth with some authorization checks

Api Tests

api tests using http-client

Tools and Tech used

This project uses following tools and technologies

  1. Apollo graphQL server
  2. Prisma as ORM layer
  3. docker to run local postgres instance
  4. API test are recorded on Thunder-Client, json file inside /docs
  5. Expressjs as production ready app server

Improvements

  1. I have used schema-first appraoch in this project. For bigger graphQL APIs it would be valuable to use more code-first appraoch to build and maintain graphQL schema
  2. express.js is solid contender for small to medium sized APIs devvelopment and manitenance. NestJS could be used to write more complex backend APIs with scales better in terms of maintenability and redability
  3. Write CRUD operations using queries and mutations
  4. api unittest could be written on top of integration
  5. proper JWT token could be used to secure the api
  6. Everything could be strongly typed for TS benefits
  7. could setup CI/CD pipelines to help with future development workflows

@ Reach Me @

available for new opportunity ...

Buy Me A Coffee

Spread Love ♥️ and not 🚫 hatred Twitter Follow

About

schema-first graphQL api built using ts and expressjs


Languages

Language:TypeScript 95.0%Language:Shell 2.6%Language:Dockerfile 2.5%