This template project provides a streamlined setup for developing web backend APIs using Go, gqlgen, and sqlc. With built-in integrations for database migrations and task management, it simplifies the process of building and testing modern web applications, allowing for a focus on delivering features.
The go-gql-sqlc-template serves as a robust template project designed for creating Web Backend APIs using a powerful tech stack. This repository leverages several modern tools to streamline development, including:
- Go: A statically typed, compiled programming language renowned for its efficiency and simplicity.
- gqlgen: A framework for building GraphQL APIs with a focus on developer experience and performance by utilizing GraphQL schemas.
- sqlc: A SQL-based Object-Relational Mapping (ORM) tool that transforms SQL queries into type-safe Go code.
- dbmate: A straightforward database migration tool that facilitates schema management.
- task: A task runner for managing complex workflows with simple configurations.
API Development
This template streamlines the API setup process with commands for initializing, starting, and testing the backend service. For example, the command to start the API is:
$ task up
Followed by database migration with:
$ task migrate
Testing
The project includes options for running tests and integration tests seamlessly. Testing can be executed using:
$ task test
Development Features
In terms of development, the template offers utilities for generating API interfaces directly from the GraphQL schema and ORM code from SQL statements. Commands for these operations include:
$ task gql-gen
$ task sqlc-gen
Database Management
The template also provides commands for database operations, including migration and rollback functionalities:
$ task migrate
$ task rollback
This comprehensive setup allows developers to focus on building features without the distractions often associated with boilerplate configurations, making it an efficient starting point for any Go-based web backend project.
No comments yet.
Sign in to be the first to comment.