Documentation
¶
Overview ¶
Public embedding surface: aliases that let external modules construct a Config, implement plugin hooks, and mount pdbq inside their own HTTP mux. The implementation stays under internal/; aliases are the contract.
Package pdbq wires the subsystems into a runnable application and is the embedding surface for third-party plugins: import pdbq as a library and run pdbq.New(cfg, pdbq.WithPlugins(myPlugin)).Serve(ctx).
Index ¶
- type App
- func (a *App) BuildSchema(ctx context.Context, cat *introspect.Catalog) (*schema.Built, error)
- func (a *App) Close()
- func (a *App) Connect(ctx context.Context) error
- func (a *App) Executor(built *schema.Built) *exec.Executor
- func (a *App) Handler(ctx context.Context) (http.Handler, error)
- func (a *App) LoadCatalog(ctx context.Context) (*introspect.Catalog, error)
- func (a *App) Plugins() []plugin.Plugin
- func (a *App) Pool() *pgxpool.Pool
- func (a *App) Query(ctx context.Context, query string, vars map[string]any, operation string) (*exec.Result, error)
- func (a *App) Serve(ctx context.Context) error
- type AuthConfig
- type Built
- type Catalog
- type CatalogHook
- type CompileFunc
- type CompileHook
- type CompileRequest
- type Config
- type DatabaseConfig
- type ErrorsConfig
- type ExecRequest
- type Executor
- type FiltersConfig
- type InflectInput
- type InflectKind
- type InflectNext
- type InflectionHook
- type LogConfig
- type Operation
- type Option
- type Plugin
- type PluginRegistry
- type PluginsConfig
- type RLSConfig
- type RequestHook
- type Result
- type SchemaBuilder
- type SchemaConfig
- type SchemaHook
- type ServerConfig
- type Statement
- type TXConfig
- type WatchConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type App ¶
type App struct {
Config config.Config
Registry *plugin.Registry
Log *slog.Logger
// contains filtered or unexported fields
}
App is a configured pdbq instance.
func (*App) BuildSchema ¶
BuildSchema runs the full pipeline: catalog hooks -> inflection -> default generation -> schema hooks -> SDL validation.
func (*App) Handler ¶
Handler runs the boot pipeline (introspect -> plugins -> schema -> executor) and returns the GraphQL http.Handler for embedding in a larger mux. Watch mode, when enabled, hot-swaps the schema behind the returned handler exactly as Serve does. The caller owns the listener; server.addr and request timeouts still apply to the handler's internals (http.TimeoutHandler), but read/idle timeouts are the embedder's job.
func (*App) LoadCatalog ¶
LoadCatalog introspects the database, or loads the schema cache when configured.
type AuthConfig ¶
Configuration. Section types carry a Config suffix to avoid clashing with unrelated root-package names.
type Catalog ¶
type Catalog = introspect.Catalog
Types referenced by hook signatures and the executor.
type CompileFunc ¶
Types referenced by hook signatures and the executor.
type CompileRequest ¶
Types referenced by hook signatures and the executor.
type Config ¶
Configuration. Section types carry a Config suffix to avoid clashing with unrelated root-package names.
type DatabaseConfig ¶
Configuration. Section types carry a Config suffix to avoid clashing with unrelated root-package names.
type ErrorsConfig ¶
Configuration. Section types carry a Config suffix to avoid clashing with unrelated root-package names.
type ExecRequest ¶
Types referenced by hook signatures and the executor.
type FiltersConfig ¶
Configuration. Section types carry a Config suffix to avoid clashing with unrelated root-package names.
type InflectInput ¶
Types referenced by hook signatures and the executor.
type InflectKind ¶
Types referenced by hook signatures and the executor.
type InflectNext ¶
Types referenced by hook signatures and the executor.
type LogConfig ¶
Configuration. Section types carry a Config suffix to avoid clashing with unrelated root-package names.
type Option ¶
type Option func(*App)
Option customizes an App.
func WithPlugins ¶
WithPlugins registers additional plugins (the library embedding pattern).
type PluginsConfig ¶
Configuration. Section types carry a Config suffix to avoid clashing with unrelated root-package names.
type RLSConfig ¶
Configuration. Section types carry a Config suffix to avoid clashing with unrelated root-package names.
type SchemaBuilder ¶
Types referenced by hook signatures and the executor.
type SchemaConfig ¶
Configuration. Section types carry a Config suffix to avoid clashing with unrelated root-package names.
type ServerConfig ¶
Configuration. Section types carry a Config suffix to avoid clashing with unrelated root-package names.
type TXConfig ¶
Configuration. Section types carry a Config suffix to avoid clashing with unrelated root-package names.
type WatchConfig ¶
Configuration. Section types carry a Config suffix to avoid clashing with unrelated root-package names.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
pdbq
command
Command pdbq serves an automatically mapped GraphQL API for a PostgreSQL database, and provides schema-cache, config, and one-off query tooling.
|
Command pdbq serves an automatically mapped GraphQL API for a PostgreSQL database, and provides schema-cache, config, and one-off query tooling. |
|
internal
|
|
|
cache
Package cache (de)serializes the introspected Catalog so pdbq can boot without touching pg_catalog: gzip-compressed JSON with a format version and a content hash for drift detection (`pdbq schema dump|check`).
|
Package cache (de)serializes the introspected Catalog so pdbq can boot without touching pg_catalog: gzip-compressed JSON with a format version and a content hash for drift detection (`pdbq schema dump|check`). |
|
compile
Package compile turns one validated GraphQL root field into exactly one parameterized SQL statement, PostGraphile-style: nested selections become jsonb_build_object trees, relations become LEFT JOIN LATERAL subqueries, lists become jsonb_agg — so the database returns the response JSON directly and there is no N+1 problem to paper over.
|
Package compile turns one validated GraphQL root field into exactly one parameterized SQL statement, PostGraphile-style: nested selections become jsonb_build_object trees, relations become LEFT JOIN LATERAL subqueries, lists become jsonb_agg — so the database returns the response JSON directly and there is no N+1 problem to paper over. |
|
config
Package config defines pdbq's configuration model and its loading rules: YAML file < environment (PDBQ_*) < command-line flags.
|
Package config defines pdbq's configuration model and its loading rules: YAML file < environment (PDBQ_*) < command-line flags. |
|
exec
Package exec owns the request lifecycle: parse/validate, depth and cost limits, per-operation transactions, RLS role switching + claims via set_config, execution of compiled statements, and PG->GraphQL error mapping.
|
Package exec owns the request lifecycle: parse/validate, depth and cost limits, per-operation transactions, RLS role switching + claims via set_config, execution of compiled statements, and PG->GraphQL error mapping. |
|
inflect
Package inflect defines the naming pipeline for every generated GraphQL identifier.
|
Package inflect defines the naming pipeline for every generated GraphQL identifier. |
|
introspect
Package introspect reads pg_catalog and produces a Catalog — the single serializable model that drives schema building, caching, and plugins.
|
Package introspect reads pg_catalog and produces a Catalog — the single serializable model that drives schema building, caching, and plugins. |
|
plugin
Package plugin defines the hook surfaces and the ordered registry.
|
Package plugin defines the hook surfaces and the ordered registry. |
|
plugins/advancedfilters
Package advancedfilters is a built-in plugin extending the generated filter/orderBy surface with two features default generation leaves out:
|
Package advancedfilters is a built-in plugin extending the generated filter/orderBy surface with two features default generation leaves out: |
|
plugins/nestedmutations
Package nestedmutations is a built-in plugin exercising every hook surface: it adds nested `create`/`connect` input fields on create-mutation inputs following foreign keys (SchemaHook), compiles them into a single multi-CTE SQL statement respecting FK direction and insertion order (CompileHook), and forces a transaction for nested mutations even when transactions are globally disabled (RequestHook), unless plugins.nested-mutations.force_transactions is false.
|
Package nestedmutations is a built-in plugin exercising every hook surface: it adds nested `create`/`connect` input fields on create-mutation inputs following foreign keys (SchemaHook), compiles them into a single multi-CTE SQL statement respecting FK direction and insertion order (CompileHook), and forces a transaction for nested mutations even when transactions are globally disabled (RequestHook), unless plugins.nested-mutations.force_transactions is false. |
|
plugins/simplenames
Package simplenames is a built-in plugin proving that naming is fully hook-driven: `users` instead of `allUsers`, `user(id:)` instead of `userById`, `updateUser` instead of `updateUserById`, and shortened relation names where unambiguous.
|
Package simplenames is a built-in plugin proving that naming is fully hook-driven: `users` instead of `allUsers`, `user(id:)` instead of `userById`, `updateUser` instead of `updateUserById`, and shortened relation names where unambiguous. |
|
plugins/smartcomments
Package smartcomments is a built-in plugin that turns PostGraphile-style "smart comments" — database COMMENTs whose leading lines start with '@' — into schema customization, so the generated API can be tuned with plain DDL and no pdbq configuration:
|
Package smartcomments is a built-in plugin that turns PostGraphile-style "smart comments" — database COMMENTs whose leading lines start with '@' — into schema customization, so the generated API can be tuned with plain DDL and no pdbq configuration: |
|
schema
Package schema turns an introspect.Catalog into a GraphQL schema.
|
Package schema turns an introspect.Catalog into a GraphQL schema. |
|
server
Package server exposes the GraphQL API over HTTP: POST /graphql, an embedded GraphiQL page, and health endpoints.
|
Package server exposes the GraphQL API over HTTP: POST /graphql, an embedded GraphiQL page, and health endpoints. |
|
smarttags
Package smarttags parses PostGraphile-style "smart comments": lines at the start of a database COMMENT beginning with '@' are machine-readable tags, everything after the first non-tag line is the human description.
|
Package smarttags parses PostGraphile-style "smart comments": lines at the start of a database COMMENT beginning with '@' are machine-readable tags, everything after the first non-tag line is the human description. |
|
testutil
Package testutil provides a hand-built fixture Catalog mirroring the docker fixture schema, so schema-builder and compiler tests run without a database.
|
Package testutil provides a hand-built fixture Catalog mirroring the docker fixture schema, so schema-builder and compiler tests run without a database. |
|
watch
Package watch re-introspects on DDL changes (dev mode).
|
Package watch re-introspects on DDL changes (dev mode). |