Code generation and the wrapper-entity runtime for
dgdao. Define Go structs, run
go generate, and get a fully typed client, query builders, auto-paging iterators, and
a CLI — all derived from your struct definitions.
dgdao-gen was extracted from dgdao. The generic typed client and
query primitives stay in dgdao; this project owns the generator and the
entity wrapper base that generated code embeds.
go get github.com/dgraph-io/dgdao-gen
Add a go:generate directive next to your schema structs:
//go:generate go run github.com/dgraph-io/dgdao-gen/cmd/dgdao-gen -entitiesthen run go generate ./....
Generated code imports the generic primitives from dgdao/typed and the wrapper
base from dgdao-gen/wrap:
import (
"github.com/dgraph-io/dgdao/typed"
"github.com/dgraph-io/dgdao-gen/wrap"
)Part of the dgdao family:
- dgdao — core typed client and DAO library for Dgraph
- dgdao-migrate — struct-first schema migration framework for Dgraph
- dgdao-telemetry — OpenTelemetry instrumentation for the dgdao typed client