go-gql-sqlc-template

module
v0.0.0-...-be31693 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 13, 2024 License: MIT

README

go-gql-sqlc-template

Template Project of Web Backend API

Use Following Techstack

  • Go : Modern Programing Language
  • gqlgen : Use GraphQL Schema
  • sqlc : SQL based OR Mapper
  • dbmate : Migration Tool
  • task : Task Runner

Setup

Installation

Assuming the use of MacOS

  1. Install followings
  • Go 1.23
  • Docker Environmet (ex. Docker Desktop)
  1. Execute following commands

    $ go install github.com/go-task/task/v3/cmd/task@latest
    $ task setup
    # add 'export PATH="/opt/homebrew/opt/libpq/bin:$PATH"' to .zshrc etc.
    

Start API

$ task up
# wait a minutes...
$ task migrate # setup db

Test

$ task test
Integration Test
$ task integration-test

Development

Generate API I/F From Graphql Schema
$ task gql-gen
Generate DB I/F From SQL
# OR Mapper Code from DML
$ task sqlc-gen

# Model Code from DDL
$ task migrate # generate `db/schema.sql` through `dbmate migrate`
$ task sqlc-gen
DB Operations
# migrate
$ task migrate

# rollback
$ task rollback

Directories

Path Synopsis
cmd
api
test

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL