base

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CatalogDirectiveName       = "catalog"
	DependencyDirectiveName    = "dependency"
	ModuleCatalogDirectiveName = "module_catalog"
)
View Source
const (
	ObjectTableDirectiveName = "table"
	ObjectViewDirectiveName  = "view"
)

Object-level directive names.

View Source
const (
	FieldPrimaryKeyDirectiveName           = "pk"
	FieldGeometryInfoDirectiveName         = "geometry_info"
	FieldSqlDirectiveName                  = "sql"
	FieldExtraFieldDirectiveName           = "extra_field"
	FieldDefaultDirectiveName              = "default"
	FieldDefaultDirectiveInsertExprArgName = "insert_exp"
	FieldDefaultDirectiveUpdateExprArgName = "update_exp"
	FieldMeasurementDirectiveName          = "measurement"
	FieldMeasurementFuncArgName            = "measurement_func"
	FieldDimDirectiveName                  = "dim"
	FieldExcludeMCPDirectiveName           = "exclude_mcp"
)

Field-level directive names.

View Source
const (
	WithDeletedDirectiveName = "with_deleted"
	StatsDirectiveName       = "stats"
	RawResultsDirectiveName  = "raw"
	UnnestDirectiveName      = "unnest"
	NoPushdownDirectiveName  = "no_pushdown"
)

Query-side directive names.

View Source
const (
	QueryDirectiveName                 = "query"
	MutationDirectiveName              = "mutation"
	FunctionDirectiveName              = "function"
	FunctionCallDirectiveName          = "function_call"
	FunctionCallTableJoinDirectiveName = "table_function_call_join"
	JoinDirectiveName                  = "join"
	ReferencesDirectiveName            = "references"
	FieldReferencesDirectiveName       = "field_references"
	ReferencesQueryDirectiveName       = "references_query"
	FieldAggregationQueryDirectiveName = "aggregation_query"
	ModuleDirectiveName                = "module"
	ModuleRootDirectiveName            = "module_root"
	ViewArgsDirectiveName              = "args"
	OriginalNameDirectiveName          = "original_name"
	DeprecatedDirectiveName            = "deprecated"
	FilterInputDirectiveName           = "filter_input"
	FilterListInputDirectiveName       = "filter_list_input"
	DataInputDirectiveName             = "data_input"
)

Query/mutation directive names.

View Source
const (
	CacheDirectiveName           = "cache"
	NoCacheDirectiveName         = "no_cache"
	InvalidateCacheDirectiveName = "invalidate_cache"
)

Cache directive names.

View Source
const (
	AddH3DirectiveName          = "add_h3"
	H3QueryFieldName            = "h3"
	H3QueryTypeName             = "_h3_query"
	H3DataQueryTypeName         = "_h3_data_query"
	H3DataFieldName             = "data"
	DistributionFieldName       = "distribution_by"
	DistributionTypeName        = "_distribution_by"
	BucketDistributionFieldName = "distribution_by_bucket"
	BucketDistributionTypeName  = "_distribution_by_bucket"
)

H3 directive and type names.

View Source
const (
	GisFeatureDirectiveName    = "feature"
	GisWFSDirectiveName        = "wfs"
	GisWFSFieldDirectiveName   = "wfs_field"
	GisWFSExcludeDirectiveName = "wfs_exclude"
	GisWFSTypeName             = "_wfs_features"
)

GIS/WFS directive and type names.

View Source
const (
	QueryTimeJoinsFieldName   = "_join"
	QueryTimeJoinsTypeName    = "_join"
	QueryTimeSpatialFieldName = "_spatial"
	QueryTimeSpatialTypeName  = "_spatial"
)

Query-time join type/field names.

View Source
const (
	VectorTypeName                       = "Vector"
	VectorSearchInputName                = "VectorSearchInput"
	VectorDistanceTypeEnumName           = "VectorDistanceType"
	VectorSearchDistanceL2               = "L2"
	VectorSearchDistanceIP               = "Inner"
	VectorSearchDistanceCosine           = "Cosine"
	SimilaritySearchArgumentName         = "similarity"
	EmbeddingsDirectiveName              = "embeddings"
	SemanticSearchArgumentName           = "semantic"
	SemanticSearchInputName              = "SemanticSearchInput"
	SummaryForEmbeddedArgumentName       = "summary"
	DistanceFieldNameSuffix              = "distance"
	VectorDistanceExtraFieldName         = "VectorDistance"
	QueryEmbeddingDistanceExtraFieldName = "QueryEmbeddingDistance"
	QueryEmbeddingsDistanceFieldName     = "_distance_to_query"
)

Vector search directive and type names.

View Source
const (
	FunctionTypeName         = "Function"
	FunctionMutationTypeName = "MutationFunction"
	QueryBaseName            = "Query"
	MutationBaseName         = "Mutation"
	OperationResultTypeName  = "OperationResult"
)

Type name constants.

View Source
const (
	JSONTypeName                      = "JSON"
	TimestampTypeName                 = "Timestamp"
	H3CellTypeName                    = "H3Cell"
	GeometryTypeName                  = "Geometry"
	GeometryAggregationTypeName       = "GeometryAggregation"
	GeometryMeasurementExtraFieldName = "Measurement"
	TimestampExtractExtraFieldName    = "Extract"
)

Scalar type name constants.

View Source
const (
	AggregateKeyFieldName   = "key"
	AggregateFieldName      = "aggregations"
	AggRowsCountFieldName   = "_rows_count"
	AggregationSuffix       = "_aggregation"
	BucketAggregationSuffix = "_bucket_aggregation"
)

Aggregation constants.

View Source
const (
	ListFilterInputSuffix = "_list_filter"
	FilterInputSuffix     = "_filter"
)

Input/filter constants.

View Source
const (
	MutationTypeTextInsert = "INSERT"
	MutationTypeTextUpdate = "UPDATE"
	MutationTypeTextDelete = "DELETE"
)

Mutation type text constants.

View Source
const (
	JoinSourceFieldPrefix = "source"
	JoinRefFieldPrefix    = "dest"
)

Join field name prefixes.

View Source
const (
	ObjectQueryByPKSuffix = "_by_pk"
	StubFieldName         = "_stub"
)

Object query constants.

View Source
const (
	QueryTypeTextSelect          = "SELECT"
	QueryTypeTextSelectOne       = "SELECT_ONE"
	QueryTypeTextAggregate       = "AGGREGATE"
	QueryTypeTextAggregateBucket = "AGGREGATE_BUCKET"
)

Query type text constants (for @query directive "type" argument).

View Source
const (
	ObjectHyperTableDirectiveName = "hypertable"
	ObjectCubeDirectiveName       = "cube"
	ObjectUniqueDirectiveName     = "unique"

	FieldReferencesQueryDirectiveName = "references_query"

	FieldTimescaleKeyDirectiveName = "timescale_key"

	InputFieldNamedArgDirectiveName = "named_arg"

	ObjectAggregationDirectiveName      = "aggregation"
	ObjectFieldAggregationDirectiveName = "field_aggregation"
)

Object-level secondary directive names.

View Source
const (
	DescFilter        = "Filter"
	DescOrderBy       = "Sort options for the result set"
	DescLimit         = "Limit the number of returned objects"
	DescOffset        = "Skip the first n objects"
	DescDistinctOn    = "Distinct on the given fields"
	DescInnerJoin     = "Apply inner join to the result set"
	DescInnerJoinRef  = "Apply inner join to reference record"
	DescArgs          = "Arguments for the view"
	DescBucketKey     = "The key of the bucket"
	DescNestedOrderBy = "Sort options for the nested result set"
	DescNestedLimit   = "Limit the number of returned nested objects"
	DescNestedOffset  = "Skip the first n nested objects"
)

Query argument descriptions.

View Source
const (
	ArgName                  = "name"
	ArgType                  = "type"
	ArgSQL                   = "sql"
	ArgExp                   = "exp"
	ArgField                 = "field"
	ArgRequired              = "required"
	ArgDescription           = "description"
	ArgReferencesName        = "references_name"
	ArgSourceFields          = "source_fields"
	ArgReferencesFields      = "references_fields"
	ArgReferencesQuery       = "references_query"
	ArgReferencesDescription = "references_description"
	ArgIsM2M                 = "is_m2m"
	ArgM2MName               = "m2m_name"
	ArgIsTable               = "is_table"
	ArgIsTableFuncJoin       = "is_table_func_join"
	ArgIsBucket              = "is_bucket"
	ArgBaseField             = "base_field"
	ArgBaseType              = "base_type"
	ArgQuery                 = "query"
	ArgSoftDelete            = "soft_delete"
	ArgSoftDeleteCond        = "soft_delete_cond"
	ArgSoftDeleteSet         = "soft_delete_set"
	ArgSkipNullArg           = "skip_null_arg"
	ArgJsonCast              = "json_cast"
	ArgSequence              = "sequence"
	ArgQuerySuffix           = "query_suffix"
	ArgSkipQuery             = "skip_query"
	ArgModule                = "module"
	ArgModel                 = "model"
	ArgVector                = "vector"
	ArgDistance              = "distance"
	ArgLen                   = "len"
	ArgSRID                  = "srid"
	ArgArgs                  = "args"
)

Directive argument name constants (shared between sdl and rules).

View Source
const (
	// Drop type, input, enum value, or field from the schema
	DropDirectiveName = "drop"
	// Replace type, input, enum value, or field in the schema with the new definition
	ReplaceDirectiveName = "replace"
	// Skip adding the definition if it already exists
	IfNotExistsDirectiveName = "if_not_exists"
	// Drop a specific directive usage from the target definition or field
	DropDirectiveDirectiveName = "drop_directive"
)

DDL directive names

View Source
const (
	MetadataSchemaQuery   = "__schema"
	MetadataTypeQuery     = "__type"
	MetadataTypeNameQuery = "__typename"

	JQTransformQueryName = "jq"
)

Metadata query constants.

View Source
const (
	TableDataObject = "table"
	ViewDataObject  = "view"
)
View Source
const CatalogSystemVariableName = "$catalog"

Catalog system variable.

View Source
const FieldSourceDirectiveName = "field_source"

Variables

View Source
var (
	ErrDefinitionNotFound = errors.New("definition not found")
)
View Source
var SystemDirective = &ast.Directive{Name: "system", Position: CompiledPos("")}

SystemDirective is the sentinel directive marking compiler-generated definitions.

Functions

func AddH3Directive

func AddH3Directive(field string, resolution int, transformFrom int, buffer float64, divideVals bool, simplify bool, pos *ast.Position) *ast.Directive

AddH3Directive creates an @add_h3 directive with the given parameters.

func CloneArgument

func CloneArgument(arg *ast.Argument) *ast.Argument

func CloneArgumentList

func CloneArgumentList(args ast.ArgumentList) ast.ArgumentList

func CloneDefinition

func CloneDefinition(def *ast.Definition, fieldFilter func(*ast.FieldDefinition) bool) *ast.Definition

func CloneDirective

func CloneDirective(dir *ast.Directive) *ast.Directive

func CloneDirectiveList

func CloneDirectiveList(dirs ast.DirectiveList) ast.DirectiveList

func CloneEnumValueList

func CloneEnumValueList(enumValues ast.EnumValueList) ast.EnumValueList

func CloneFieldDefinition

func CloneFieldDefinition(field *ast.FieldDefinition) *ast.FieldDefinition

func CloneFieldDefinitionListWithFilter

func CloneFieldDefinitionListWithFilter(fields ast.FieldList, fieldFilter func(*ast.FieldDefinition) bool) ast.FieldList

func CloneValue

func CloneValue(value *ast.Value) *ast.Value

func CompiledPos

func CompiledPos(name string) *ast.Position

CompiledPos creates a position marker for compiled/generated AST elements.

func DefinitionCatalog

func DefinitionCatalog(def *ast.Definition) string

func DefinitionDependencies

func DefinitionDependencies(def *ast.Definition) []string

func DefinitionDirectiveArgString

func DefinitionDirectiveArgString(def *ast.Definition, dirName, argName string) string

func DefinitionModuleCatalogs

func DefinitionModuleCatalogs(def *ast.Definition) []string

DefinitionModuleCatalogs returns all catalog names from @module_catalog directives on a definition.

func DerivedExtensionFields

func DerivedExtensionFields(name, fieldName string) map[string][]string

DerivedExtensionFields returns field names that compilation adds to shared types (Query, Mutation, _join, _join_aggregation) for a given data object. Used by incremental compilation to emit @drop fields when a type is dropped or replaced. The fieldName parameter is the query/mutation field name (original name when AsModule, compiled name otherwise).

func DerivedTypeNames

func DerivedTypeNames(name string) []string

DerivedTypeNames returns the deterministic list of all type names generated from a source type during compilation. Used by incremental compilation to identify all types that must be dropped when a source type is dropped or replaced.

func DirectiveArgString

func DirectiveArgString(dir *ast.Directive, name string) string

func DirectiveArgStrings

func DirectiveArgStrings(dir *ast.Directive, name string) []string

DirectiveArgStrings extracts a list of string values from a directive argument.

func DropDirectiveIfExists

func DropDirectiveIfExists(def *ast.Definition) bool

func DropFieldIfExists

func DropFieldIfExists(field *ast.FieldDefinition) bool

func EnumValueCatalog

func EnumValueCatalog(enumValue *ast.EnumValueDefinition) string

func ErrorPosf

func ErrorPosf(pos *ast.Position, format string, args ...any) *gqlerror.Error

func FieldDefCatalog

func FieldDefCatalog(field *ast.FieldDefinition) string

func FieldDefDependency

func FieldDefDependency(field *ast.FieldDefinition) string

FieldDefDependency returns the dependency name from a field's @dependency directive.

func FieldDefDirectiveArgString

func FieldDefDirectiveArgString(field *ast.FieldDefinition, dirName, argName string) string

func FieldDefModuleCatalogs

func FieldDefModuleCatalogs(field *ast.FieldDefinition) []string

FieldDefModuleCatalogs returns all catalog names from @module_catalog directives on a field.

func FieldGeometryInfoDirective

func FieldGeometryInfoDirective(geomType string, srid int) *ast.Directive

FieldGeometryInfoDirective creates a @geometry_info directive.

func FieldSourceDirective

func FieldSourceDirective(name string) *ast.Directive

FieldSourceDirective creates a @field_source directive for renamed fields.

func FieldSqlDirective

func FieldSqlDirective(sql string) *ast.Directive

FieldSqlDirective creates a @sql directive with the given expression.

func Ident

func Ident(s string) string

Ident quotes a SQL identifier if it is a reserved keyword or contains special characters.

func IsControlDirective

func IsControlDirective(name string) bool

IsControlDirective returns true for DDL control directives that should be stripped before inserting definitions into the schema.

func IsDropDefinition

func IsDropDefinition(def *ast.Definition) bool

func IsDropEnumValue

func IsDropEnumValue(ev *ast.EnumValueDefinition) bool

func IsDropField

func IsDropField(field *ast.FieldDefinition) bool

func IsIfNotExistsDefinition

func IsIfNotExistsDefinition(def *ast.Definition) bool

func IsReplaceDefinition

func IsReplaceDefinition(def *ast.Definition) bool

func IsReplaceField

func IsReplaceField(field *ast.FieldDefinition) bool

func IsValidIdentifier

func IsValidIdentifier(s string) bool

IsValidIdentifier returns true if the string is a valid unquoted SQL identifier.

func ModuleDirective

func ModuleDirective(name string, pos *ast.Position) *ast.Directive

ModuleDirective creates a @module directive with the given name.

func QuerySideDirectives

func QuerySideDirectives() []string

QuerySideDirectives returns directive names that are valid on query fields.

func SetDirectiveArg

func SetDirectiveArg(dir *ast.Directive, name, value string)

SetDirectiveArg sets or adds a string argument on a directive.

func Sources

func Sources() []*ast.Source

Sources returns the base system type SDL sources. Scalar type SDL is provided separately by the types package.

func StripControlDirectives

func StripControlDirectives(dirs ast.DirectiveList) ast.DirectiveList

StripControlDirectives returns a new directive list with all DDL control directives removed.

Types

type BatchRule

type BatchRule interface {
	Rule
	ProcessAll(ctx CompilationContext) error
}

BatchRule performs cross-cutting work after all DefinitionRules in the same phase.

type CompilationContext

type CompilationContext interface {
	Context() context.Context
	Source() DefinitionsSource
	CompileOptions() Options
	ApplyPrefix(name string) string

	// Scalar registry access
	ScalarLookup(name string) types.ScalarType
	IsScalar(name string) bool

	// Output writing
	AddDefinition(def *ast.Definition)
	AddExtension(ext *ast.Definition)
	AddDefinitionReplaceOrCreate(def *ast.Definition)

	// PromoteToSource adds a definition to the source-level pool.
	// Definitions added here are dispatched to DefinitionRules in subsequent phases,
	// alongside source definitions. Used by PREPARE rules (e.g. InternalExtensionMerger)
	// when an extension targets a provider type not present in the source.
	PromoteToSource(def *ast.Definition)

	// PromotedDefinitions returns definitions promoted via PromoteToSource.
	// Used by PREPARE batch rules (e.g. PrefixPreparer) to also process promoted defs.
	PromotedDefinitions() []*ast.Definition

	// Type lookup: checks compilation output first, then target schema
	LookupType(name string) *ast.Definition
	LookupDirective(name string) *ast.DirectiveDefinition

	// LookupExtension returns the accumulated extension for a given type name,
	// or nil if no extensions have been added for that type.
	LookupExtension(name string) *ast.Definition

	// Shared state management
	RegisterObject(name string, info *ObjectInfo)
	GetObject(name string) *ObjectInfo

	// Field collectors for ASSEMBLE phase
	RegisterQueryFields(objectName string, fields []*ast.FieldDefinition)
	RegisterMutationFields(objectName string, fields []*ast.FieldDefinition)
	RegisterFunctionFields(fields []*ast.FieldDefinition)
	RegisterFunctionMutationFields(fields []*ast.FieldDefinition)

	// Field collector getters for ASSEMBLE phase
	QueryFields() map[string][]*ast.FieldDefinition
	MutationFields() map[string][]*ast.FieldDefinition
	FunctionFields() []*ast.FieldDefinition
	FunctionMutationFields() []*ast.FieldDefinition

	// Object iteration
	Objects() iter.Seq2[string, *ObjectInfo]

	// Output iteration (for FINALIZE rules)
	OutputDefinitions() iter.Seq[*ast.Definition]
	OutputExtensions() iter.Seq[*ast.Definition]

	// Dependency registration (extension compilation)
	RegisterDependency(name string)
}

CompilationContext provides rules access to source, target schema lookups, output writing, scalar registry, and shared state.

type CompiledCatalog

type CompiledCatalog interface {
	DefinitionsSource
	ExtensionsSource
}

CompiledCatalog is the DDL feed output of compilation, consumable by static.Provider.Update().

type DefinitionRule

type DefinitionRule interface {
	Rule
	Match(def *ast.Definition) bool
	Process(ctx CompilationContext, def *ast.Definition) error
}

DefinitionRule processes individual source definitions matching a predicate.

type DefinitionsSource

type DefinitionsSource interface {
	ForName(ctx context.Context, name string) *ast.Definition
	DirectiveForName(ctx context.Context, name string) *ast.DirectiveDefinition

	// iteration
	Definitions(ctx context.Context) iter.Seq[*ast.Definition]
	DirectiveDefinitions(ctx context.Context) iter.Seq2[string, *ast.DirectiveDefinition]
}

DefinitionsSource resolves types and directives with context support. A subset of Provider for functions that only need type resolution.

type DependentCompiledCatalog

type DependentCompiledCatalog interface {
	Dependencies() []string
}

DependentCompiledCatalog extends CompiledCatalog with dependency information collected from @dependency directives during extension compilation.

type DropDirectiveSpec

type DropDirectiveSpec struct {
	Name  string            // directive name to drop
	Match map[string]string // argument values to match (nil = drop all instances)
}

DropDirectiveSpec describes which directive to remove from a target.

func DropDirectiveSpecs

func DropDirectiveSpecs(def *ast.Definition) []DropDirectiveSpec

DropDirectiveSpecs extracts all @drop_directive specs from a definition's directives.

func FieldDropDirectiveSpecs

func FieldDropDirectiveSpecs(field *ast.FieldDefinition) []DropDirectiveSpec

FieldDropDirectiveSpecs extracts all @drop_directive specs from a field's directives.

type EngineCapabilities

type EngineCapabilities struct {
	General EngineGeneralCapabilities
	Insert  EngineInsertCapabilities
	Update  EngineUpdateCapabilities
	Delete  EngineDeleteCapabilities
}

EngineCapabilities declares what an engine supports.

type EngineDeleteCapabilities

type EngineDeleteCapabilities struct {
	Delete           bool
	DeleteWithoutPKs bool
}

type EngineGeneralCapabilities

type EngineGeneralCapabilities struct {
	SupportDefaultSequences       bool
	UnsupportedTypes              []string
	UnsupportStructuredTypes      bool
	UnsupportArrays               bool
	UnsupportTables               bool
	SupportCrossCatalogReferences bool
}

type EngineInsertCapabilities

type EngineInsertCapabilities struct {
	Insert           bool
	Returning        bool
	InsertReferences bool
}

type EngineUpdateCapabilities

type EngineUpdateCapabilities struct {
	Update           bool
	UpdatePKColumns  bool
	UpdateWithoutPKs bool
}

type ExtensionsSource

type ExtensionsSource interface {
	DefinitionsSource

	// Extensions
	DefinitionExtensions(ctx context.Context, name string) iter.Seq[*ast.Definition]
	Extensions(ctx context.Context) iter.Seq[*ast.Definition]
}

ExtensionsSource extends DefinitionsSource with support for definition extensions.

type HugrType

type HugrType string

HugrType identifies the kind of a compiled schema definition for introspection.

const (
	HugrTypeModule     HugrType = "module"
	HugrTypeTable      HugrType = "table"
	HugrTypeView       HugrType = "view"
	HugrTypeJoin       HugrType = "join_queries"
	HugrTypeSpatial    HugrType = "spatial_queries"
	HugrTypeH3Data     HugrType = "h3_data"
	HugrTypeH3Agg      HugrType = "h3_aggregate"
	HugrTypeFilter     HugrType = "filter"
	HugrTypeFilterList HugrType = "filter_list"
	HugrTypeDataInput  HugrType = "data_input"
)

type HugrTypeField

type HugrTypeField string

HugrTypeField identifies the kind of a field within a compiled definition.

const (
	HugrTypeFieldSubmodule      HugrTypeField = "submodule"
	HugrTypeFieldSelectOne      HugrTypeField = "select_one"
	HugrTypeFieldSelect         HugrTypeField = "select"
	HugrTypeFieldAgg            HugrTypeField = "aggregate"
	HugrTypeFieldBucketAgg      HugrTypeField = "bucket_agg"
	HugrTypeFieldFunction       HugrTypeField = "function"
	HugrTypeFieldJoin           HugrTypeField = "join"
	HugrTypeFieldSpatial        HugrTypeField = "spatial"
	HugrTypeFieldH3Agg          HugrTypeField = "h3_aggregate"
	HugrTypeFieldJQ             HugrTypeField = "jq"
	HugrTypeFieldMutationInsert HugrTypeField = "mutation_insert"
	HugrTypeFieldMutationUpdate HugrTypeField = "mutation_update"
	HugrTypeFieldMutationDelete HugrTypeField = "mutation_delete"
	HugrTypeFieldExtraField     HugrTypeField = "extra_field"
)

type ModuleObjectType

type ModuleObjectType int

ModuleObjectType identifies the kind of module root object.

const (
	ModuleQuery ModuleObjectType = iota + 1
	ModuleMutation
	ModuleFunction
	ModuleMutationFunction
)

type ModuleRoot

type ModuleRoot struct {
	Name string
	Type ModuleObjectType
}

ModuleRoot holds extracted module information from a type definition.

func ModuleRootInfo

func ModuleRootInfo(def *ast.Definition) *ModuleRoot

ModuleRootInfo extracts module root information from @module_root directive or by well-known type name (Query, Mutation, Function, MutationFunction).

type MutableProvider

type MutableProvider interface {
	Provider

	// SetDefinitionDescription updates a type's description and long description.
	SetDefinitionDescription(ctx context.Context, name, desc, longDesc string) error
	// SetFieldDescription updates a field's description and long description.
	SetFieldDescription(ctx context.Context, typeName, fieldName, desc, longDesc string) error
	// SetModuleDescription updates a module's description and long description.
	SetModuleDescription(ctx context.Context, name, desc, longDesc string) error
	// SetCatalogDescription updates a catalog's description and long description.
	SetCatalogDescription(ctx context.Context, name, desc, longDesc string) error

	DropCatalog(ctx context.Context, name string, cascade bool) error
	Update(ctx context.Context, changes DefinitionsSource) error
}

MutableProvider is a mutable container for schema definitions.

type ObjectInfo

type ObjectInfo struct {
	Name         string
	OriginalName string
	TableName    string
	Module       string
	IsReplace    bool
	IsView       bool
	IsM2M        bool
	IsCube       bool
	IsHypertable bool
	PrimaryKey   []string

	// Parameterized views (@args)
	InputArgsName string // input type name from @args(name: "...")
	RequiredArgs  bool   // true if any field in input type is NonNull or @args(required: true)
}

ObjectInfo caches shared metadata about a data object during compilation.

func RecoverObjectInfo

func RecoverObjectInfo(def *ast.Definition) *ObjectInfo

RecoverObjectInfo reconstructs ObjectInfo from an already-compiled provider definition by reading its directives. Used during incremental compilation to recover metadata about existing types in the provider schema.

type ObjectMutationType

type ObjectMutationType int

ObjectMutationType represents the kind of mutation generated for a data object.

const (
	MutationTypeInsert ObjectMutationType = iota
	MutationTypeUpdate
	MutationTypeDelete
)

func (ObjectMutationType) String

func (m ObjectMutationType) String() string

type ObjectQueryType

type ObjectQueryType int

ObjectQueryType represents the kind of query generated for a data object.

const (
	QueryTypeSelect ObjectQueryType = iota
	QueryTypeSelectOne
	QueryTypeAggregate
	QueryTypeAggregateBucket

	SubQueryTypeReferencesData
	SubQueryTypeJoinData
	SubQueryTypeFunctionCallData
	SubQueryTypeFunctionCallTableJoinData
)

type Options

type Options struct {
	Name         string
	ReadOnly     bool
	Prefix       string
	EngineType   string
	AsModule     bool
	IsExtension  bool
	Capabilities *EngineCapabilities
}

Options configures compilation behavior.

func (*Options) ApplyPrefix

func (o *Options) ApplyPrefix(name string) string

ApplyPrefix prepends the prefix to a name with underscore separator if set.

func (*Options) IsArraysSupported

func (o *Options) IsArraysSupported() bool

func (*Options) IsCrossCatalogReferencesSupported

func (o *Options) IsCrossCatalogReferencesSupported() bool

func (*Options) IsSequenceDefaultSupported

func (o *Options) IsSequenceDefaultSupported() bool

func (*Options) IsStructuredTypesSupported

func (o *Options) IsStructuredTypesSupported() bool

func (*Options) IsTablesSupported

func (o *Options) IsTablesSupported() bool

func (*Options) IsTypeSupported

func (o *Options) IsTypeSupported(typ string) bool

func (*Options) SupportDelete

func (o *Options) SupportDelete() bool

func (*Options) SupportDeleteWithoutPKs

func (o *Options) SupportDeleteWithoutPKs() bool

func (*Options) SupportInsert

func (o *Options) SupportInsert() bool

func (*Options) SupportInsertReferences

func (o *Options) SupportInsertReferences() bool

func (*Options) SupportInsertReturning

func (o *Options) SupportInsertReturning() bool

func (*Options) SupportUpdate

func (o *Options) SupportUpdate() bool

func (*Options) SupportUpdatePKs

func (o *Options) SupportUpdatePKs() bool

func (*Options) SupportUpdateWithoutPKs

func (o *Options) SupportUpdateWithoutPKs() bool

type Phase

type Phase int

Phase represents a compilation phase.

const (
	PhaseValidate Phase = iota
	PhasePrepare
	PhaseGenerate
	PhaseAssemble
	PhaseFinalize
)

func (Phase) String

func (p Phase) String() string

type Provider

type Provider interface {
	DefinitionsSource

	Description(ctx context.Context) string

	// Root operation types
	QueryType(ctx context.Context) *ast.Definition
	MutationType(ctx context.Context) *ast.Definition
	SubscriptionType(ctx context.Context) *ast.Definition

	// Type relationships (for validator: fragment spreading, interface checks)
	PossibleTypes(ctx context.Context, name string) iter.Seq[*ast.Definition]
	Implements(ctx context.Context, name string) iter.Seq[*ast.Definition]

	// types iteration (for introspection, meta-info)
	Types(ctx context.Context) iter.Seq2[string, *ast.Definition]
}

Provider is a read-only interface to a compiled schema. All methods accept context.Context for future storage-backed implementations.

type QueryRequest

type QueryRequest struct {
	Name      string
	OrderNum  int
	QueryType QueryType
	Field     *ast.Field
	Subset    []QueryRequest
}

QueryRequest is a classified entry from an operation's selection set.

type QueryType

type QueryType int

QueryType is a bitmask for classifying operation-level query requests.

const (
	QueryTypeNone QueryType = 0
	QueryTypeMeta QueryType = 1 << iota
	QueryTypeQuery
	QueryTypeJQTransform
	QueryTypeMutation
	QueryTypeFunction
	QueryTypeFunctionMutation
	QueryTypeH3Aggregation
)

type Rule

type Rule interface {
	Name() string
	Phase() Phase
}

Rule is the base interface for all compilation rules.

Jump to

Keyboard shortcuts

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