/nestjs-graphql-mysql-dev-ops-starter

An easy to manage starter project for NestJs. Includes unit testing with reporting, and coverage, database access, and some sort of data fixtures.

Primary LanguageTypeScriptMIT LicenseMIT

ZenHub Unit Testing Building Coverage Status Maintainability Test Coverage Commitizen Friendly

Installation

npm install

Running

This example requires a local MySQL installation. See .env.example for credentials, and make sure there are matching credentials in the database and the .env file. The .env.dev file contains variable definitions for the development environment. The .env.test file containst variable definitions for the test environment (used on TravisCI, too). The .env file is left uncommitted as it is supposed to hold production secrets.

Run the sample

Then, run Nest as usual:

npm run start

or, for development settings:

npm run start:dev

Playground

After running Point your browser at http://localhost:3000/graphql

A simple query

query {
  getCats {
    id
    name
    age
  }
}

Where the query keyword is optional.

A simple mutation

mutation CreateCat($data: CreateCatInput) {
  createCat(createCatInput: $data) {
    name
    age
  }
}

Mutation data (as $data above)

{
  "data": {
    "name": "name3",
    "age": 5
  }
}

A simple subscription

subscription catCreated {
  catCreated {
    name
    age
  }
}