Skip to content

rikeda71/go-gql-sqlc-template

Repository files navigation

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

Releases

No releases published

Packages

No packages published

Languages