Skip to content

Nestjs GraphQL best practice. Schema is based on Tolkien's Arda world data from lotr.fandom.com

License

Notifications You must be signed in to change notification settings

kiaksarg/nestjs-graphql-tolkien

Repository files navigation

nestjs-graphql-tolkien

NestJS GraphQL with TypeORM and MariaDB (MySQL)

Screenshot-Fellowship-of-the-Ring

Graphql-Fellowship-of-the-Ring.mp4

Database Migration

Check or change the database name, user and password in .env file

  1. Create database
  2. Create database user
  3. Make changes in .env file
  4. Run migrate command:
npm run migrate
  1. To generate migration file, if needed (it is already generated, so this step can be skipped):
npm run migration:gen

Database seeding

To seed the database run:

npm run seed:run

Sample Query

{
  cultures(
    options: {
      take: 100
      skip: 0
      sort: { name: ASC }
      filter: { name: { search: "Fellowship" } }
    }
  ) {
    totalItems
    items {
      id
      name
      characters(
        options: {
          take: 10
          skip: 0
          sort: { name: ASC }
          filter: { name: { search: "Gandalf" } }
        }
      ){
        totalItems
        items{
          id
          name
        }
      }
    }
  }
}

Entities

Characters

Locations

Cultures

Races

Artefacts

Battles

Quotes

Releases

No releases published

Packages

No packages published

Languages