GraphQL API server implemented using code-first development approach and optimized for hosting in a serverless environment such as Google Cloud Functions or Google Cloud Run.
This project was bootstrapped with GraphQL API Starter Kit. Be sure to join our Discord channel for assistance.
- Node.js
v16
, Yarn, TypeScript, Babel, Prettier, ESLint — core platform and dev tools - GraphQL.js, GraphQL.js Relay, DataLoader, Validator.js — GraphQL schema and API endpoint(s)
- PostgreSQL, Knex.js,
pg
,@google-cloud/storage
— data access jose
,google-auth-library
— stateless JWT-based sessions and authentication- Jest - unit and snapshot testing
.
├── auth/ # Authentication middleware
├── core/ # Common application modules
├── db/ # PostgreSQL client and query builder
├── mutations/ # GraphQL API mutation endpoints
├── queries/ # Top-level GraphQL API query fields
├── types/ # GrapHQL API schema types
├── utils/ # Helper / utility functions
├── views/ # Handlebar views
├── context.ts # GraphQL API context variable(s)
├── env.ts # Environment variables validator
├── errors.ts # Application errors middleware
├── global.d.ts # TypeScript definition overrides
├── graphql.ts # GraphQL API schema
├── index.ts # Node.js / Express server
├── package.json # Node.js dependencies
├── rollup.config.js # Rollup bundler configuration
├── schema.graphql # GraphQL schema (auto-generated)
└── tsconfig.json # TypeScript configuration
- Node.js v16 or higher, Yarn package manager
- Local or remote instance of PostgreSQL (see Postgres.app, Google Cloud SQL)
- VS Code editor (highly recommended)
Ensure that the database schema and data is up-to-date by running:
$ yarn db:reset # Re-creates the database and applies migrations and seeds
Launch the app in development mode:
$ yarn api:start # Launch the API server on http://localhost:8080/
$ yarn api:start-debug # Alternatively, launch it with a debugger (chrome inspector)
Optionally pass the --env=#0
argument with one of the pre-configured
environments — dev
(default), local
, test
, or prod
.
The app must become available on http://localhost:8080/api
.
$ yarn g:lint [--no-cache] # Lint code with ESLint
$ yarn g:test # Run unit tests with Jest
$ yarn tsc # Check the code for type errors using TypeScript
Use yarn start-debug
instead of yarn start
then attach VS Code debugger to
the running instance of the app.
$ yarn api:build
$ yarn api:deploy [--version #0] [--env #0]