Documentation
¶
Overview ¶
Package registry stores metadata about every endpoint a nexus app exposes. It is the source of truth the dashboard reads from.
Index ¶
- type Endpoint
- type GraphQLArg
- type GraphQLUpdate
- type GraphQLValidator
- type Registry
- func (r *Registry) AttachResource(serviceName, resourceName string)
- func (r *Registry) DefaultOfKind(kind resource.Kind) resource.Resource
- func (r *Registry) Endpoints() []Endpoint
- func (r *Registry) EndpointsByService(name string) []Endpoint
- func (r *Registry) EnsureMiddleware(name string)
- func (r *Registry) FindResource(name string) resource.Resource
- func (r *Registry) Middlewares() []middleware.Middleware
- func (r *Registry) RegisterEndpoint(e Endpoint)
- func (r *Registry) RegisterMiddleware(m middleware.Middleware)
- func (r *Registry) RegisterResource(res resource.Resource)
- func (r *Registry) RegisterService(s Service)
- func (r *Registry) Resources() []ResourceSnapshot
- func (r *Registry) Services() []Service
- func (r *Registry) SetEndpointMiddlewares(service string, transport Transport, names []string)
- func (r *Registry) UpdateGraphQLEndpoint(service, name string, u GraphQLUpdate)
- type ResourceSnapshot
- type Service
- type Transport
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Endpoint ¶
type Endpoint struct {
Service string
Name string
Transport Transport
Method string // REST verb; GraphQL "query"/"mutation"/"subscription"; unused for WS
Path string // REST/WS path; for GraphQL this is the mount path (e.g. "/graphql")
Description string
Middleware []string
Tags map[string]string
RegisteredAt time.Time
// GraphQL-specific metadata, populated when Transport == GraphQL.
Args []GraphQLArg `json:",omitempty"`
ReturnType string `json:",omitempty"`
// Deprecation flows from graph.WithDeprecated on the underlying resolver.
Deprecated bool `json:",omitempty"`
DeprecationReason string `json:",omitempty"`
}
type GraphQLArg ¶
type GraphQLArg struct {
Name string
Type string // SDL-style, e.g. "String!", "[Int]", "UUID"
Description string `json:",omitempty"`
Required bool `json:",omitempty"`
Default any `json:"Default,omitempty"`
Validators []GraphQLValidator `json:",omitempty"`
}
GraphQLArg describes one argument on a GraphQL field. Used by the dashboard to pre-fill the tester's query template with typed variables and render validator chips.
type GraphQLUpdate ¶
type GraphQLUpdate struct {
Description string
ReturnType string
Args []GraphQLArg
Middleware []string
Deprecated bool
DeprecationReason string
}
GraphQLUpdate is the patch graphfx applies to an endpoint after it has introspected the go-graph resolver. Only fields set on the update overwrite the endpoint; others are preserved.
type GraphQLValidator ¶
type GraphQLValidator struct {
Kind string
Message string `json:",omitempty"`
Details any `json:",omitempty"`
}
GraphQLValidator mirrors graph.ValidatorInfo — what kind of rule applies, the user-facing message, and any parameters (e.g. min/max for length).
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
func (*Registry) AttachResource ¶
AttachResource links a resource to a service. The dashboard draws an edge service → resource. Multiple services may attach to the same resource.
func (*Registry) DefaultOfKind ¶
DefaultOfKind returns the resource marked resource.AsDefault() for the kind, or — if none is marked — the lexically-first registered resource of that kind. Returns nil when no resources of the kind exist.
func (*Registry) EndpointsByService ¶
func (*Registry) EnsureMiddleware ¶
EnsureMiddleware registers an unknown name as a Custom middleware. Builders call this whenever .Use("name", fn) runs so the dashboard surfaces every middleware name the app references, even those the user never declared explicitly. Does nothing when the name already exists (preserves builtin).
func (*Registry) FindResource ¶
FindResource looks a resource up by name. Returns nil if unknown.
func (*Registry) Middlewares ¶
func (r *Registry) Middlewares() []middleware.Middleware
Middlewares returns the middleware metadata snapshot, sorted by name.
func (*Registry) RegisterEndpoint ¶
func (*Registry) RegisterMiddleware ¶
func (r *Registry) RegisterMiddleware(m middleware.Middleware)
RegisterMiddleware adds or overwrites a middleware entry. Safe to call at any time; the dashboard reflects the latest on its next poll.
func (*Registry) RegisterResource ¶
RegisterResource adds a resource to the registry. Safe to call multiple times with the same resource — later calls overwrite earlier ones.
func (*Registry) RegisterService ¶
func (*Registry) Resources ¶
func (r *Registry) Resources() []ResourceSnapshot
Resources returns a fresh snapshot with health probed right now.
func (*Registry) SetEndpointMiddlewares ¶
SetEndpointMiddlewares applies a middleware chain to every registered endpoint matching (service, transport). Used by graphfx to tag a whole GraphQL mount with the middleware that actually applied inside go-graph.
func (*Registry) UpdateGraphQLEndpoint ¶
func (r *Registry) UpdateGraphQLEndpoint(service, name string, u GraphQLUpdate)
UpdateGraphQLEndpoint patches an existing GraphQL endpoint with richer metadata from go-graph introspection. Non-empty fields on the update overwrite the endpoint; empty fields are left alone (so a follow-up call only carrying middleware names won't wipe previously-set args).
type ResourceSnapshot ¶
type ResourceSnapshot struct {
Name string `json:"name"`
Kind resource.Kind `json:"kind"`
Description string `json:"description,omitempty"`
Healthy bool `json:"healthy"`
Details map[string]any `json:"details,omitempty"`
AttachedTo []string `json:"attachedTo,omitempty"`
}
ResourceSnapshot is the serializable view of a resource at a point in time. The dashboard polls this via /__nexus/resources — healthy is probed fresh on every snapshot so the UI reflects live state.