Documentation
¶
Index ¶
- Variables
- func QueryRequestInfo(ss ast.SelectionSet) ([]sdl.QueryRequest, sdl.QueryType)
- type Catalog
- type CatalogManager
- type ExtensionCatalog
- type IncrementalCatalog
- type Manager
- type Operation
- type ParseOption
- type Provider
- type Querier
- type ReloadableCatalog
- type Service
- func (s *Service) AddCatalog(ctx context.Context, name string, catalog Catalog) error
- func (s *Service) Definitions(ctx context.Context) iter.Seq[*ast.Definition]
- func (s *Service) Description(ctx context.Context) string
- func (s *Service) DirectiveDefinitions(ctx context.Context) iter.Seq2[string, *ast.DirectiveDefinition]
- func (s *Service) DirectiveForName(ctx context.Context, name string) *ast.DirectiveDefinition
- func (s *Service) Engine(name string) (engines.Engine, error)
- func (s *Service) ExistsCatalog(name string) bool
- func (s *Service) ForName(ctx context.Context, name string) *ast.Definition
- func (s *Service) Implements(ctx context.Context, name string) iter.Seq[*ast.Definition]
- func (s *Service) MutationType(ctx context.Context) *ast.Definition
- func (s *Service) ParseQuery(ctx context.Context, query string, vars map[string]any, operationName string) (*Operation, error)
- func (s *Service) PossibleTypes(ctx context.Context, name string) iter.Seq[*ast.Definition]
- func (s *Service) Provider() Provider
- func (s *Service) QueryType(ctx context.Context) *ast.Definition
- func (s *Service) RegisterEngine(name string, engine engines.Engine)
- func (s *Service) ReloadCatalog(ctx context.Context, name string) error
- func (s *Service) RemoveCatalog(ctx context.Context, name string) error
- func (s *Service) SchemaProvider() Provider
- func (s *Service) SetProvider(p Provider)
- func (s *Service) SetVariableTransformer(t VariableTransformer)
- func (s *Service) SubscriptionType(ctx context.Context) *ast.Definition
- func (s *Service) Types(ctx context.Context) iter.Seq2[string, *ast.Definition]
- func (s *Service) ValidateQuery(ctx context.Context, query string) (*ast.QueryDocument, error)
- type ServiceOption
- type VariableTransformer
Constants ¶
This section is empty.
Variables ¶
var ( ErrCatalogNotFound = errors.New("catalog not found") ErrCatalogAlreadyExists = errors.New("catalog already exists") )
Functions ¶
func QueryRequestInfo ¶
func QueryRequestInfo(ss ast.SelectionSet) ([]sdl.QueryRequest, sdl.QueryType)
QueryRequestInfo recursively classifies an operation's selection set into typed query requests (meta, data, mutation, function, jq, h3).
Types ¶
type CatalogManager ¶
type CatalogManager interface {
// Load/Unload catalogs (for dynamic schema updates)
AddCatalog(ctx context.Context, name string, catalog Catalog) error
RemoveCatalog(ctx context.Context, name string) error
ExistsCatalog(name string) bool
// ReloadCatalog reloads a catalog. If the source supports incremental
// changes (IncrementalCatalog), only the delta is compiled and applied.
// Otherwise falls back to full recompilation.
ReloadCatalog(ctx context.Context, name string) error
}
type ExtensionCatalog ¶
type ExtensionCatalog = sources.ExtensionCatalog
type IncrementalCatalog ¶
type IncrementalCatalog = sources.IncrementalCatalog
type Manager ¶
type Manager interface {
// Catalog lifecycle
AddCatalog(ctx context.Context, name string, catalog Catalog) error
RemoveCatalog(ctx context.Context, name string) error
ExistsCatalog(name string) bool
ReloadCatalog(ctx context.Context, name string) error
Engine(name string) (engines.Engine, error)
// RegisterEngine adds an engine for planner routing without compilation.
// Used by cluster workers where schema is already compiled in CoreDB.
RegisterEngine(name string, engine engines.Engine)
}
type Operation ¶
type Operation struct {
// Enriched AST operation definition
Definition *ast.OperationDefinition
// All fragments from the document (needed by the planner for FragmentSpread resolution)
Fragments ast.FragmentDefinitionList
// Transformed variables
Variables map[string]any
// Classified top-level query requests from the selection set
Queries []sdl.QueryRequest
// Combined bitmask of all query types in the operation
QueryType sdl.QueryType
}
Operation is the result of ParseQuery. Contains an enriched AST operation ready for the planner.
func ParseQuery ¶
func ParseQuery(ctx context.Context, p Provider, query string, vars map[string]any, opts ...ParseOption) (*Operation, error)
ParseQuery is a universal pipeline for parsing and validating GraphQL queries.
Pipeline:
- VariableTransformer.TransformVariables(ctx, vars) — if set
- parser.ParseQuery(query) — gqlparser lexer + parser
- validator.Validate(ctx, provider, doc) — our Walker: enrichment + validation + permissions
- selectOperation(operations, operationName) — select operation
- QueryRequestInfo(op.SelectionSet) — classify queries
Returns: enriched Operation with filled field.Definition, field.ObjectDefinition etc.
type ParseOption ¶
type ParseOption func(*parseConfig)
ParseOption configures ParseQuery.
func WithOperationName ¶
func WithOperationName(name string) ParseOption
WithOperationName sets the operation name to select from the document. Default: "" (single operation).
func WithValidator ¶
func WithValidator(v *validator.Validator) ParseOption
WithValidator sets the validator for ParseQuery. Default: validator.New(rules.DefaultRules()...).
func WithVariableTransformer ¶
func WithVariableTransformer(t VariableTransformer) ParseOption
WithVariableTransformer sets the variable transformer. Default: nil (no transformation).
type Querier ¶
type Querier interface {
Query(ctx context.Context, query string, vars map[string]any) (*types.Response, error)
}
Querier executes GraphQL queries. Used by VariableTransformer for the jq queryHugr function.
type ReloadableCatalog ¶
type ReloadableCatalog = sources.ReloadableCatalog
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service holds dependencies for query parsing: Provider, Validator, VariableTransformer. Thread-safe (Provider and Validator are immutable after creation).
func NewService ¶
func NewService(p Provider, opts ...ServiceOption) *Service
NewService creates a Service with the given provider and options.
func (*Service) AddCatalog ¶
func (*Service) Definitions ¶
func (*Service) DirectiveDefinitions ¶
func (*Service) DirectiveForName ¶
func (*Service) ExistsCatalog ¶
func (*Service) Implements ¶
func (*Service) MutationType ¶
func (s *Service) MutationType(ctx context.Context) *ast.Definition
func (*Service) ParseQuery ¶
func (s *Service) ParseQuery(ctx context.Context, query string, vars map[string]any, operationName string) (*Operation, error)
ParseQuery parses a query using the service's dependencies.
func (*Service) PossibleTypes ¶
func (*Service) RegisterEngine ¶
RegisterEngine adds an engine reference for planner routing without going through catalog compilation. Used in read-only mode where schemas are already persisted by the writer node.
func (*Service) ReloadCatalog ¶
func (*Service) RemoveCatalog ¶
func (*Service) SetProvider ¶
SetProvider replaces the Provider (e.g. on catalog change). NOT thread-safe — call under external lock.
func (*Service) SetVariableTransformer ¶
func (s *Service) SetVariableTransformer(t VariableTransformer)
SetVariableTransformer sets the variable transformer.
func (*Service) SubscriptionType ¶
func (s *Service) SubscriptionType(ctx context.Context) *ast.Definition
func (*Service) ValidateQuery ¶
ValidateQuery parses and validates/enriches a query, returning the full QueryDocument. Unlike ParseQuery it does not select an operation or classify queries. Useful when the caller needs to inspect/filter the enriched AST before execution.
type ServiceOption ¶
type ServiceOption func(*Service)
ServiceOption configures a Service.
func WithServiceValidator ¶
func WithServiceValidator(v *validator.Validator) ServiceOption
WithServiceValidator sets the validator for the service.
func WithServiceVarTransformer ¶
func WithServiceVarTransformer(t VariableTransformer) ServiceOption
WithServiceVarTransformer sets the variable transformer for the service.
type VariableTransformer ¶
type VariableTransformer interface {
TransformVariables(ctx context.Context, vars map[string]any) (map[string]any, error)
}
VariableTransformer transforms query variables before parsing. The primary implementation is jqVariableTransformer (checks _jq key).
func NewJQVariableTransformer ¶
func NewJQVariableTransformer(querier Querier) VariableTransformer
NewJQVariableTransformer creates a VariableTransformer that processes _jq expressions.