Skip to content

Working with Flyway, Prisma, NestJS and GraphQL

afwilcox edited this page Feb 6, 2024 · 1 revision

See below for a common developer workflow for a schema first approach to adding new entities to the project:

  1. Create DDL scripts that are stored in the migrations directory and run these scripts against your local database

  2. Run the following command to sync the prisma schema with the database:

  • npx prisma db pull
  1. Run the following command to generate the prisma client:
  • npx prisma generate
  1. There is a bit of a weird bug with prisma / VS Code at this point... See: https://stackoverflow.com/questions/65663292/prisma-schema-not-updating-properly-after-adding-new-fields
  • Restart VS Code or
  • Restart CS Code language server or
  • Open file node_modules/.prisma/client/index.d.ts
  1. Generate the required nestJS objects through the following command:
  • npx nest g resource
  • select 'GraphQL (schema first)'
  • Optionally create CRUD entry points depending on what you are doing
  1. Make required changes to the generated entities. At a minimum you will need to:
  • Add a graphQL schema file to define your queries and mutations
  • Import the prisma module as the first argument to the new module and specs
  • Add required functions to the resolver and service to implement the new functionality
Clone this wiki locally