This project is a simple GraphQL server that you can use as a base of your next project.
Sometimes it's hard to set up convenient Development Environment and it may take a lot of time. In this project i've tried to make all that annoying things for you, and let you focus more on your code.
Also, master
branch of the repository is deployed to Heroku, so you can open GraphQL Playground and take a look at schema or test some Query/Mutation - https://gql-server.herokuapp.com/graphql
- Last JavaScript features, including imports/exports, thanks to Babel
- Server auto restarting on file changes with Nodemon
- Write clean code - ESLint with AirBnb config - most popular JavaScript code style
- Environment Variable configs with type validations - envalid
- Deployment to Heroku, a good way to start
- Install and start MongoDB server
- Install packages -
npm install
- Setup environment variables:
-
- Create
.env
file at root of the repository
- Create
-
- Set required variables. For most cases will be enough just copy and paste all content from
.env.example
file to.env
.
- Set required variables. For most cases will be enough just copy and paste all content from
- Start the server -
npm start
You can easily deploy this server to Heroku.
- Create application on Heroku dashboard
- Set Config Vars(Environment variables) in settings section of your application
Then
- Install and setup Heroku CLI - https://devcenter.heroku.com/articles/heroku-cli
- Add remote to the repository -
heroku git:remote -a your-app-name
- Push the repository to Heroku -
git push heroku master
Or, if you're using GitHub, you can setup Heroku GitHub Integration and all pushes to GitHub will automaticly trigger deployment to Heroku - https://devcenter.heroku.com/articles/github-integration
After each push to Heroku it will run npm script heroku-postbuild
that will create build of the server, then Heroku will run command from Procfile
file, in our case it's npm run start-build
- Clone this repository(or pull changes when updating) on your server
- Run
npm install
- Run
npm run build
to make build of the server - Set environment variables (create .env file or set them manually)
- Run
npm run start-build
OR
- Make build -
npm run build
- Somehow deploy your
build
folder,package.json
andpackage-lock.json
files to your server - Install packages -
npm install
- Set environment variables (create .env file or set them manually)
- Run
npm run start-build
- Babel & Nodemon
- ESLint - AirBnb style
- Sign In & Sign Up with JWT
- Basic Query/Mutation
- Deployment to Heroku
- Husky - Run ESLint before commits
- Dataloader
- Subscriptions
- TypeScript & Automatic type generation