plugin

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 22 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseGraphQL

ParseGraphQL adapts the `graphql` directive.

func RegisterBackend

func RegisterBackend(appName string, fn borrower)

RegisterBackend makes a backend available to the graphql handler under its Caddy app name ("sqlite", "pgsql", "mysql"). A backend plugin, or a small adapter beside it, calls this in init. Registering the same name twice panics, the way Caddy's own module registry does.

Types

type GraphQL

type GraphQL struct {
	Sources  []Source         `json:"sources,omitempty"`
	Backend  string           `json:"backend,omitempty"`
	Database string           `json:"database,omitempty"`
	Role     string           `json:"role,omitempty"`
	Policy   string           `json:"policy,omitempty"`
	Remote   string           `json:"remote,omitempty"`
	Remotes  []Remote         `json:"remotes,omitempty"`
	Exposes  []graphql.Expose `json:"exposes,omitempty"`
	// contains filtered or unexported fields
}

GraphQL serves one GraphQL endpoint over databases this process already declares with database plugins (caddy-sqlite, caddy-pgsql, caddy-mysql). It opens no connection: reads, writes and subscriptions run through the borrowed clusters, so batching, the cache, migrations and readonly stay the backend plugins'. Several backends can be merged into one endpoint; the SQL dialect is chosen per backend, so one handler serves all three engines unchanged.

func (*GraphQL) CaddyModule

func (*GraphQL) CaddyModule() caddy.ModuleInfo

func (*GraphQL) Provision

func (m *GraphQL) Provision(ctx caddy.Context) error

func (*GraphQL) ServeHTTP

func (m *GraphQL) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyhttp.Handler) error

func (*GraphQL) UnmarshalCaddyfile

func (m *GraphQL) UnmarshalCaddyfile(d *caddyfile.Dispenser) error

type Remote

type Remote struct {
	Name string `json:"name,omitempty"`
	URL  string `json:"url,omitempty"`
}

Remote is a stitched remote schema: its root fields merge into the local one.

type Site

type Site interface {
	// Dialect is the SQL dialect the engine compiles for.
	Dialect() graphql.Dialect
	// CanonicalSchema resolves a schema name to its declared spelling.
	CanonicalSchema(name string) (string, bool)
	// Anchor is the borrowed pool, for introspection.
	Anchor() *sql.DB
	// Runtime is the read/write surface the engine runs statements through.
	Runtime() graphql.Runtime
}

Site is the database the GraphQL engine runs against, abstracted behind an interface so one handler serves SQLite, PostgreSQL and MySQL unchanged. A backend plugin registers a borrower for its Caddy app name; the handler picks one by the `backend` directive and never imports the engine packages directly.

type Source

type Source struct {
	Backend  string `json:"backend,omitempty"`
	Database string `json:"database,omitempty"`
}

Source is one backend/database pair the endpoint borrows. A graphql block may name several, and their tables merge into one schema.

Jump to

Keyboard shortcuts

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