package codegen
import "github.com/99designs/gqlgen/codegen"
Index ¶
- func GenerateCode(data *Data) error
- type ArgSet
- type AugmentedSource
- type Data
- func BuildData(cfg *config.Config, plugins ...any) (*Data, error)
- func (d *Data) Args() map[string][]*FieldArgument
- func (d *Data) BuiltInDirectives() DirectiveList
- func (d *Data) Directives() DirectiveList
- func (d *Data) HasEmbeddableSources() bool
- func (d *Data) UserDirectives() DirectiveList
- type Directive
- func (d *Directive) ArgsFunc() string
- func (d *Directive) CallArgs() string
- func (d *Directive) CallName() string
- func (d *Directive) CallPath() string
- func (d *Directive) Declaration() string
- func (d *Directive) FunctionImpl() string
- func (d *Directive) IsBuiltIn() bool
- func (d *Directive) IsLocation(location ...ast.DirectiveLocation) bool
- func (d *Directive) ResolveArgs(obj string, next int) string
- type DirectiveList
- type Field
- func (f *Field) ArgsFunc() string
- func (f *Field) CallArgs() string
- func (f *Field) ChildFieldContextFunc(name string) string
- func (f *Field) ComplexityArgs() string
- func (f *Field) ComplexitySignature() string
- func (f *Field) DirectiveObjName() string
- func (f *Field) FieldContextFunc() string
- func (f *Field) GoNameUnexported() string
- func (f *Field) GoResultName() (string, bool)
- func (f *Field) HasDirectives() bool
- func (f *Field) ImplDirectives() []*Directive
- func (f *Field) IsConcurrent() bool
- func (f *Field) IsInputObject() bool
- func (f *Field) IsMap() bool
- func (f *Field) IsMethod() bool
- func (f *Field) IsReserved() bool
- func (f *Field) IsRoot() bool
- func (f *Field) IsVariable() bool
- func (f *Field) ResolverType() string
- func (f *Field) ShortInvocation() string
- func (f *Field) ShortResolverDeclaration() string
- func (f *Field) ShortResolverSignature(ft *goast.FuncType) string
- type FieldArgument
- func (f *FieldArgument) DirectiveObjName() string
- func (f *FieldArgument) ImplDirectives() []*Directive
- func (f *FieldArgument) Stream() bool
- type GoFieldType
- type Interface
- type InterfaceImplementor
- type Object
- func (o *Object) Description() string
- func (o *Object) HasDirectives() bool
- func (o *Object) HasField(name string) bool
- func (o *Object) HasResolvers() bool
- func (o *Object) HasUnmarshal() bool
- func (o *Object) Implementors() string
- func (o *Object) IsConcurrent() bool
- func (o *Object) IsMap() bool
- func (o *Object) IsReserved() bool
- func (o *Object) Reference() types.Type
- func (o *Object) UniqueFields() map[string][]*Field
- type Objects
Functions ¶
func GenerateCode ¶
Types ¶
type ArgSet ¶
type ArgSet struct { Args []*FieldArgument FuncDecl string }
type AugmentedSource ¶
type AugmentedSource struct { // path relative to Config.Exec.Filename RelativePath string Embeddable bool BuiltIn bool Source string }
AugmentedSource contains extra information about graphql schema files which is not known directly from the Config.Sources data
type Data ¶
type Data struct { Config *config.Config Schema *ast.Schema // If a schema is broken up into multiple Data instance, each representing part of the schema, // AllDirectives should contain the directives for the entire schema. Directives() can // then be used to get the directives that were defined in this Data instance's sources. // If a single Data instance is used for the entire schema, AllDirectives and Directives() // will be identical. // AllDirectives should rarely be used directly. AllDirectives DirectiveList Objects Objects Inputs Objects Interfaces map[string]*Interface ReferencedTypes map[string]*config.TypeReference ComplexityRoots map[string]*Object QueryRoot *Object MutationRoot *Object SubscriptionRoot *Object AugmentedSources []AugmentedSource Plugins []any }
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 ¶
func (*Data) Args ¶
func (d *Data) Args() map[string][]*FieldArgument
func (*Data) BuiltInDirectives ¶
func (d *Data) BuiltInDirectives() DirectiveList
Get only the directives which should have a statically provided definition
func (*Data) Directives ¶
func (d *Data) Directives() DirectiveList
Get only the directives which are defined in the config's sources.
func (*Data) HasEmbeddableSources ¶
func (*Data) UserDirectives ¶
func (d *Data) UserDirectives() DirectiveList
Get only the directives which should have a user provided definition on server instantiation
type Directive ¶
type Directive struct { *ast.DirectiveDefinition Name string Args []*FieldArgument config.DirectiveConfig }
func (*Directive) ArgsFunc ¶
func (*Directive) CallArgs ¶
func (*Directive) CallName ¶
func (*Directive) CallPath ¶
func (*Directive) Declaration ¶
func (*Directive) FunctionImpl ¶
func (*Directive) IsBuiltIn ¶
func (*Directive) IsLocation ¶
func (d *Directive) IsLocation(location ...ast.DirectiveLocation) bool
IsLocation check location directive
func (*Directive) ResolveArgs ¶
type DirectiveList ¶
func (DirectiveList) LocationDirectives ¶
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 VOkFunc bool // If this is bound to a go method, is it of shape (any, bool) Object *Object // A link back to the parent object Default any // The default value Stream bool // does this field return a channel? Directives []*Directive }
func (*Field) ArgsFunc ¶
func (*Field) CallArgs ¶
func (*Field) ChildFieldContextFunc ¶
func (*Field) ComplexityArgs ¶
func (*Field) ComplexitySignature ¶
func (*Field) DirectiveObjName ¶
func (*Field) FieldContextFunc ¶
func (*Field) GoNameUnexported ¶
func (*Field) GoResultName ¶
func (*Field) HasDirectives ¶
func (*Field) ImplDirectives ¶
func (*Field) IsConcurrent ¶
func (*Field) IsInputObject ¶
func (*Field) IsMap ¶
func (*Field) IsMethod ¶
func (*Field) IsReserved ¶
func (*Field) IsRoot ¶
func (*Field) IsVariable ¶
func (*Field) ResolverType ¶
func (*Field) ShortInvocation ¶
func (*Field) ShortResolverDeclaration ¶
func (*Field) ShortResolverSignature ¶
ShortResolverSignature is identical to ShortResolverDeclaration, but respects previous naming (return) conventions, if any.
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 any // The default value Directives []*Directive Value any // value set in Data CallArgumentDirectivesWithNull bool }
func (*FieldArgument) DirectiveObjName ¶
func (f *FieldArgument) DirectiveObjName() string
func (*FieldArgument) ImplDirectives ¶
func (f *FieldArgument) ImplDirectives() []*Directive
ImplDirectives get not SkipRuntime 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 ¶
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 PointersInUnmarshalInput bool }
func (*Object) Description ¶
func (*Object) HasDirectives ¶
func (*Object) HasField ¶
func (*Object) HasResolvers ¶
func (*Object) HasUnmarshal ¶
func (*Object) Implementors ¶
func (*Object) IsConcurrent ¶
func (*Object) IsMap ¶
func (*Object) IsReserved ¶
func (*Object) Reference ¶
func (*Object) UniqueFields ¶
type Objects ¶
type Objects []*Object
func (Objects) ByName ¶
Source Files ¶
args.go complexity.go data.go directive.go field.go generate.go interface.go object.go type.go util.go
Directories ¶
- Version
- v0.17.73 (latest)
- Published
- May 2, 2025
- Platform
- linux/amd64
- Imports
- 19 packages
- Last checked
- 3 days ago –
Tools for package owners.