Documentation
¶
Overview ¶
Package users is the canonical "owns its data, exposes typed REST" module: a minimal user catalog tagged DeployAs("users-svc") so it can be peeled out into its own binary later.
Layout demonstrates multi-file shadow support:
types.go — public types (User, *Args) service.go — Service struct, constructor, plain methods handlers.go — gin/graphql handler shims module.go — Module declaration
Each file contributes to the same `users` package; the shadow generator strips Service/handlers/Module-related declarations from each file and synthesizes one zz_shadow_gen.go containing the HTTP-stub Service. Public types in types.go are preserved verbatim in the shadow build (they're called by checkout's signatures).
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Module = nexus.Module("users", nexus.DeployAs("users-svc"), nexus.Provide(NewService), nexus.AsRest("GET", "/users/:id", NewGet), nexus.AsRest("GET", "/users", NewList), nexus.AsQuery(NewSearch), )
Module is the wired declaration. DeployAs("users-svc") names this module's deployment unit — `nexus build --deployment X` uses it to decide whether to keep this package's hand-written code or substitute the shadow stub.
Functions ¶
This section is empty.
Types ¶
type GetArgs ¶
type GetArgs struct {
ID string `json:"id" uri:"id"`
}
GetArgs binds a path parameter named `id`. The framework's gin binding reads the `uri:"id"` tag; the shadow generator's path expansion reads the same tag — guaranteed to round-trip.
type ListArgs ¶
type ListArgs struct{}
ListArgs is empty — kept as a real type (rather than struct{}) so the generated method has a stable shape if filters are added.
type SearchArgs ¶ added in v0.13.0
type SearchArgs struct {
Prefix string `graphql:"prefix" json:"prefix"`
}
SearchArgs is the typed input for a GraphQL query.
type Service ¶
Service holds the in-memory store. Real implementations would back it with a DB; this stays simple to keep the example focused on the build-time transport switch. In binaries that don't own users, the shadow generator replaces this struct with an HTTP-stub variant whose methods route over PeerCaller — same public method set, same type identifier, different body.