generator

package
v0.0.0-...-ada6ab3 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EnsureRuntimeScaffolds

func EnsureRuntimeScaffolds(root, modulePath string) error

EnsureRuntimeScaffolds materialises the runtime scaffolding packages required by generated code. It writes files only when they are absent so repeated executions remain idempotent.

func GraphQLModelTypeMappings

func GraphQLModelTypeMappings() map[string][]string

GraphQLModelTypeMappings returns a defensive copy of the scalar-to-Go type mappings used when scaffolding gqlgen configuration.

func GraphQLModelsSection

func GraphQLModelsSection(modulePath string) string

GraphQLModelsSection renders the gqlgen `models` configuration block using the shared scalar mappings and built-in scalar aliases.

func RegisterGraphQLScalarTemplate

func RegisterGraphQLScalarTemplate(content []byte)

RegisterGraphQLScalarTemplate provides the default scalars helper template used when ensuring GraphQL runtime helpers are present during generation. The content is copied to avoid callers mutating the registered template after registration.

func SetGQLRunnerForTest

func SetGQLRunnerForTest(fn func(string) error) func()

SetGQLRunnerForTest overrides the gqlgen runner for tests and returns a restore function.

Types

type ColumnSnapshot

type ColumnSnapshot struct {
	Name          string   `json:"name"`
	Type          string   `json:"type"`
	Nullable      bool     `json:"nullable"`
	Unique        bool     `json:"unique,omitempty"`
	DefaultExpr   string   `json:"default_expr,omitempty"`
	DefaultNow    bool     `json:"default_now,omitempty"`
	Identity      bool     `json:"identity,omitempty"`
	GeneratedExpr string   `json:"generated_expr,omitempty"`
	Dependencies  []string `json:"dependencies,omitempty"`
	ReadOnly      bool     `json:"read_only,omitempty"`
	EnumValues    []string `json:"enum_values,omitempty"`
}

type ComponentName

type ComponentName string
const (
	ComponentORM        ComponentName = "orm"
	ComponentGraphQL    ComponentName = "graphql"
	ComponentMigrations ComponentName = "migrations"
)

type ComponentResult

type ComponentResult struct {
	Name    ComponentName
	Changed bool
	Skipped bool
	Staged  bool
	Files   []string
	Reason  string
}

type Entity

type Entity struct {
	Name          string
	Fields        []dsl.Field
	Edges         []dsl.Edge
	Indexes       []dsl.Index
	Query         dsl.QuerySpec
	Annotations   []dsl.Annotation
	Authorization dsl.AuthRules
}

type ForeignKeySnapshot

type ForeignKeySnapshot struct {
	Column       string `json:"column"`
	TargetTable  string `json:"target_table"`
	TargetColumn string `json:"target_column"`
	Constraint   string `json:"constraint"`
	OnDelete     string `json:"on_delete,omitempty"`
	OnUpdate     string `json:"on_update,omitempty"`
}

type GenerateOptions

type GenerateOptions struct {
	DryRun        bool
	Force         bool
	MigrationName string
	Components    []string
	StagingDir    string
}

type IndexSnapshot

type IndexSnapshot struct {
	Name             string   `json:"name"`
	Columns          []string `json:"columns"`
	Unique           bool     `json:"unique,omitempty"`
	Method           string   `json:"method,omitempty"`
	Where            string   `json:"where,omitempty"`
	NullsNotDistinct bool     `json:"nulls_not_distinct,omitempty"`
}

type MigrationFile

type MigrationFile struct {
	Name       string
	Path       string
	SQL        string
	Operations []Operation
}

type MigrationResult

type MigrationResult struct {
	Operations []Operation
	Files      []MigrationFile
	Snapshot   SchemaSnapshot
}

type Operation

type Operation struct {
	Kind   OperationKind
	Target string
	SQL    string
}

type OperationKind

type OperationKind string
const (
	OpCreateExtension  OperationKind = "create_extension"
	OpDropExtension    OperationKind = "drop_extension"
	OpCreateTable      OperationKind = "create_table"
	OpDropTable        OperationKind = "drop_table"
	OpAddColumn        OperationKind = "add_column"
	OpDropColumn       OperationKind = "drop_column"
	OpAlterColumn      OperationKind = "alter_column"
	OpAddForeignKey    OperationKind = "add_foreign_key"
	OpDropForeignKey   OperationKind = "drop_foreign_key"
	OpAddIndex         OperationKind = "add_index"
	OpDropIndex        OperationKind = "drop_index"
	OpCreateHypertable OperationKind = "create_hypertable"
	OpDropHypertable   OperationKind = "drop_hypertable"
	OpAddCheck         OperationKind = "add_check_constraint"
	OpDropCheck        OperationKind = "drop_check_constraint"
)

type RunResult

type RunResult struct {
	Components []ComponentResult
	Migration  MigrationResult
}

func Run

func Run(root string, opts GenerateOptions) (RunResult, error)

type SchemaDiscoveryError

type SchemaDiscoveryError struct {
	Path   string
	Detail string
	Hints  []string
}

SchemaDiscoveryError captures failures while attempting to load user-authored schema files.

func (SchemaDiscoveryError) Error

func (e SchemaDiscoveryError) Error() string

Error implements the error interface.

func (SchemaDiscoveryError) Suggestion

func (e SchemaDiscoveryError) Suggestion() string

Suggestion aggregates hints for display in CLI error messages.

type SchemaSnapshot

type SchemaSnapshot struct {
	Tables     []TableSnapshot `json:"tables"`
	Extensions []string        `json:"extensions,omitempty"`
}

type SchemaValidationError

type SchemaValidationError struct {
	Entity     string
	Edge       string
	Field      string
	Column     string
	Target     string
	Detail     string
	Suggestion string
}

type SchemaValidationErrorList

type SchemaValidationErrorList struct {
	Problems []SchemaValidationError
}

func (*SchemaValidationErrorList) Error

func (l *SchemaValidationErrorList) Error() string

type TableSnapshot

type TableSnapshot struct {
	Name             string               `json:"name"`
	Columns          []ColumnSnapshot     `json:"columns"`
	PrimaryKey       []string             `json:"primary_key,omitempty"`
	Indexes          []IndexSnapshot      `json:"indexes,omitempty"`
	ForeignKeys      []ForeignKeySnapshot `json:"foreign_keys,omitempty"`
	HypertableColumn string               `json:"hypertable_column,omitempty"`
	IsJoinTable      bool                 `json:"join_table,omitempty"`
}

Jump to

Keyboard shortcuts

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