Documentation
¶
Index ¶
- func Generate(cfg Config) error
- func GenerateServer(cfg Config, filename string) error
- func ImportPathForDir(dir string) (res string)
- func NameForDir(dir string) string
- type BindError
- type BindErrors
- type Build
- type Config
- type Directive
- type Enum
- type EnumValue
- type Field
- func (f *Field) ArgsFunc() string
- func (f *Field) CallArgs() string
- func (f *Field) ComplexityArgs() string
- func (f *Field) ComplexitySignature() string
- func (f *Field) GoNameExported() string
- func (f *Field) GoNameUnexported() string
- func (f *Field) IsConcurrent() bool
- func (f *Field) IsMethod() bool
- func (f *Field) IsReserved() bool
- func (f *Field) IsResolver() bool
- func (f *Field) IsVariable() bool
- func (f *Field) ResolverDeclaration() string
- func (f *Field) ResolverType() string
- func (f *Field) ShortInvocation() string
- func (f *Field) ShortResolverDeclaration() string
- func (f *Field) WriteJson() string
- type FieldArgument
- type GoFieldType
- type Interface
- type InterfaceImplementor
- type Model
- type ModelBuild
- type ModelField
- type NamedType
- type NamedTypes
- type Object
- type Objects
- type PackageConfig
- type Packages
- func (p *Packages) Count() int
- func (p *Packages) Errors() PkgErrors
- func (p *Packages) Evict(importPath string)
- func (p *Packages) Load(importPath string) *packages.Package
- func (p *Packages) LoadAll(importPaths ...string) []*packages.Package
- func (p *Packages) LoadWithTypes(importPath string) *packages.Package
- func (p *Packages) ModTidy() error
- func (p *Packages) NameForPackage(importPath string) string
- func (p *Packages) ReloadAll(importPaths ...string) []*packages.Package
- type PkgErrors
- type Ref
- type ResolverBuild
- type SchemaFilenames
- type ServerBuild
- type Type
- type TypeMap
- type TypeMapEntry
- type TypeMapField
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateServer ¶
func ImportPathForDir ¶ added in v0.12.9
ImportPathForDir takes a path and returns a golang import path for the package
func NameForDir ¶ added in v0.12.9
NameForDir manually looks for package stanzas in files located in the given directory. This can be much faster than having to consult go list, because we already know exactly where to look.
Types ¶
type BindErrors ¶
type BindErrors []BindError
func (BindErrors) Error ¶
func (b BindErrors) Error() string
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"` Objects []Object `yaml:"-"` FilePath string `yaml:"-"` Packages *Packages `yaml:"-"` // contains filtered or unexported fields }
func DefaultConfig ¶
func DefaultConfig() *Config
DefaultConfig creates a copy of the default config
func LoadConfig ¶
LoadConfig reads the gqlgen.yml config file
func LoadConfigFromDefaultLocations ¶
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) CopyModifiersFromAst ¶ added in v0.12.9
func (*Config) ReloadAllPackages ¶ added in v0.12.9
func (c *Config) ReloadAllPackages()
type Directive ¶
type Directive struct { Name string Args []FieldArgument }
func (*Directive) Declaration ¶
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) ComplexityArgs ¶ added in v0.5.0
func (*Field) ComplexitySignature ¶ added in v0.5.0
func (*Field) GoNameExported ¶
func (*Field) GoNameUnexported ¶
func (*Field) IsConcurrent ¶
func (*Field) IsReserved ¶ added in v0.5.0
func (*Field) IsResolver ¶
func (*Field) IsVariable ¶
func (*Field) ResolverDeclaration ¶
func (*Field) ResolverType ¶
func (*Field) ShortInvocation ¶
func (*Field) ShortResolverDeclaration ¶
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 Model ¶
type Model struct { *NamedType Description string Fields []ModelField Implements []*NamedType }
type ModelBuild ¶
type ModelField ¶
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 ¶
type NamedTypes ¶
type Object ¶
type Object struct { *NamedType Fields []Field Satisfies []string Implements []*NamedType ResolverInterface *Ref Root bool DisableConcurrency bool Stream bool }
func (*Object) HasResolvers ¶
func (*Object) Implementors ¶
func (*Object) IsConcurrent ¶ added in v0.5.0
func (*Object) IsReserved ¶ added in v0.5.0
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
func (*PackageConfig) Pkg ¶ added in v0.12.9
func (c *PackageConfig) Pkg() *types.Package
type Packages ¶ added in v0.12.9
type Packages struct {
// contains filtered or unexported fields
}
Packages is a wrapper around x/tools/go/packages that maintains a (hopefully prewarmed) cache of packages that can be invalidated as writes are made and packages are known to change.
func (*Packages) Errors ¶ added in v0.12.9
Errors returns any errors that were returned by Load, either from the call itself or any of the loaded packages.
func (*Packages) Evict ¶ added in v0.12.9
Evict removes a given package import path from the cache, along with any packages that depend on it. Further calls to Load will fetch it from disk.
func (*Packages) Load ¶ added in v0.12.9
Load works the same as LoadAll, except a single package at a time.
func (*Packages) LoadAll ¶ added in v0.12.9
LoadAll will call packages.Load and return the package data for the given packages, but if the package already have been loaded it will return cached values instead.
func (*Packages) LoadWithTypes ¶ added in v0.12.9
LoadWithTypes tries a standard load, which may not have enough type info (TypesInfo== nil) available if the imported package is a second order dependency. Fortunately this doesnt happen very often, so we can just issue a load when we detect it.
func (*Packages) NameForPackage ¶ added in v0.12.9
NameForPackage looks up the package name from the package stanza in the go files at the given import path.
type Ref ¶
type ResolverBuild ¶
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 Type ¶
func (Type) FullSignature ¶
type TypeMap ¶
type TypeMap map[string]TypeMapEntry
func (TypeMap) ReferencedPackages ¶ added in v0.12.9
func (TypeMap) UserDefined ¶ added in v0.12.9
type TypeMapEntry ¶
type TypeMapEntry struct { Model string `yaml:"model"` Fields map[string]TypeMapField `yaml:"fields,omitempty"` }