A minimal GraphQL API that serves as the backend for the Working without direct database connection tutorial. AdminForth connects to this API instead of a database directly.
Exposes two entities — Apartment and AdminUser — via GraphQL queries and mutations backed by PostgreSQL through Prisma.
A running PostgreSQL instance. Quickest way with Docker:
docker run -d \
--name my-api-pg \
-e POSTGRES_USER=myuser \
-e POSTGRES_PASSWORD=mypassword \
-e POSTGRES_DB=mydb \
-p 5432:5432 \
postgres:16Or start a locally installed PostgreSQL:
sudo systemctl start postgresqlpnpm installCreate a .env file:
DATABASE_URL=postgresql://myuser:mypassword@localhost:5432/mydbRun the migration and generate the Prisma client (PostgreSQL must be running):
npx prisma migrate dev --name init && npx prisma generatenpx tsx index.tsAPI available at http://localhost:3001/graphql.