Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ParseGraphQL ¶
func ParseGraphQL(h httpcaddyfile.Helper) (caddyhttp.MiddlewareHandler, error)
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
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.