brkss / gogql

πŸ–‡οΈ Backend with Graphql, Sqlc and authentication

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

🍱 Golang Graphql Boilerplate

Golang, is a statically typed, compiled programming language designed at Google that aids in building simple, reliable, and efficient software. 99designs/gqlgen is go generate based graphql server library schema first, type safe and enables Codegen.

πŸ“š Description

This boilerplate leverages the Graphql to quickly prototype backend applications. It comes with database, logging, security, and authentication features out of the box.


🍬 Features

  • Based on gqlgen.

  • SQLC to Compile SQL to type-safe code for Postgres. But can support MYSQL, SQLite.

  • Paseto for token-based authentication, provide strong token signing algorithms out of the box.

  • godotenv for working with env configurations.


πŸ› οΈ Prerequisites

🐳 Docker

Please make sure to have Docker Desktop operational on the preferred operating system of choice to quickly get started. To get started, please see the following link.

Note: Despite the fact that Docker Desktop comes free for both Mac and Windows, it only supports the Pro edition of Windows 10. A common workaround is to get Docker Toolbox which will bypass the Windows 10 Pro restriction by executing Docker in a VM.


πŸ”¨ Getting Started

πŸ“¦ Packages to install

Migrate

$ brew install golang-migrate

Sqlc

$ brew install sqlc

Setup infrastructure

  • Create postgres container:

    make postgres
  • Start postgres container:

    make startdb
  • Create database:

    make createdb
  • Run db migration up all versions:

    make migrateup
  • Run db migration down all versions:

    make migratedown

How to generate code

  • Generate schema SQL file with DBML:

    make db_schema
  • Generate SQL CRUD with sqlc:

    make sqlc
  • Generate DB mock with gomock:

    make mock
  • Create a new db migration:

    migrate create -ext sql -dir db/migration -seq <migration_name>

How to run

  • Run server:

    make server
  • Run test:

    make test

About

πŸ–‡οΈ Backend with Graphql, Sqlc and authentication


Languages

Language:Go 53.9%Language:HTML 30.4%Language:Shell 11.5%Language:Makefile 2.9%Language:Dockerfile 1.2%