An example of how to create and test a GraphQL Server with Nest.js and TypeORM
- GraphQL server with Apollo
- Code first approach to build the schema
- TypeORM to connect with MySQL
- Unit tests and E2E tests
- PNPM for a fast and efficient installation
- Check code quality with MegaLinter
- Check continuous integration with github actions
- Run the necessary services with docker compose
Clone the project
git clone https://github.com/leosuncin/nest-graphql-example.git
Go to the project directory
cd nest-graphql-example
Install dependencies
pnpm install
Create a .env
from the example one and customize it with your environment variables
cp .env.example .env
Start the services using Docker Compose
docker-compose up -d
Run migrations to create the DB schema
pnpm typeorm migration:run
Start the server
pnpm start:dev
To run this project, you will need to add the following environment variables to your .env file
MYSQL_DATABASE
the name of the database to connect in the MySQL instance (required)
MYSQL_ROOT_PASSWORD
The password of the root user to connect to the MySQL instance (required)
DATABASE_URL
a connection string to the MySQL instance, example mysql://root@localhost/example-db (required)
You can copy the example .env
and edit the values
cp .env.example .env
To run unit tests, run the following command:
pnpm test
To run e2e tests (the MySQL instance must be available), run the following command:
pnpm test:e2e
Server: Typescript, MySQL, Nest.js, TypeORM, Apollo
Test: Jest, SuperTest
DevOps: Docker Compose
👤 Jaime Leonardo Suncin Cruz
- Twitter: @jl_suncin
- Github: @leosuncin
- LinkedIn: @jaimesuncin
Give a ⭐️ if this project helped you!
Here are some more example projects with Nest.js
Release under the terms of GPL v3