A template for boostrapping a backend service(GraphQL & Restful) using Apollo Server + Nexus + Prisma stack, with various other useful tools like devops, testing, etc.
- Apollo Server v4 (with Koa integration): Run GraphQL & Http server
- Nexus: Writing code-first GraphQL schema
- Prisma v4: ORM
- Postgres: Relational Database
- jest: Unit tests
- Github Action: CI
- Helm: CD
📦 Sample App
┣ 📂 .github # Pipeline definition code.
┃ ┣ 📂 .github/workflows/cd.yml # GitHub action workflow.
┃ ┣ 📂 .github/deploy.yml # Deliverybot configuration file.
┣ 📂 infra # docker files and helm charts that manage our infrastructure.
┃ ┣ 📂 config # Contains value files per environment.
┣ 📂 prisma # Prisma schema.
┣ 📂 scripts # Some bash scripts need be to executed through pipeline。
┣ 📂 src
┃ ┣ 📂 common # Common stuff like constants, helpers functions。
┃ ┣ 📂 graqhpl # Graphql schema, types, resolvers。
┃ ┣ 📂 middleware # Koa middlewares.
┃ ┣ 📂 restful # Restful Koa route.
┃ ┣ 📂 setupServer # Setup koa + apollo server.
┃ ┣ 📂 types # TypeScript type definitions.
┃ ┣ 📂 utils
┃ ┣ 📂 app # service entrypoint.
┃ ┣ 📂 db # The PrismaClient after applying prisma middlewares.
┃ ┗ 📂 logger # Logger for recording information/debug.
┣ 📂 tests # Jest tests.
┗ 📜 package.json
- Start postgres database
- Create a new db named
anp-sample
- OR you could run db via docker-compose
docker-compose -f infra/docker-compose/dev.yml up -d
- Create a new db named
cp sample.env .env
, copy thesample.env
into.env
fileyarn
, install dependenciesyarn db:new-migration init
, migrate db & seed data (only the first time)yarn dev
, run service, go to http://localhost:4000/graphqlyarn studio
, this is optional, then go to http://localhost:5555 and explore data.yarn test
, run alljest
unit test.- Explore
package.json -> scripts
for more commands.