Project template for authoring GraphQL server applications with Node.js 7+ and JavaScript (demo). You can use it either as a playground or a base for your next Node.js-based backend project.
.
├── /build/ # The compiled output (via Babel)
├── /migrations/ # Database schema migrations
├── /node_modules/ # Project dependencies (npm modules)
├── /scripts/ # Build automation scripts
├── /src/ # Node.js application source files
│ ├── /db/ # Database access methods and connection pooling
│ ├── /passport/ # Passport.js authentication strategies
│ ├── /routes/ # Express routes, e.g. /login/facebook
│ ├── /types/ # GraphQL types /w resolve functions
│ │ ├── /User.js # User account (id, email, etc.)
│ │ ├── /Viewer.js # The top-level GraphQL object type
│ │ └── /... # etc.
│ ├── /utils/ # Utility functions
│ ├── /app.js # Express application
│ ├── /schema.js # GraphQL schema
│ └── /server.js # Node.js server (entry point)
├── /test/ # Unit, integration and load tests
├── .env # Application settings for the dev environment
├── package.json # The list of project dependencies
└── yarn.lock # Fixed versions of all the dependencies
- OS X, Windows or Linux
- Node.js v6 or newer + Yarn package manager
- PostgreSQL v9.5 or newer (see how to install PostgreSQL on a dev machine)
- Text editor or IDE (e.g. VS Code, WebStorm etc.)
Just clone the repo and start hacking:
git clone -o graphql-starter-kit -b master --single-branch \
https://github.com/kriasoft/graphql-starter-kit.git api.example.com
cd api.example.com
yarn install # Install project dependencies. Alternatively, npm install
npm run db:create # Create a new database (see .env/DATABASE_URL)
npm run db:migrate # Migrate database schema to the latest version
npm run start # Launch the app. Alternatively, node scripts/start.js
The GraphQL server should become available at http://localhost:5000/ (live demo).
If you just need to build the project without launching a dev server, run one of these two commands:
npm run build # Compiles the app into the /build folder
npm run build:watch # Compiles the app and starts watching for changes
The following scripts can be used to transfer your existing database into another state and vise
versa. Those state transitions are saved in migration files (/migrations/*.js
), which describe
the way how to get to the new state and how to revert the changes in order to get back to the old
state.
npm run db:create # Create a new database
npm run db:drop # Drop the database
npm run db:version # Print database schema version
npm run db:migrate # Migrate database schema to the latest version
npm run db:migrate:undo # Rollback the latest migration
npm run db:migration <name> # Create a new migration from the template (see /migrations folder)
npm run db:seed # Import reference data
npm run lint # Find problematic patterns in code
npm run check # Check source code for type errors
npm run test # Run unit tests once
npm run test:watch # Run unit tests in watch mode
# Option 1:
npm run build && node build/server.js --debug --nolazy
# Option 2:
npm run start -- --debug --nolazy
After launching the app in a debug mode attach your debugger
to the process listening on 127.0.0.1:5858
.
Anyone and everyone is welcome to contribute. Start by checking out the list of open issues marked help wanted. However, if you decide to get involved, please take a moment to review the guidelines:
- GraphQL.js — The JavaScript reference implementation for GraphQL
- React Starter Kit — Isomorphic web app boilerplate (React, Node.js, Babel, Webpack, CSS Modules)
- React Static Boilerplate — Single-page application (SPA) starter kit (React, Redux, Webpack, Firebase)
- Membership Database — SQL schema boilerplate for user accounts, profiles, roles, and auth claims
- #react-starter-kit on Stack Overflow — Questions and answers
- #react-starter-kit on Gitter — Watch announcements, share ideas and feedback
- GitHub Issues — Check open issues, send feature requests
- @koistya on Codementor or HackHands — Private consulting
Copyright © 2016-present Kriasoft, LLC. This source code is licensed under the MIT license found in the LICENSE.txt file. The documentation to the project is licensed under the CC BY-SA 4.0 license.
Made with ♥ by Konstantin Tarkus (@koistya) and contributors