internal

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2020 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Header = `// Code generated by go generate; DO NOT EDIT.
// This file was generated from GraphQL schema

package %s
`

	StructTPL = `type %s struct {
%s
}`

	FieldTPL        = "  %s %s `json:\"%s\"`"
	ListFieldTPL    = "  %s []%s `json:\"%s\"`"
	EnumTypeDefTPL  = "type %s %s"
	EnumDefConstTPL = "const %s%s %s = \"%s\""
)

Variables

View Source
var GQLTypesToGoTypes = map[string]string{
	"Int":     "int64",
	"Float":   "float64",
	"String":  "string",
	"Boolean": "bool",
	"ID":      "string",
}

Functions

func LoadSchemas added in v1.1.0

func LoadSchemas(inputSchemas []InputSchema) (*ast.SchemaDocument, error)

Types

type Config added in v1.1.0

type Config struct {
	Schemas []string
	Outputs []OutputItem

	InPlace     bool
	GoGenConfig *GOGenerate
}

func ReadConfigFromFile added in v1.1.0

func ReadConfigFromFile(f io.Reader) (Config, error)

type FileOutput

type FileOutput struct {
	OutputFile *os.File
	// contains filtered or unexported fields
}

func NewFileOutput

func NewFileOutput(fName string) (*FileOutput, error)

func (*FileOutput) Close

func (o *FileOutput) Close() error

func (*FileOutput) Flush

func (o *FileOutput) Flush() error

func (*FileOutput) Write

func (o *FileOutput) Write(s string) error

func (*FileOutput) Writeln

func (o *FileOutput) Writeln(s string) error

type GOGenerate added in v1.1.0

type GOGenerate struct {
	GOFile    string
	GOLine    int
	GOPackage string
}

func GetGOGenerate added in v1.1.0

func GetGOGenerate() *GOGenerate

type GoGenerator

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

func NewGoGenerator

func NewGoGenerator(output Outputer, entities []string, packageName string) *GoGenerator

func (*GoGenerator) Generate

func (g *GoGenerator) Generate(doc *ast.SchemaDocument) error

type InputSchema added in v1.1.0

type InputSchema struct {
	Data       string
	SourcePath string
}

func ReadSchemas added in v1.1.0

func ReadSchemas(schemaPaths []string) ([]InputSchema, error)

type OutputItem added in v1.1.0

type OutputItem struct {
	OutputPath  string
	PackageName string
	Entities    []string
}

type Outputer

type Outputer interface {
	Write(s string) error
	Writeln(s string) error
	Close() error
	Flush() error
}

type STDOutput

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

func NewSTDOutput

func NewSTDOutput() *STDOutput

func (*STDOutput) Close

func (o *STDOutput) Close() error

func (*STDOutput) Flush

func (o *STDOutput) Flush() error

func (*STDOutput) Write

func (o *STDOutput) Write(s string) error

func (*STDOutput) Writeln

func (o *STDOutput) Writeln(s string) error

type YamlConfig added in v1.1.0

type YamlConfig struct {
	Schema    []string                    `yaml:"schema"`
	Generates map[string]YamlGenerateItem `yaml:"generates"`
}

type YamlGenerateConfig added in v1.1.0

type YamlGenerateConfig struct {
	PackageName string   `yaml:"packageName"`
	Entities    []string `yaml:"entities"`
}

type YamlGenerateItem added in v1.1.0

type YamlGenerateItem struct {
	Config YamlGenerateConfig `yaml:"config"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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