nest-graphql-example

Example of GraphQL with Nest.js and TypeORM

GPL-3.0 License

Stars
9

🎲 Nest.js GraphQL Example

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

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

License

Release under the terms of GPL v3