codegen

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2019 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Generate

func Generate(cfg Config) error

func GenerateServer

func GenerateServer(cfg Config, filename string) error

Types

type BindError

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

func (BindError) Error

func (b BindError) Error() string

type BindErrors

type BindErrors []BindError

func (BindErrors) Error

func (b BindErrors) Error() string

type Build

type Build struct {
	PackageName      string
	Objects          Objects
	Inputs           Objects
	Interfaces       []*Interface
	QueryRoot        *Object
	MutationRoot     *Object
	SubscriptionRoot *Object
	SchemaRaw        map[string]string
	SchemaFilename   SchemaFilenames
	Directives       []*Directive
}

type Config

type Config struct {
	SchemaFilename SchemaFilenames   `yaml:"schema,omitempty"`
	SchemaStr      map[string]string `yaml:"-"`
	Exec           PackageConfig     `yaml:"exec"`
	Model          PackageConfig     `yaml:"model"`
	Resolver       PackageConfig     `yaml:"resolver,omitempty"`
	Models         TypeMap           `yaml:"models,omitempty"`
	StructTag      string            `yaml:"struct_tag,omitempty"`

	FilePath string `yaml:"-"`
	// contains filtered or unexported fields
}

func DefaultConfig

func DefaultConfig() *Config

DefaultConfig creates a copy of the default config

func LoadConfig

func LoadConfig(filename string) (*Config, error)

LoadConfig reads the gqlgen.yml config file

func LoadConfigFromDefaultLocations

func LoadConfigFromDefaultLocations() (*Config, error)

LoadConfigFromDefaultLocations looks for a config file in the current directory, and all parent directories walking up the tree. The closest config file will be returned.

func (*Config) Check

func (cfg *Config) Check() error

type Directive

type Directive struct {
	Name string
	Args []FieldArgument
}

func (*Directive) ArgsFunc added in v0.5.1

func (d *Directive) ArgsFunc() string

func (*Directive) CallArgs

func (d *Directive) CallArgs() string

func (*Directive) Declaration

func (d *Directive) Declaration() string

type Enum

type Enum struct {
	*NamedType
	Description string
	Values      []EnumValue
}

type EnumValue

type EnumValue struct {
	Name        string
	Description string
}

type Field

type Field struct {
	*Type
	Description      string          // Description of a field
	GQLName          string          // The name of the field in graphql
	GoFieldType      GoFieldType     // The field type in go, if any
	GoReceiverName   string          // The name of method & var receiver in go, if any
	GoFieldName      string          // The name of the method or var in go, if any
	Args             []FieldArgument // A list of arguments to be passed to this field
	ForceResolver    bool            // Should be emit Resolver method
	MethodHasContext bool            // If this is bound to a go method, does the method also take a context
	NoErr            bool            // If this is bound to a go method, does that method have an error as the second argument
	Object           *Object         // A link back to the parent object
	Default          interface{}     // The default value
}

func (*Field) ArgsFunc added in v0.5.1

func (f *Field) ArgsFunc() string

func (*Field) CallArgs

func (f *Field) CallArgs() string

func (*Field) ComplexityArgs added in v0.5.0

func (f *Field) ComplexityArgs() string

func (*Field) ComplexitySignature added in v0.5.0

func (f *Field) ComplexitySignature() string

func (*Field) GoNameExported

func (f *Field) GoNameExported() string

func (*Field) GoNameUnexported

func (f *Field) GoNameUnexported() string

func (*Field) IsConcurrent

func (f *Field) IsConcurrent() bool

func (*Field) IsMethod

func (f *Field) IsMethod() bool

func (*Field) IsReserved added in v0.5.0

func (f *Field) IsReserved() bool

func (*Field) IsResolver

func (f *Field) IsResolver() bool

func (*Field) IsVariable

func (f *Field) IsVariable() bool

func (*Field) ResolverDeclaration

func (f *Field) ResolverDeclaration() string

func (*Field) ResolverType

func (f *Field) ResolverType() string

func (*Field) ShortInvocation

func (f *Field) ShortInvocation() string

func (*Field) ShortResolverDeclaration

func (f *Field) ShortResolverDeclaration() string

func (*Field) WriteJson

func (f *Field) WriteJson() string

should be in the template, but its recursive and has a bunch of args

type FieldArgument

type FieldArgument struct {
	*Type

	GQLName   string      // The name of the argument in graphql
	GoVarName string      // The name of the var in go
	Object    *Object     // A link back to the parent object
	Default   interface{} // The default value
}

func (*FieldArgument) Stream

func (f *FieldArgument) Stream() bool

type GoFieldType

type GoFieldType int
const (
	GoFieldUndefined GoFieldType = iota
	GoFieldMethod
	GoFieldVariable
)

type Interface

type Interface struct {
	*NamedType

	Implementors []InterfaceImplementor
}

type InterfaceImplementor

type InterfaceImplementor struct {
	ValueReceiver bool

	*NamedType
}

type Model

type Model struct {
	*NamedType
	Description string
	Fields      []ModelField
	Implements  []*NamedType
}

type ModelBuild

type ModelBuild struct {
	PackageName string
	Models      []Model
	Enums       []Enum
}

type ModelField

type ModelField struct {
	*Type
	GQLName     string
	GoFieldName string
	GoFKName    string
	GoFKType    string
	Description string
}

type NamedType

type NamedType struct {
	Ref
	IsScalar    bool
	IsInterface bool
	IsInput     bool
	GQLType     string // Name of the graphql type
	Marshaler   *Ref   // If this type has an external marshaler this will be set
}

func (NamedType) IsMarshaled

func (t NamedType) IsMarshaled() bool

type NamedTypes

type NamedTypes map[string]*NamedType

type Object

type Object struct {
	*NamedType

	Fields             []Field
	Satisfies          []string
	Implements         []*NamedType
	ResolverInterface  *Ref
	Root               bool
	DisableConcurrency bool
	Stream             bool
}

func (*Object) HasResolvers

func (o *Object) HasResolvers() bool

func (*Object) Implementors

func (o *Object) Implementors() string

func (*Object) IsConcurrent added in v0.5.0

func (o *Object) IsConcurrent() bool

func (*Object) IsReserved added in v0.5.0

func (o *Object) IsReserved() bool

type Objects

type Objects []*Object

func (Objects) ByName

func (os Objects) ByName(name string) *Object

type PackageConfig

type PackageConfig struct {
	Filename string `yaml:"filename,omitempty"`
	Package  string `yaml:"package,omitempty"`
	Type     string `yaml:"type,omitempty"`
}

func (*PackageConfig) Check

func (c *PackageConfig) Check() error

func (*PackageConfig) Dir

func (c *PackageConfig) Dir() string

func (*PackageConfig) ImportPath

func (c *PackageConfig) ImportPath() string

func (*PackageConfig) IsDefined

func (c *PackageConfig) IsDefined() bool

type Ref

type Ref struct {
	GoType        string // Name of the go type
	Package       string // the package the go type lives in
	IsUserDefined bool   // does the type exist in the typemap
}

func (Ref) FullName

func (t Ref) FullName() string

func (Ref) PkgDot

func (t Ref) PkgDot() string

type ResolverBuild

type ResolverBuild struct {
	PackageName   string
	ResolverType  string
	Objects       Objects
	ResolverFound bool
}

type SchemaFilenames added in v0.7.0

type SchemaFilenames []string

func (SchemaFilenames) Has added in v0.7.0

func (a SchemaFilenames) Has(file string) bool

func (*SchemaFilenames) UnmarshalYAML added in v0.7.0

func (a *SchemaFilenames) UnmarshalYAML(unmarshal func(interface{}) error) error

type ServerBuild

type ServerBuild struct {
	PackageName         string
	ExecPackageName     string
	ResolverPackageName string
}

type Type

type Type struct {
	*NamedType

	Modifiers   []string
	ASTType     *ast.Type
	AliasedType *Ref
}

func (Type) FullSignature

func (t Type) FullSignature() string

func (Type) IsPtr

func (t Type) IsPtr() bool

func (Type) IsSlice

func (t Type) IsSlice() bool

func (Type) Marshal

func (t Type) Marshal(val string) string

func (Type) Signature

func (t Type) Signature() string

func (*Type) StripPtr

func (t *Type) StripPtr()

func (Type) Unmarshal

func (t Type) Unmarshal(result, raw string) string

type TypeMap

type TypeMap map[string]TypeMapEntry

func (TypeMap) Check

func (tm TypeMap) Check() error

func (TypeMap) Exists

func (tm TypeMap) Exists(typeName string) bool

type TypeMapEntry

type TypeMapEntry struct {
	Model  string                  `yaml:"model"`
	Fields map[string]TypeMapField `yaml:"fields,omitempty"`
}

type TypeMapField

type TypeMapField struct {
	Resolver  bool   `yaml:"resolver"`
	FieldName string `yaml:"fieldName"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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