Code Monkey home page Code Monkey logo

modularizing-graphql-boilerplate's Introduction

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.

modularizing-graphql-boilerplate's People

Contributors

renovate-bot avatar renovate[bot] avatar whatthefar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.