plugin

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package plugin defines the hook surfaces and the ordered registry.

v1 plugins are compile-time: a plugin is any Go type implementing one or more of the hook interfaces below, registered via Register (built-ins) or pdbq.WithPlugins (library embedding). The interfaces are deliberately small and orthogonal — they are also the contract for a future out-of-process (go-plugin / wasm) transport.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Register

func Register(p Plugin)

Register adds a plugin to the process-wide default registry (built-ins).

Types

type CatalogHook

type CatalogHook interface {
	TransformCatalog(ctx context.Context, c *introspect.Catalog) error
}

CatalogHook mutates or filters the introspected catalog before schema building (e.g. hide tables, rename via comments).

type CompileHook

type CompileHook interface {
	WrapCompile(next compile.Func) compile.Func
}

CompileHook wraps SQL generation per field, middleware-style.

type InflectionHook

type InflectionHook interface {
	Inflect(kind inflect.Kind, in inflect.Input, next inflect.Next) string
}

InflectionHook controls every generated GraphQL name. Call next to get the downstream (ultimately default) name; return your own to override.

type Plugin

type Plugin interface {
	Name() string
	Priority() int
}

Plugin is the base interface: identity plus default priority. Lower priority runs earlier (outermost in middleware chains); ties break by registration order.

type Registry

type Registry struct {
	// contains filtered or unexported fields
}

Registry holds plugins in deterministic order.

func Default

func Default() *Registry

Default returns the process-wide registry.

func NewRegistry

func NewRegistry(plugins ...Plugin) *Registry

func (*Registry) Add

func (r *Registry) Add(p Plugin)

Add registers a plugin, keeping the list sorted by (priority, insertion).

func (*Registry) All

func (r *Registry) All() []Plugin

All returns plugins in execution order.

func (*Registry) CompileChain

func (r *Registry) CompileChain(disabled map[string]bool, base compile.Func) compile.Func

CompileChain wraps base with all CompileHooks (outermost = lowest priority).

func (*Registry) Enabled

func (r *Registry) Enabled(disabled map[string]bool) []Plugin

Enabled returns plugins in execution order, excluding names disabled in cfg.

func (*Registry) Inflector

func (r *Registry) Inflector(disabled map[string]bool) inflect.Next

Inflector composes all InflectionHooks into a single naming function with inflect.Default as the innermost link.

func (*Registry) RequestHooks

func (r *Registry) RequestHooks(disabled map[string]bool) []RequestHook

RequestHooks returns the RequestHook implementations in order.

func (*Registry) TransformCatalog

func (r *Registry) TransformCatalog(ctx context.Context, disabled map[string]bool, c *introspect.Catalog) error

TransformCatalog runs all CatalogHooks in order.

func (*Registry) TransformSchema

func (r *Registry) TransformSchema(ctx context.Context, disabled map[string]bool, b *schema.Builder) error

TransformSchema runs all SchemaHooks in order.

type RequestHook

type RequestHook interface {
	BeforeOperation(ctx context.Context, op *exec.Operation) (context.Context, error)
	AfterOperation(ctx context.Context, op *exec.Operation, res *exec.Result)
}

RequestHook observes and controls the request lifecycle (auth, logging, transaction policy).

type SchemaHook

type SchemaHook interface {
	TransformSchema(ctx context.Context, s *schema.Builder) error
}

SchemaHook adds/removes/wraps types and fields after default generation.

Jump to

Keyboard shortcuts

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