generator

package
v0.0.0-...-c400f7e Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2018 License: Apache-2.0 Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var KnownGQLTypes = map[string]bool{
	"__Directive":         true,
	"__DirectiveLocation": true,
	"__EnumValue":         true,
	"__Field":             true,
	"__InputValue":        true,
	"__Schema":            true,
	"__Type":              true,
	"__TypeKind":          true,
	"LIST":                true,
	"String":              true,
	"Float":               true,
	"ID":                  true,
	"Int":                 true,
	"Boolean":             true,
	"Time":                true,
}
View Source
var KnownGoTypes = map[string]bool{
	"string":  true,
	"bool":    true,
	"float32": true,
	"float64": true,
	"int":     true,
	"int32":   true,
	"int64":   true,
}

Functions

func GenServer

func GenServer() string

Types

type FieldDef

type FieldDef struct {
	Name        string
	Parent      string
	Description string
	Type        *Typ

	Args []*FieldDef
	// contains filtered or unexported fields
}

func NewField

func NewField(t *introspection.Field) *FieldDef

func (*FieldDef) GenFuncArgs

func (f *FieldDef) GenFuncArgs() string

FIXME could be refactored and become part of GenResStruct()

func (*FieldDef) GenResolver

func (f *FieldDef) GenResolver() string

Resolvers generates the resolver function for the given FieldDef

func (*FieldDef) Parse

func (f *FieldDef) Parse()

type Generator

type Generator struct {
	*bytes.Buffer

	PkgName string
	// contains filtered or unexported fields
}

func New

func New() *Generator

New creates a new generator and allocates the request and response protobufs.

func (*Generator) Error

func (g *Generator) Error(err error, msgs ...string)

Error reports a problem, including an error, and exits the program.

func (*Generator) Fail

func (g *Generator) Fail(msgs ...string)

Fail reports a problem and exits the program.

func (Generator) GenSchemaResolversFile

func (g Generator) GenSchemaResolversFile() []byte

Fill the buffer with the generated output for all the files we're supposed to generate.

func (Generator) GenServerFile

func (g Generator) GenServerFile() []byte

func (*Generator) In

func (g *Generator) In()

In Indents the output one tab stop.

func (*Generator) Out

func (g *Generator) Out()

Out unindents the output one tab stop.

func (*Generator) P

func (g *Generator) P(str ...interface{})

P prints the arguments to the generated output. It handles strings and int32s, plus handling indirections because they may be *string, etc.

func (*Generator) Parse

func (g *Generator) Parse(fileData []byte) error

func (*Generator) SetPkgName

func (g *Generator) SetPkgName(name string) *Generator

type SchemaMap

type SchemaMap struct {
	RootTypes     map[string]string
	ResolverTypes map[string]string
	ResolverFuncs map[string]string
}

func NewSchemaMap

func NewSchemaMap() *SchemaMap

type Typ

type Typ struct {
	GoType     string
	GQLType    string
	IsNullable bool
	Type       *Typ
	Values     []string
	// contains filtered or unexported fields
}

type TypeDef

type TypeDef struct {
	Name        string
	Description string
	Fields      map[string]*FieldDef
	GQLType     string
	// contains filtered or unexported fields
}

func NewType

func NewType(t *introspection.Type) *TypeDef

func (*TypeDef) GenInterface

func (t *TypeDef) GenInterface() string

FIXME could be refactored and become part of GenStruct()

func (*TypeDef) GenInterfaceResStruct

func (t *TypeDef) GenInterfaceResStruct(typePkgName string) string

FIXME could be refactored and become part of GenResStruct()

func (*TypeDef) GenResStruct

func (t *TypeDef) GenResStruct(typePkgName string) string

func (*TypeDef) GenStruct

func (t *TypeDef) GenStruct(typ string) string

func (*TypeDef) GenUnionResStruct

func (t *TypeDef) GenUnionResStruct() string

func (*TypeDef) GenUnionResolver

func (t *TypeDef) GenUnionResolver(parentName string) string

Jump to

Keyboard shortcuts

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