registry

package
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package registry stores metadata about every endpoint a nexus app exposes. It is the source of truth the dashboard reads from.

Index

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 New

func New() *Registry

func (*Registry) AttachResource

func (r *Registry) AttachResource(serviceName, resourceName string)

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

func (r *Registry) DefaultOfKind(kind resource.Kind) resource.Resource

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) Endpoints

func (r *Registry) Endpoints() []Endpoint

func (*Registry) EndpointsByService

func (r *Registry) EndpointsByService(name string) []Endpoint

func (*Registry) EnsureMiddleware

func (r *Registry) EnsureMiddleware(name string)

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

func (r *Registry) FindResource(name string) resource.Resource

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 (r *Registry) RegisterEndpoint(e Endpoint)

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

func (r *Registry) RegisterResource(res resource.Resource)

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 (r *Registry) RegisterService(s Service)

func (*Registry) Resources

func (r *Registry) Resources() []ResourceSnapshot

Resources returns a fresh snapshot with health probed right now.

func (*Registry) Services

func (r *Registry) Services() []Service

func (*Registry) SetEndpointMiddlewares

func (r *Registry) SetEndpointMiddlewares(service string, transport Transport, names []string)

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.

type Service

type Service struct {
	Name        string
	Description string
}

type Transport

type Transport string
const (
	REST      Transport = "rest"
	GraphQL   Transport = "graphql"
	WebSocket Transport = "websocket"
)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL