codegen

package
v0.1.0-alpha.54-test1 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2023 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const DEFAULT_PRETTIER_GLOB = "src/**/*.ts"
View Source
const PRETTIER_FILE_CHUNKS = 20

Variables

This section is empty.

Functions

func FormatTS

func FormatTS(cfg *Config) error

Types

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"`
	DefaultGraphQLMutationName codegenapi.GraphQLMutationName   `yaml:"defaultGraphQLMutationName"`
	DefaultGraphQLFieldFormat  codegenapi.GraphQLFieldFormat    `yaml:"defaultGraphQLFieldFormat"`
	SchemaSQLFilePath          string                           `yaml:"schemaSQLFilePath"`
	DatabaseToCompareTo        string                           `yaml:"databaseToCompareTo"`
	FieldPrivacyEvaluated      codegenapi.FieldPrivacyEvaluated `yaml:"fieldPrivacyEvaluated"`
	TemplatizedViewer          *codegenapi.ImportedObject       `yaml:"templatizedViewer"`
	CustomAssocEdgePath        *codegenapi.ImportedObject       `yaml:"customAssocEdgePath"`
	GlobalImportPath           string                           `yaml:"globalImportPath"`
}

func (*CodegenConfig) Clone added in v0.0.39

func (cfg *CodegenConfig) Clone() *CodegenConfig

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) AddChangedFile added in v0.0.38

func (cfg *Config) AddChangedFile(filePath string)

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) ChangeMap added in v0.0.38

func (cfg *Config) ChangeMap() change.ChangeMap

func (*Config) Clone added in v0.0.39

func (cfg *Config) Clone() *Config

Clone doesn't clone changes and changedTSFiles

func (*Config) DatabaseToCompareTo added in v0.0.39

func (cfg *Config) DatabaseToCompareTo() string

func (*Config) DebugFilesMode added in v0.1.0

func (cfg *Config) DebugFilesMode() bool

func (*Config) DebugMode

func (cfg *Config) DebugMode() bool

func (*Config) DefaultGraphQLFieldFormat added in v0.0.39

func (cfg *Config) DefaultGraphQLFieldFormat() codegenapi.GraphQLFieldFormat

func (*Config) DefaultGraphQLMutationName added in v0.0.39

func (cfg *Config) DefaultGraphQLMutationName() codegenapi.GraphQLMutationName

func (*Config) DisableBase64Encoding added in v0.0.30

func (cfg *Config) DisableBase64Encoding() bool

func (*Config) DisableGraphQLRoot

func (cfg *Config) DisableGraphQLRoot() bool

func (*Config) DummyWrite added in v0.1.0

func (cfg *Config) DummyWrite() bool

func (*Config) FieldPrivacyEvaluated added in v0.1.0

func (cfg *Config) FieldPrivacyEvaluated() codegenapi.FieldPrivacyEvaluated

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) GetAssocEdgePath added in v0.1.0

func (cfg *Config) GetAssocEdgePath() *codegenapi.ImportedObject

func (*Config) GetChangedTSFiles added in v0.1.0

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

func (*Config) GetCustomGraphQLJSONPath added in v0.0.39

func (cfg *Config) GetCustomGraphQLJSONPath() string

func (*Config) GetDefaultActionPolicy

func (cfg *Config) GetDefaultActionPolicy() *PrivacyConfig

func (*Config) GetDefaultEntPolicy

func (cfg *Config) GetDefaultEntPolicy() *PrivacyConfig

func (*Config) GetDynamicScriptCustomGraphQLJSONPath added in v0.1.0

func (cfg *Config) GetDynamicScriptCustomGraphQLJSONPath() string

func (*Config) GetGlobalImportPath added in v0.1.0

func (cfg *Config) GetGlobalImportPath() *tsimport.ImportPath

func (*Config) GetGlobalSchemaImportPath added in v0.1.0

func (cfg *Config) GetGlobalSchemaImportPath() string

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) GetPathToBuildFile added in v0.0.38

func (cfg *Config) GetPathToBuildFile() string

func (*Config) GetPathToCustomSchemaFile added in v0.0.38

func (cfg *Config) GetPathToCustomSchemaFile() string

func (*Config) GetPathToSchemaFile added in v0.0.38

func (cfg *Config) GetPathToSchemaFile() 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) GetRomeConfig added in v0.1.0

func (cfg *Config) GetRomeConfig() *input.RomeConfig

func (*Config) GetRootPathToConfigs

func (cfg *Config) GetRootPathToConfigs() string

func (*Config) GetTemplatizedViewer added in v0.1.0

func (cfg *Config) GetTemplatizedViewer() *codegenapi.ImportedObject

func (*Config) OverrideGraphQLMutationName added in v0.0.39

func (cfg *Config) OverrideGraphQLMutationName(mutationName codegenapi.GraphQLMutationName)

func (*Config) OverrideImportPathToModels

func (cfg *Config) OverrideImportPathToModels(importPath string)

func (*Config) SchemaSQLFilePath added in v0.0.39

func (cfg *Config) SchemaSQLFilePath() string

func (*Config) SetChangeMap added in v0.0.38

func (cfg *Config) SetChangeMap(changes change.ChangeMap)

func (*Config) SetDebugFilesMode added in v0.1.0

func (cfg *Config) SetDebugFilesMode(debugFilesMode bool)

func (*Config) SetDebugMode

func (cfg *Config) SetDebugMode(debugMode bool)

func (*Config) SetDummyWrite added in v0.1.0

func (cfg *Config) SetDummyWrite(val bool)

func (*Config) SetInputConfig added in v0.1.0

func (cfg *Config) SetInputConfig(inputCfg *input.Config)

func (*Config) SetUseChanges added in v0.0.38

func (cfg *Config) SetUseChanges(useChanges bool)

func (*Config) SetWriteAll added in v0.0.38

func (cfg *Config) SetWriteAll(writeAll bool)

func (*Config) ShouldUseRelativePaths

func (cfg *Config) ShouldUseRelativePaths() bool

func (*Config) UseChanges added in v0.0.38

func (cfg *Config) UseChanges() bool

In rare scenarios, we can have UseChanges() and WriteAll() be true if ent.yml changed so that we can process deletes also

func (*Config) WriteAllFiles added in v0.0.38

func (cfg *Config) WriteAllFiles() bool

type ConfigurableConfig added in v0.1.0

type ConfigurableConfig struct {
	Codegen                            *CodegenConfig `yaml:"codegen"`
	CustomGraphQLJSONPath              string         `yaml:"customGraphQLJSONPath"`
	DynamicScriptCustomGraphQLJSONPath string         `yaml:"dynamicScriptCustomGraphQLJSONPath"`
	GlobalSchemaPath                   string         `yaml:"globalSchemaPath"`
}

func (*ConfigurableConfig) Clone added in v0.1.0

func (cfg *ConfigurableConfig) Clone() *ConfigurableConfig

type ConstructOption added in v0.0.38

type ConstructOption func(*constructOption)

func BuildInfo added in v0.0.38

func BuildInfo(bi *build_info.BuildInfo) ConstructOption

func DebugFileMode added in v0.1.0

func DebugFileMode() ConstructOption

func DebugMode added in v0.0.38

func DebugMode() ConstructOption

func ForcePrettier added in v0.1.0

func ForcePrettier() ConstructOption

func ForceWriteAll added in v0.1.0

func ForceWriteAll() ConstructOption

func ProcessorConfig added in v0.0.38

func ProcessorConfig(cfg *Config) ConstructOption

func WriteAll added in v0.0.38

func WriteAll() ConstructOption

type DBChangeType added in v0.1.0

type DBChangeType string
const (
	// NOTE: this was a list that was in sync with change_type in auto_schema/change_type.py
	// since deprecated and we're only using a few, only keeping reference to those ones
	AddColumn   DBChangeType = "add_column"
	CreateIndex DBChangeType = "create_index"
	DropIndex   DBChangeType = "drop_index"
	ModifyEdge  DBChangeType = "modify_edge"
)

type ImportPackage

type ImportPackage struct {
	PackagePath        string
	AuthPackagePath    string
	ActionPackagePath  string
	SchemaPackagePath  string
	GraphQLPackagePath string
	InternalImportPath string
	ExternalImportPath string
	TypesImportPath    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"`
}

func (*PrettierConfig) Clone added in v0.0.39

func (cfg *PrettierConfig) Clone() *PrettierConfig

type PrivacyConfig

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

func (*PrivacyConfig) Clone added in v0.0.39

func (cfg *PrivacyConfig) Clone() *PrivacyConfig

type Processor

type Processor struct {
	Schema    *schema.Schema
	ChangeMap change.ChangeMap

	Config *Config
	// contains filtered or unexported fields
}

Processor stores the parsed data needed for codegen

func NewCodegenProcessor

func NewCodegenProcessor(currentSchema *schema.Schema, configPath string, options ...ConstructOption) (*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

func (*Processor) WriteSchema added in v0.0.38

func (p *Processor) WriteSchema() 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 StepWithPostProcess added in v0.0.38

type StepWithPostProcess interface {
	Step
	PostProcessData(data *Processor) error
}

TODO figure out long term thing here

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