This is a boilerplate for Apollo Server 4 with Typescript, Kysely, Apollo Server, Express, and Postgres.
This boilerplate offers the three main features of GraphQL: Queries, Mutations, and Subscriptions.
Requirements: Docker, PNPM, Node.JS
- Clone the repository
- Cpoy the
.env.example
file to.env
and fill in the environment variables - Run
pnpm install
- Run
docker-compose up -d
to start the Postgres database - Run
pnpm dev
to start the server
To run the database migrations, run the following command:
pnpm db:migrate:up # To run the migrations
pnpm db:migrate:down # To run the migrations
touch src/db/migrations/number.quick-name-description.ts
# Example of a migration file 0001.create-users-table.ts
This will be the content of the migration file:
import { Kysely, sql } from 'kysely';
export async function up(db: Kysely<any>): Promise<void> {
sql`
`.execute(db);
}
export async function down(db: Kysely<any>): Promise<void> {
sql`
`.execute(db);
}
It follows a modular structure, where each module has its own folder with the following structure:
src
├── modules
│ ├── module-name
│ │ ├── resolvers.module-name.ts
│ │ ├── types.module-name.ts
│ │ ├── index.ts
Feel free to contribute to this project by creating a pull request, or creating an issue. If you want to fork this project, please give credit to the original author.
- ESLint is used for linting
- Prettier is used for formatting
- Typescript is used for type checking
To run the linting and formatting, run the following command:
pnpm lint # eslint
pnpm format # prettier
pnpm check-types # typescript type checking