generator

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OptionGraphQL string = "(graphql.type)"

	ImportPrefixOption = "import_prefix"
	ImportPathOption   = "import_path"
)
View Source
const (
	GQLTypeObject   GQLType = GQLType("Object")
	GQLTypeInput            = GQLType("Input")
	GQLTypeScalar           = GQLType("Scalar")
	GQLTypeEnum             = GQLType("Enum")
	GQLTypeQuery            = GQLType("Query")
	GQLTypeMutation         = GQLType("Mutation")
)

Variables

This section is empty.

Functions

func DefaultNameGenerator

func DefaultNameGenerator(packageName, typeName string) string

DefaultNameGenerator is a default type name generator

func Generate

func Generate()

func NormalizedFileName

func NormalizedFileName(s string) string

Types

type Extern

type Extern struct {
	ProtoPackage string
	ImportAlias  string
	SourcePath   string
}

type GQLIdent added in v0.0.2

type GQLIdent struct {
	protogen.GoIdent
	Type GQLType
	// contains filtered or unexported fields
}

func (*GQLIdent) String added in v0.0.2

func (g *GQLIdent) String() string

type GQLType added in v0.0.2

type GQLType string

type Generator

type Generator interface {
	FromProto(*descriptorpb.FileDescriptorProto, string, string) (bool, error)
	GetFieldType(*descriptorpb.DescriptorProto, *descriptorpb.FieldDescriptorProto, string) *TypeInfo
	GetObjectFields(*descriptorpb.DescriptorProto) *ObjectField
	GetProtobufFieldName(string) string
	GetInputType(string) string
	GetOutputType(string) string
	GetEnumType(string) string
	GetLanguageType(string) string
	GetGraphQLTypeName(string) string
	GetExternal(string) (*Extern, bool)
	HasOperation() bool
}

Generator is an interface of graphql code generator

func NewGenerator

func NewGenerator(typeNameGenerator TypeNameGenerator, baseFileName string, options Options) Generator

type MapEntry added in v0.3.0

type MapEntry struct {
	KeyField   string
	KeyType    string
	ValueField string
	ValueType  string
}

type ObjectField

type ObjectField struct {
	Fields    []*descriptorpb.FieldDescriptorProto
	Unions    map[string][]*descriptorpb.FieldDescriptorProto
	Maps      []*descriptorpb.FieldDescriptorProto
	MapTypes  map[string]MapEntry
	HasFields bool
}

type Option

type Option interface {
	Name() string
	Value() string
}

func NewOption

func NewOption(key, value string) Option

type Options

type Options []Option

func (Options) Get

func (opts Options) Get(key string) (string, bool)

type Printer added in v0.0.2

type Printer interface {
	Enter()
	Exit()
	P(...interface{}) Printer
}

type Symbol added in v0.0.2

type Symbol struct {
	Ident  GQLIdent
	Parent *Symbol
}

func NewSymbol added in v0.0.2

func NewSymbol(parent *Symbol, ident GQLIdent) *Symbol

type SymbolTable added in v0.0.2

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

func (*SymbolTable) Append added in v0.0.2

func (t *SymbolTable) Append(s *Symbol)

func (*SymbolTable) Exist added in v0.0.2

func (t *SymbolTable) Exist(ident GQLIdent) bool

func (*SymbolTable) LookUp added in v0.0.2

func (t *SymbolTable) LookUp(ident GQLIdent) (*Symbol, bool)

type TypeInfo

type TypeInfo struct {
	Name         string
	Prefix       string
	PackageName  string
	Suffix       string
	IsScalar     bool
	IsRepeated   bool
	IsNonNull    bool
	LanguageType string
}

func (*TypeInfo) GetName

func (t *TypeInfo) GetName() string

func (*TypeInfo) String

func (t *TypeInfo) String() string

type TypeNameGenerator

type TypeNameGenerator func(packageName, typeName string) string

TypeNameGenerator is function type to generate GraphQL type from protobuf object type

type UnionField

type UnionField struct {
	Message *descriptorpb.DescriptorProto
	Field   *descriptorpb.FieldDescriptorProto
}

type Visitor added in v0.0.2

type Visitor interface {
	Content() ([]byte, error)
	Visit(parent *Symbol, f *protogen.File)
	VisitEnum(parent *Symbol, enumDescriptor *protogen.Enum)
	VisitMessage(parent *Symbol, p *protogen.Message, typ GQLType)
	VisitField(symbol *Symbol, p *protogen.Field, typ GQLType)
	VisitOneOf(symbol *Symbol, p *protogen.Oneof, typ GQLType)
	VisitService(symbol *Symbol, p *protogen.Service)
}

func NewVisitor added in v0.0.2

func NewVisitor(f *protogen.File, g *protogen.GeneratedFile, importPath string) Visitor

Jump to

Keyboard shortcuts

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