Build GraphQL APIs in Go. Fast.
Documentation • Quick Start • 中文
Lighthouse is a batteries-included GraphQL framework for Go. Define your schema, run one command, and get a production-ready API with DataLoaders, authentication, and database migrations.
type User @loader(keys: ["id"]) {
id: ID!
name: String! @varchar(length: 100)
posts: [Post!]! @goField(forceResolver: true)
}
extend type Query {
me: User! @auth
}lighthouse generate:schema # That's it. Models, resolvers, dataloaders generated.| Feature | Description |
|---|---|
| Schema-First | Define GraphQL schema, generate Go code |
| DataLoader | Auto-generated, N+1 problem solved |
| Auth Directives | @auth, @own built-in |
| Database | GORM + MySQL, connection pooling, master-slave |
| Migrations | Atlas-powered schema migrations |
| Queue | Redis-based async jobs (asynq) |
| Messaging | NATS pub/sub for real-time |
| Storage | S3/MinIO/COS unified interface |
| Metrics | Prometheus + health checks |
# Install
go install github.com/light-speak/lighthouse@latest
# Create project
lighthouse generate:init --module github.com/you/myapp --models user,post
cd myapp
# Configure .env, then run
go run . app:startOpen http://localhost:8080 → GraphQL Playground ready.
myapp/
├── schema/ # GraphQL definitions
├── models/ # Generated Go structs
├── resolver/ # Your business logic
├── graph/ # gqlgen generated (don't touch)
├── commands/ # CLI commands
├── server/ # HTTP server setup
└── migrations/ # Database migrations
- gqlgen - GraphQL engine
- GORM - ORM
- Atlas - Migrations
- asynq - Job queue
- NATS - Messaging
- zerolog - Logging
PRs welcome. Open an issue first for major changes.
MIT
Built with ☕ by Light Speak