-
copy
./backend/.env.exampleto./backend/.envand./backend/prisma/.env.exampleto./backend/prisma/.envYou can leave all of the values in the files as is. -
make sure your current working directory is
./backend -
install dependencies
npm install -
run prisma migrations
npm run database:migrateIf this fails, its probably that prisma is not picking up the
.envfile, so you might need to set it manually: Windows - run in cmd:set DATABASE_URL=postgresql://mayoor-user:developer1@localhost:54320/mayoor-dbMacOS - run in shell:export DATABASE_URL=postgresql://mayoor-user:developer1@localhost:54320/mayoor-db -
seed the database with initial data
npm run database:seed -
run app in dev mode
npm run dev -
🚀open http://localhost:4444/graphql to view the GraphQL playground 🚀
-
(optional) To test, that the GraphQL server is working, copy and paste this query to the GraphQL playground:
mutation {
login(email: "admin", password: "admin") {
user {
name
email
role
}
token
}
}This repo is defined "schema-first", that means it uses Prisma Migrate to manipulate with the database schema, even though it is still experimental feature of Prisma.
E.g. adding a new database table:
- add it to the schema in
./prisma/schema.prisma(data modeling manual) - create a migration file for it by
npx prisma migrate save --experimental - run the migration against the database
npx prisma migrate up --experimental - generate the prisma types
npm run generate:prisma - ✅Now you should be able to access this object through Prisma Client
- test e.g. in any query resolver by accessing the Prisma Client in the context
./src/queries/customers/getCustomer.tstryctx.prisma.. and you should see the TypeScript Intellisense
- e.g. add a new GraphQL query to
./src/queries/material - add it to the index file in
./src/queries/index.ts - run
npm run generate:nexus - it should generate types for all of the queries arguments, return types etc. into
./src/generated/nexus.ts