codegen

package
v0.0.38-alpha2 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_GLOB = "src/**/*.ts"

Variables

This section is empty.

Functions

func FormatTS

func FormatTS(cfg *Config) error

Types

type ChangeType

type ChangeType string
const (
	AddTable               ChangeType = "add_table"
	DropTable              ChangeType = "drop_table"
	AddColumn              ChangeType = "add_column"
	DropColumn             ChangeType = "drop_column"
	CreateIndex            ChangeType = "create_index"
	DropIndex              ChangeType = "drop_index"
	CreateForeignKey       ChangeType = "create_foreign_key"
	AlterColumn            ChangeType = "alter_column"
	CreateUniqueConstraint ChangeType = "create_unique_constraint"
	AddEdges               ChangeType = "add_edges"
	RemoveEdges            ChangeType = "remove_edges"
	ModifyEdge             ChangeType = "modify_edge"
	AddRows                ChangeType = "add_rows"
	RemoveRows             ChangeType = "remove_rows"
	ModifyRows             ChangeType = "modify_rows"
	AlterEnum              ChangeType = "alter_enum"
	AddEnum                ChangeType = "add_enum"
	DropEnum               ChangeType = "drop_enum"
	CreateCheckConstraint  ChangeType = "create_check_constraint"
	DropCheckConstraint    ChangeType = "drop_check_constraint"
)

note these need to be in sync with change_type in auto_schema/change_type.py

type CodegenConfig

type CodegenConfig struct {
	DefaultEntPolicy      *PrivacyConfig  `yaml:"defaultEntPolicy"`
	DefaultActionPolicy   *PrivacyConfig  `yaml:"defaultActionPolicy"`
	Prettier              *PrettierConfig `yaml:"prettier"`
	RelativeImports       bool            `yaml:"relativeImports"`
	DisableGraphQLRoot    bool            `yaml:"disableGraphQLRoot"`
	GeneratedHeader       string          `yaml:"generatedHeader"`
	DisableBase64Encoding bool            `yaml:"disableBase64Encoding"`
	GenerateRootResolvers bool            `yaml:"generateRootResolvers"`
}

type Config

type Config struct {
	// contains filtered or unexported fields
}

Config is codegen info/config which is used to pass things down the line

func NewConfig

func NewConfig(configPath, modulePath string) (*Config, error)

func NewTestConfig

func NewTestConfig(configPath, modulePath string, codegenCfg *CodegenConfig) (*Config, error)

func (*Config) AppendPathToModels

func (cfg *Config) AppendPathToModels(paths ...string) string

used by golang

func (*Config) Base64EncodeIDs added in v0.0.30

func (cfg *Config) Base64EncodeIDs() bool

func (*Config) DebugMode

func (cfg *Config) DebugMode() bool

func (*Config) DisableBase64Encoding added in v0.0.30

func (cfg *Config) DisableBase64Encoding() bool

func (*Config) DisableGraphQLRoot

func (cfg *Config) DisableGraphQLRoot() bool

func (*Config) GenerateNodeQuery added in v0.0.30

func (cfg *Config) GenerateNodeQuery() bool

func (*Config) GenerateRootResolvers added in v0.0.30

func (cfg *Config) GenerateRootResolvers() bool

func (*Config) GeneratedHeader

func (cfg *Config) GeneratedHeader() string

func (*Config) GetAbsPathToGraphQL

func (cfg *Config) GetAbsPathToGraphQL() string

used by golang

func (*Config) GetAbsPathToModels

func (cfg *Config) GetAbsPathToModels() string

used by golang

func (*Config) GetAbsPathToRoot

func (cfg *Config) GetAbsPathToRoot() string

func (*Config) GetDefaultActionPolicy

func (cfg *Config) GetDefaultActionPolicy() *PrivacyConfig

func (*Config) GetDefaultEntPolicy

func (cfg *Config) GetDefaultEntPolicy() *PrivacyConfig

func (*Config) GetImportPackage

func (cfg *Config) GetImportPackage() *ImportPackage

func (*Config) GetImportPathToGraphQL

func (cfg *Config) GetImportPathToGraphQL() string

func (*Config) GetImportPathToModels

func (cfg *Config) GetImportPathToModels() string

func (*Config) GetImportPathToRoot

func (cfg *Config) GetImportPathToRoot() string

func (*Config) GetPrettierArgs

func (cfg *Config) GetPrettierArgs() []string

func (*Config) GetQuotedImportPathToConfigs

func (cfg *Config) GetQuotedImportPathToConfigs() string

func (*Config) GetQuotedImportPathToModels

func (cfg *Config) GetQuotedImportPathToModels() string

func (*Config) GetRelativePathToConfigs

func (cfg *Config) GetRelativePathToConfigs() string

func (*Config) GetRootPathToConfigs

func (cfg *Config) GetRootPathToConfigs() string

func (*Config) OverrideImportPathToModels

func (cfg *Config) OverrideImportPathToModels(importPath string)

func (*Config) SetDebugMode

func (cfg *Config) SetDebugMode(debugMode bool)

func (*Config) ShouldUseRelativePaths

func (cfg *Config) ShouldUseRelativePaths() bool

type ImportPackage

type ImportPackage struct {
	PackagePath        string
	AuthPackagePath    string
	ActionPackagePath  string
	SchemaPackagePath  string
	GraphQLPackagePath string
	InternalImportPath string
	ExternalImportPath string
}

ImportPackage refers to TypeScript paths of what needs to be generated for imports

type Option

type Option func(*option)

func DisableCustomGraphQL

func DisableCustomGraphQL() Option

func DisableFormat

func DisableFormat() Option

func DisablePrompts

func DisablePrompts() Option

func DisableSchemaGQL

func DisableSchemaGQL() Option

func FromTest

func FromTest() Option

type PrettierConfig

type PrettierConfig struct {
	Custom bool   `yaml:"custom"`
	Glob   string `yaml:"glob"`
}

type PrivacyConfig

type PrivacyConfig struct {
	Path       string `yaml:"path"`
	PolicyName string `yaml:"policyName"`
	Class      bool   `yaml:"class"`
}

type Processor

type Processor struct {
	Schema *schema.Schema
	Config *Config
	// contains filtered or unexported fields
}

Processor stores the parsed data needed for codegen

func NewCodegenProcessor

func NewCodegenProcessor(schema *schema.Schema, configPath, modulePath string, debugMode bool) (*Processor, error)

func NewTestCodegenProcessor

func NewTestCodegenProcessor(configPath string, s *schema.Schema, codegenCfg *CodegenConfig) (*Processor, error)

func (*Processor) DisableCustomGraphQL

func (p *Processor) DisableCustomGraphQL() bool

func (*Processor) DisableSchemaGQL

func (p *Processor) DisableSchemaGQL() bool

func (*Processor) FormatTS

func (p *Processor) FormatTS() error

func (*Processor) FromTest

func (p *Processor) FromTest() bool

func (*Processor) NoDBChanges

func (p *Processor) NoDBChanges() bool

func (*Processor) Run

func (p *Processor) Run(steps []Step, step string, options ...Option) error

type Step

type Step interface {
	Name() string
	ProcessData(data *Processor) error
}

Step refers to a step in the codegen process e.g. db/ graphql/code etc

type StepWithPreProcess

type StepWithPreProcess interface {
	Step
	// any pre-process steps can be done here
	// this is where things like user input and other
	PreProcessData(data *Processor) error
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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