convert

package
v0.0.0-...-fc4761b Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2020 License: MIT Imports: 28 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HasStringPrimaryIDsInModels

func HasStringPrimaryIDsInModels(models []*Model) bool

func NameForDir

func NameForDir(dir string) string

NameForDir manually looks for package stanzas in files located in the given directory. This can be much faster than having to consult go list, because we already know exactly where to look.

func New

func New(output, backend, frontend Directory, opts ...Option) plugin.Plugin

func PkgAndType

func PkgAndType(name string) (string, string)

take a string in the form github.com/package/blah.Type and split it into package and type

func SanitizePackageName

func SanitizePackageName(pkg string) string

Types

type ColumnSetting

type ColumnSetting struct {
	Name                  string
	RelationshipModelName string
	IDAvailable           bool
}

type Config

type Config struct {
	// Aliases between domain type and model
	// useful if you have a domain type like, Auth that connects to a User model
	Aliases map[string][]string
}

type Convert

type Convert struct {
	Cfg *Config
	// contains filtered or unexported fields
}

func (*Convert) BoilerModelMatch

func (c *Convert) BoilerModelMatch(boilerModelName, modelName string) bool

func (*Convert) FindBoilerModel

func (c *Convert) FindBoilerModel(models []*model.Model, modelName string) model.Model

func (*Convert) GetModelsWithInformation

func (c *Convert) GetModelsWithInformation(enums []*Enum, cfg *config.Config, boilerModels []*model.Model) []*Model

func (*Convert) MutateConfig

func (c *Convert) MutateConfig(originalCfg *config.Config) error

func (*Convert) Name

func (c *Convert) Name() string

type ConvertConfig

type ConvertConfig struct {
	IsCustom         bool
	IsDomainType     bool
	ToBoiler         string
	ToDomain         string
	GraphTypeAsText  string
	BoilerTypeAsText string
}

type Directory

type Directory struct {
	Directory string
	Package   string
}

type Enum

type Enum struct {
	Description string
	Name        string

	Values []*EnumValue
}

type EnumValue

type EnumValue struct {
	Description string
	Name        string
	NameLower   string
}

type Field

type Field struct {
	Name               string
	PluralName         string
	Type               string
	TypeWithoutPointer string
	IsNumberID         bool
	IsPrimaryNumberID  bool
	IsPrimaryID        bool
	IsRequired         bool
	IsPlural           bool
	ConvertConfig      ConvertConfig
	// relation stuff
	IsRelation bool
	// boiler relation stuff is inside this field
	BoilerField model.Field
	// graphql relation ship can be found here
	Relationship *Model
	IsOr         bool
	IsAnd        bool

	// Some stuff
	Description  string
	OriginalType types.Type
	Tag          string
}

type Import

type Import struct {
	Alias      string
	ImportPath string
}

type Interface

type Interface struct {
	Description string
	Name        string
}

type Model

type Model struct {
	Name                  string
	PluralName            string
	BoilerModel           model.Model
	PrimaryKeyType        string
	Fields                []*Field
	IsNormal              bool
	IsInput               bool
	IsCreateInput         bool
	IsUpdateInput         bool
	IsNormalInput         bool
	IsPayload             bool
	IsWhere               bool
	IsFilter              bool
	IsPreloadable         bool
	PreloadArray          []Preload
	HasOrganizationID     bool
	HasUserOrganizationID bool
	HasUserID             bool
	HasStringPrimaryID    bool
	// other stuff
	Description string
	PureFields  []*ast.FieldDefinition
	Implements  []string
}

type Option

type Option interface {
	// contains filtered or unexported methods
}

An Option configures a Logger.

func PrimaryKeyCustom

func PrimaryKeyCustom(typ interface{}) Option

func PrimaryKeyInt

func PrimaryKeyInt() Option

func PrimaryKeyString

func PrimaryKeyString() Option

func PrimaryKeyUint

func PrimaryKeyUint() Option

func SetConfig

func SetConfig(cfg *Config) Option

type Preload

type Preload struct {
	Key           string
	ColumnSetting ColumnSetting
}

type Rewriter

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

func NewRewriter

func NewRewriter(importPath string) (*Rewriter, error)

func (*Rewriter) ExistingImports

func (r *Rewriter) ExistingImports(filename string) []Import

func (*Rewriter) GetMethodBody

func (r *Rewriter) GetMethodBody(structname string, methodname string) string

func (*Rewriter) MarkStructCopied

func (r *Rewriter) MarkStructCopied(name string)

func (*Rewriter) RemainingSource

func (r *Rewriter) RemainingSource(filename string) string

type Scalar

type Scalar struct {
	IsCustom    bool
	Description string
	Name        string
}

type Template

type Template struct {
	Backend             Directory
	Frontend            Directory
	HasStringPrimaryIDs bool
	PackageName         string
	Interfaces          []*Interface
	Models              []*Model
	Enums               []*Enum
	Scalars             []*Scalar
	PrimaryKey          reflect.Type
}

Jump to

Keyboard shortcuts

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