Skip to content

leosuncin/nest-graphql-example

Repository files navigation

🎲 Nest.js GraphQL Example

MegaLinter CI Prettier GPL v3 License HitCount

An example of how to create and test a GraphQL Server with Nest.js and TypeORM

Nest Logo

Features

Run Locally

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

Environment Variables

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

Running Tests

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

Tech Stack

Server: Typescript, MySQL, Nest.js, TypeORM, Apollo

Test: Jest, SuperTest

DevOps: Docker Compose

Author

👤 Jaime Leonardo Suncin Cruz

Show your support

Give a ⭐️ if this project helped you!

Related

Here are some more example projects with Nest.js

Authentication example

API example

TypeORM custom repository

License

Release under the terms of GPL v3