codegen

package
v0.13.2 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCode added in v0.13.1

func GenerateCode(data *Data) error

Types

type ArgSet added in v0.13.1

type ArgSet struct {
	Args     []*FieldArgument
	FuncDecl string
}

type Data added in v0.13.1

type Data struct {
	Config          *config.Config
	Schema          *ast.Schema
	Directives      DirectiveList
	Objects         Objects
	Inputs          Objects
	Interfaces      map[string]*Interface
	ReferencedTypes map[string]*config.TypeReference
	ComplexityRoots map[string]*Object

	QueryRoot        *Object
	MutationRoot     *Object
	SubscriptionRoot *Object
}

Data is a unified model of the code to be generated. Plugins may modify this structure to do things like implement resolvers or directives automatically (eg grpc, validation)

func BuildData added in v0.13.1

func BuildData(cfg *config.Config) (*Data, error)

func (*Data) Args added in v0.13.1

func (a *Data) Args() map[string][]*FieldArgument

type Directive

type Directive struct {
	*ast.DirectiveDefinition
	Name    string
	Args    []*FieldArgument
	Builtin bool
}

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

func (*Directive) IsLocation added in v0.13.1

func (d *Directive) IsLocation(location ...ast.DirectiveLocation) bool

IsLocation check location directive

func (*Directive) ResolveArgs added in v0.13.1

func (d *Directive) ResolveArgs(obj string, next int) string

type DirectiveList added in v0.13.1

type DirectiveList map[string]*Directive

func (DirectiveList) LocationDirectives added in v0.13.1

func (dl DirectiveList) LocationDirectives(location string) DirectiveList

LocationDirectives filter directives by location

type Field

type Field struct {
	*ast.FieldDefinition

	TypeReference    *config.TypeReference
	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
	IsResolver       bool             // Does this field need a resolver
	Args             []*FieldArgument // A list of arguments to be passed to this field
	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
	Stream           bool             // does this field return a channel?
	Directives       []*Directive
}

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) DirectiveObjName added in v0.13.1

func (f *Field) DirectiveObjName() string

func (*Field) GoNameUnexported

func (f *Field) GoNameUnexported() string

func (*Field) HasDirectives added in v0.13.1

func (f *Field) HasDirectives() bool

func (*Field) ImplDirectives added in v0.13.1

func (f *Field) ImplDirectives() []*Directive

func (*Field) IsConcurrent

func (f *Field) IsConcurrent() bool

func (*Field) IsMap added in v0.13.1

func (f *Field) IsMap() bool

func (*Field) IsMethod

func (f *Field) IsMethod() bool

func (*Field) IsReserved added in v0.5.0

func (f *Field) IsReserved() bool

func (*Field) IsVariable

func (f *Field) IsVariable() bool

func (*Field) ResolverType

func (f *Field) ResolverType() string

func (*Field) ShortInvocation

func (f *Field) ShortInvocation() string

func (*Field) ShortResolverDeclaration

func (f *Field) ShortResolverDeclaration() string

type FieldArgument

type FieldArgument struct {
	*ast.ArgumentDefinition
	TypeReference *config.TypeReference
	VarName       string      // The name of the var in go
	Object        *Object     // A link back to the parent object
	Default       interface{} // The default value
	Directives    []*Directive
	Value         interface{} // value set in Data
}

func (*FieldArgument) DirectiveObjName added in v0.13.1

func (f *FieldArgument) DirectiveObjName() string

func (*FieldArgument) ImplDirectives added in v0.13.1

func (f *FieldArgument) ImplDirectives() []*Directive

ImplDirectives get not Builtin and location ARGUMENT_DEFINITION directive

func (*FieldArgument) Stream

func (f *FieldArgument) Stream() bool

type GoFieldType

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

type Interface

type Interface struct {
	*ast.Definition
	Type         types.Type
	Implementors []InterfaceImplementor
	InTypemap    bool
}

type InterfaceImplementor

type InterfaceImplementor struct {
	*ast.Definition

	Type    types.Type
	TakeRef bool
}

func (*InterfaceImplementor) CanBeNil added in v0.13.1

func (i *InterfaceImplementor) CanBeNil() bool

type Object

type Object struct {
	*ast.Definition

	Type               types.Type
	ResolverInterface  types.Type
	Root               bool
	Fields             []*Field
	Implements         []*ast.Definition
	DisableConcurrency bool
	Stream             bool
	Directives         []*Directive
}

func (*Object) Description added in v0.13.1

func (o *Object) Description() string

func (*Object) HasDirectives added in v0.13.1

func (o *Object) HasDirectives() bool

func (*Object) HasResolvers

func (o *Object) HasResolvers() bool

func (*Object) HasUnmarshal added in v0.13.1

func (o *Object) HasUnmarshal() 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

func (*Object) Reference added in v0.13.1

func (o *Object) Reference() types.Type

func (*Object) UniqueFields added in v0.13.1

func (o *Object) UniqueFields() map[string][]*Field

type Objects

type Objects []*Object

func (Objects) ByName

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

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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