Skip to content

Fully-feature modularized GraphQL Server boilerplate with production-ready containerized workflow.

Notifications You must be signed in to change notification settings

WhatTheFar/modularizing-graphql-boilerplate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

69 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Modularized GraphQL Boilerplate with Testing

CircleCI

Fully-feature modularized GraphQL Server boilerplate with production-ready containerized workflow.

Overview

  • Easiest way to run a GraphQL server: Sensible defaults & includes everything you need with minimal setup.
  • Practical: Built-in scripts to facilitate common workflows.
  • Production-ready: Containerized with nginx and letsencrypt configuration.
  • Testability: Including complete testing environment wih modular package.

This project is based on the following libraries & tools:

  • graphql-yoga: Fully-featured GraphQL server framework
  • graphql-shield: GraphQL Server permissions as another layer of abstraction!
  • merge-graphql-schemas: A utility library to facilitate merging of modularized GraphQL schemas and resolver objects.
  • prisma: GraphQL ORM-like* layer between between your GraphQL API and database
  • prisma-binding: GraphQL Binding for Prisma services (GraphQL Database)
  • graphql-playground: Interactive GraphQL IDE

Getting started

Configuration

Create a .env file in the root directory of your project. Add environment-specific variables on new lines in the form of NAME=VALUE.

See .env.example for example.

Clean project

To clean the project run following command(s).

bash scripts/clean-local.sh

Note: Recommended for the first run.

Run the project

  1. (Optional) Clean project, follow Clean Project topic above. (Recommended if you run for the first time).
  2. Start GraphQL server:
    bash scripts/run-local.sh
  3. (Optional) Start GraphQL Playground:
    bash scripts/graphql-playground.sh
    NOTE: To use desktop version of GraphQL Playground, download it from releases or install via Homebrew.

NOTE: This is a recommended method to run local dev server, but there is also an alternative method to optimise development cycle.

Seed the database

Seed initial data to database for development.

  1. Make sure you have run the project once.
  2. Recommended for an empty database. If database is dirty, there might occurs some error during the seed.
  3. Seed the database:
    bash scripts/run-seed.sh

Run the project (alternative)

This method is recommended for advanced docker user. See setup-dev.sh, run-dev.sh for more details of the scripts.

  1. Make sure you have run the project once, or run the following command to install dependencies.
    yarn
  2. Setting up dev environment:
    bash scripts/setup-dev.sh
  3. Run the server:
    bash scripts/run-dev.sh
    # OR
    bash scripts/run-debug.sh # To run server in debug mode
    NOTE: Debugger listening on port 9229, repeat step 3 to run server again

Testing

Run the test

  1. Make sure you have run the project once.
  2. Setting up test environment:
    bash scripts/setup-test.sh
  3. Run the test:
    bash scripts/run-test.sh
    # OR
    bash scripts/run-watch-test.sh # To run test in watch mode
    NOTE: Repeat step 3 to run test again

Build & Deploy

docker-compose -f docker-compose.yml -f docker-compose.prod.yml build --force-rm
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d

Contributing

Contributions are welcome and extremely helpful 🙌, feel free to make discussions and open a pull request.

This project use angular commit message guidelines, please refer to the guildlines for more information.

License

Copyright 2018 Jakpat Mingmongkolmitr

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

About

Fully-feature modularized GraphQL Server boilerplate with production-ready containerized workflow.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •