Help us shape the future of Go! Take the 2026 Go Developer Survey

internal

package
v1.2.5 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2023 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

%s
`

	StructTPL = `type %s struct {
%s
}`
	ImportTPL       = `import "%s"`
	FieldTPL        = "  %s %s `json:\"%s,omitempty\"`"
	ListFieldTPL    = "  %s []%s `json:\"%s,omitempty\"`"
	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",
	"Long":     "int64",
	"DateTime": "time.Time",
	"UUID":     "uuid.UUID",
}
View Source
var ImportedLibs = map[string]string{
	"uuid.UUID": "github.com/google/uuid",
	"time.Time": "time",
}

Functions

func LoadSchemas

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

Types

type Config

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

	InPlace     bool
	GoGenConfig *GOGenerate
}

func ReadConfigFromFile

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) WriteToStart

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

func (*FileOutput) Writeln

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

type GOGenerate

type GOGenerate struct {
	GOFile    string
	GOLine    int
	GOPackage string
}

func GetGOGenerate

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

type InputSchema struct {
	Data       string
	SourcePath string
}

func ReadSchemas

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

type OutputItem

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

type Outputer

type Outputer interface {
	Write(s string) error
	WriteToStart(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) WriteToStart

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

func (*STDOutput) Writeln

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

type YamlConfig

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

type YamlGenerateConfig

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

type YamlGenerateItem

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