gqlgen: github.com/99designs/gqlgen/codegen Index | Files | Directories

package codegen

import "github.com/99designs/gqlgen/codegen"

Index

Package Files

args.go complexity.go data.go directive.go field.go generate.go interface.go object.go type.go util.go

func GenerateCode Uses

func GenerateCode(data *Data) error

type ArgSet Uses

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

type Data Uses

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 Uses

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

func (*Data) Args Uses

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

type Directive Uses

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

func (*Directive) ArgsFunc Uses

func (d *Directive) ArgsFunc() string

func (*Directive) CallArgs Uses

func (d *Directive) CallArgs() string

func (*Directive) Declaration Uses

func (d *Directive) Declaration() string

func (*Directive) IsLocation Uses

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

IsLocation check location directive

func (*Directive) ResolveArgs Uses

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

type DirectiveList Uses

type DirectiveList map[string]*Directive

func (DirectiveList) LocationDirectives Uses

func (dl DirectiveList) LocationDirectives(location string) DirectiveList

LocationDirectives filter directives by location

type Field Uses

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 Uses

func (f *Field) ArgsFunc() string

func (*Field) CallArgs Uses

func (f *Field) CallArgs() string

func (*Field) ComplexityArgs Uses

func (f *Field) ComplexityArgs() string

func (*Field) ComplexitySignature Uses

func (f *Field) ComplexitySignature() string

func (*Field) DirectiveObjName Uses

func (f *Field) DirectiveObjName() string

func (*Field) GoNameUnexported Uses

func (f *Field) GoNameUnexported() string

func (*Field) HasDirectives Uses

func (f *Field) HasDirectives() bool

func (*Field) ImplDirectives Uses

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

func (*Field) IsConcurrent Uses

func (f *Field) IsConcurrent() bool

func (*Field) IsMap Uses

func (f *Field) IsMap() bool

func (*Field) IsMethod Uses

func (f *Field) IsMethod() bool

func (*Field) IsReserved Uses

func (f *Field) IsReserved() bool

func (*Field) IsVariable Uses

func (f *Field) IsVariable() bool

func (*Field) ResolverType Uses

func (f *Field) ResolverType() string

func (*Field) ShortInvocation Uses

func (f *Field) ShortInvocation() string

func (*Field) ShortResolverDeclaration Uses

func (f *Field) ShortResolverDeclaration() string

type FieldArgument Uses

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 Uses

func (f *FieldArgument) DirectiveObjName() string

func (*FieldArgument) ImplDirectives Uses

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

ImplDirectives get not Builtin and location ARGUMENT_DEFINITION directive

func (*FieldArgument) Stream Uses

func (f *FieldArgument) Stream() bool

type GoFieldType Uses

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

type Interface Uses

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

type InterfaceImplementor Uses

type InterfaceImplementor struct {
    *ast.Definition

    Type    types.Type
    TakeRef bool
}

func (*InterfaceImplementor) CanBeNil Uses

func (i *InterfaceImplementor) CanBeNil() bool

type Object Uses

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 Uses

func (o *Object) Description() string

func (*Object) HasDirectives Uses

func (o *Object) HasDirectives() bool

func (*Object) HasResolvers Uses

func (o *Object) HasResolvers() bool

func (*Object) HasUnmarshal Uses

func (o *Object) HasUnmarshal() bool

func (*Object) Implementors Uses

func (o *Object) Implementors() string

func (*Object) IsConcurrent Uses

func (o *Object) IsConcurrent() bool

func (*Object) IsReserved Uses

func (o *Object) IsReserved() bool

func (*Object) Reference Uses

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

func (*Object) UniqueFields Uses

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

type Objects Uses

type Objects []*Object

func (Objects) ByName Uses

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

Directories

PathSynopsis
config
templates
testserver
testserver/introspection
testserver/invalid-packagename
testserver/otherpkg

Package codegen imports 12 packages (graph) and is imported by 29 packages. Updated 2020-05-12. Refresh now. Tools for package owners.