GithubHelp home page GithubHelp logo

yk-mt12 / go-graphql-mongodb-boilerplate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kazmerdome/go-graphql-mongodb-boilerplate

0.0 0.0 0.0 97 KB

go-gqlgen-mongo-driver-boilerplate

Shell 0.80% Go 96.11% Makefile 1.94% Dockerfile 1.15%

go-graphql-mongodb-boilerplate's Introduction

go-graphql-mongodb-boilerplate

Lightweight, easy-to-develop graphql server that includes all you need to build amazing projects ๐Ÿ”ฅ

  • ๐Ÿ”ฎ Gqlgen โ€” Generated, type safe Graphql for Go
  • ๐Ÿ‘ฝ Mongo Driver - The official Mongodb driver for Go
  • ๐Ÿถ Dataloaden โ€” Generated type safe data loaders for Go
  • ๐Ÿ“„ Echo - High performance, extensible, minimalist Go web framework

Features:

Server:

  • Using Labstack Echo
  • Restapi example
  • prometheus implementation
  • healthz - basic (demo only) health probe implementation

Graphql:

  • using the latest (0.13.0) Gqlgen version
  • playground security with http header password (Disable Introspection)
  • custom scalar example
  • dataloader examples (https://github.com/vektah/dataloaden) for n+1 problems

MongoDB

  • model examples
  • multiple db connections implementation

Other

  • Config package for reading and caching ENV-s from global env, kubernetes, or docker swarm
  • Using Makefile, Docker-compose for faster development

๐Ÿš€ Getting started

Development Mode

step1 - build local environment with docker-compose

  make generate
  make start

step2 - start the server (inside docker)

  make run

step3 - restart the server (inside docker)

  CTRL + C
  make run

regenerate gqlgen files

  CTRL + C
  make generate
  make run

open http://localhost:9090.

Enable Graphql Documentation:

add "Playground-Password": <GRAPHQL_PLAYGROUND_PASS> to request header

Working with Auth

add "Authorization": Bearer <JWT TOKEN> to request header

Create the first user

  • step 1 - create new user
  mutation {
    authBasicStrategySignUp(data: {
      email: "[email protected]"
      password: "xxxxx"
      username: "x"
    }) {
      token
    }
  }
  • step 2 - check created user
    query {
      userMe {
        email
        username
        role
      }
    }
  • step 2 - add ADMIN role to the generated user (through db admin [mongo atlas, robo3t, etc...])

Create New CRUD - TODO

  • step 1 - create the model
  • TODO

Production Mode

step0 - make sure to provide envs (copy .env file to build folder or provide global envs)

step1 - binary build

  make generate
  make build

step2 - run

  ./build/go-graphql-mongodb-boilerplate

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.