Clone the repository.
Install dependencies with yarn.
yarn
Fill out DATABASE_URL
at .env
(example: .env.example
).
# You can set up a local development database with docker compose.
# The default DATABASE_URL in .env.example connects to this db.
docker compose up -d
Migrate the database.
yarn prisma migrate dev --skip-seed
Seed some dummy data.
yarn prisma db seed
You can view database tables using Prisma Studio.
yarn prisma studio
You can reset the database with:
yarn prisma migrate reset --skip-seed
Some files (named as **/*.generated.*
) are automatically generated.
With the generation ordering:
-
Prisma & Nexus Types
Database types are generated from
src/prisma/schema.prisma
and stored innode_modules
.yarn generate:prisma
-
GraphQL Schema & Nexus Typings
After defining the GraphQL schema using
nexus
andnext-nexus
insrc/graphql/schema.ts
, we can generate the GraphQL schema filesrc/graphql/schema.generated.graphql
and the nexus typingstypes/nexus-typegen.generated.d.ts
by starting the server and initiating a query.yarn dev # and open browser http://localhost:3000/api/graphql
-
Urql GraphQL Types
From the back end generaged GraphQL schema
src/graphql/schema.generated.graphql
and the queries we wrote insrc/{pages,components}/**/*.{graphql,js,ts,jsx,tsx}
, we can generate the front end typessrc/graphql/codegen.generated.ts
.Read more in
codegen.yml
and GraphQL Code Generator.yarn generate:codegen
The generated files will be generated again before making a commit. See .husky/pre-commit
You can run all generations with:
yarn generate
yarn dev
The main page endpoint is at http://localhost:3000
.
The GraphQL endpoint is at http://localhost:3000/api/graphql
.