graphql

package
v0.0.0-...-7953320 Latest Latest
Warning

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

Go to latest
Published: May 28, 2019 License: MIT Imports: 18 Imported by: 5

Documentation

Index

Constants

View Source
const (
	SchemaNodeTypeObject  = "OBJECT"
	SchemaNodeTypeService = "SERVICE"
)
View Source
const (
	PluginName        = "graphql"
	SchemasConfigsKey = "graphql_schemas"
)
View Source
const (
	ScalarsPkgPath       = "github.com/EGT-Ukraine/go2gql/api/scalars"
	MultipartFilePkgPath = "github.com/EGT-Ukraine/go2gql/api/multipartfile"
	InterceptorsPkgPath  = "github.com/EGT-Ukraine/go2gql/api/interceptors"
	GraphqlPkgPath       = "github.com/graphql-go/graphql"
	OpentracingPkgPath   = "github.com/opentracing/opentracing-go"
	ErrorsPkgPath        = "github.com/pkg/errors"
	LogPkg               = "github.com/opentracing/opentracing-go/log"
)
View Source
const KindBytes = reflect.Kind(255)

Variables

This section is empty.

Functions

func Asset

func Asset(name string) ([]byte, error)

Asset loads and returns the asset for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetDir

func AssetDir(name string) ([]string, error)

AssetDir returns the file names below a certain directory embedded in the file by go-bindata. For example if you run go-bindata on data/... and data contains the following hierarchy:

data/
  foo.txt
  img/
    a.png
    b.png

then AssetDir("data") would return []string{"foo.txt", "img"} AssetDir("data/img") would return []string{"a.png", "b.png"} AssetDir("foo.txt") and AssetDir("notexist") would return an error AssetDir("") will return []string{"data"}.

func AssetInfo

func AssetInfo(name string) (os.FileInfo, error)

AssetInfo loads and returns the asset info for the given name. It returns an error if the asset could not be found or could not be loaded.

func AssetNames

func AssetNames() []string

AssetNames returns the names of the assets.

func GoPackageByPath

func GoPackageByPath(path, vendorPath string) (string, error)

func GqlBoolTypeResolver

func GqlBoolTypeResolver(ctx BodyContext) string

func GqlBytesTypeResolver

func GqlBytesTypeResolver(ctx BodyContext) string

func GqlDateTimeTypeResolver

func GqlDateTimeTypeResolver(ctx BodyContext) string

func GqlFloat32TypeResolver

func GqlFloat32TypeResolver(ctx BodyContext) string

func GqlFloat64TypeResolver

func GqlFloat64TypeResolver(ctx BodyContext) string

func GqlFloatTypeResolver

func GqlFloatTypeResolver(ctx BodyContext) string

func GqlInt32TypeResolver

func GqlInt32TypeResolver(ctx BodyContext) string

func GqlInt64TypeResolver

func GqlInt64TypeResolver(ctx BodyContext) string

func GqlIntTypeResolver

func GqlIntTypeResolver(ctx BodyContext) string

func GqlMultipartFileTypeResolver

func GqlMultipartFileTypeResolver(ctx BodyContext) string

func GqlNoDataTypeResolver

func GqlNoDataTypeResolver(ctx BodyContext) string

func GqlStringTypeResolver

func GqlStringTypeResolver(ctx BodyContext) string

func GqlUInt32TypeResolver

func GqlUInt32TypeResolver(ctx BodyContext) string

func GqlUInt64TypeResolver

func GqlUInt64TypeResolver(ctx BodyContext) string

func MustAsset

func MustAsset(name string) []byte

MustAsset is like Asset but panics when Asset would return an error. It simplifies safe initialization of global variables.

func RestoreAsset

func RestoreAsset(dir, name string) error

RestoreAsset restores an asset under the given directory

func RestoreAssets

func RestoreAssets(dir, name string) error

RestoreAssets restores an asset under the given directory recursively

Types

type AssigningWrapper

type AssigningWrapper func(arg string, ctx BodyContext) string

type BodyContext

type BodyContext struct {
	File                 *TypesFile
	Importer             *importer.Importer
	TracerEnabled        bool
	OutputFieldRenderers []OutputObjectFieldRender
}

type ClientMethodCaller

type ClientMethodCaller func(client string, req string, ctx BodyContext) string

type DataLoaderField

type DataLoaderField struct {
	Name                         string
	Type                         string
	IsSlice                      bool
	ParentKeyFieldName           string
	KeyFieldSlice                bool
	NormalizedParentKeyFieldName string
	DataLoaderName               string
}

type Enum

type Enum struct {
	VariableName string
	GraphQLName  string
	Comment      string
	Values       []EnumValue
}

type EnumValue

type EnumValue struct {
	Name    string
	Value   int
	Comment string
}

type GoType

type GoType struct {
	Scalar    bool
	Kind      reflect.Kind
	ElemType  *GoType
	Elem2Type *GoType
	Name      string
	Pkg       string
}

func (GoType) String

func (g GoType) String(i *importer.Importer) string

type InputObject

type InputObject struct {
	VariableName string
	GraphQLName  string
	Fields       []ObjectField
}

type InputObjectResolver

type InputObjectResolver struct {
	FunctionName string
	OutputGoType GoType
	Fields       []InputObjectResolverField
	OneOfFields  []InputObjectResolverOneOf
}

type InputObjectResolverField

type InputObjectResolverField struct {
	OutputFieldName       string
	GraphQLInputFieldName string
	GoType                GoType
	ValueResolver         ValueResolver
	ResolverWithError     bool
	IsFromArgs            bool
}

type InputObjectResolverOneOf

type InputObjectResolverOneOf struct {
	OutputFieldName string
	Fields          []InputObjectResolverOneOfField
}

type InputObjectResolverOneOfField

type InputObjectResolverOneOfField struct {
	GraphQLInputFieldName string
	ValueResolver         ValueResolver
	ResolverWithError     bool
	AssigningWrapper      AssigningWrapper
}

type MapInputObject

type MapInputObject struct {
	VariableName    string
	GraphQLName     string
	KeyObjectType   TypeResolver
	ValueObjectType TypeResolver
}

type MapInputObjectResolver

type MapInputObjectResolver struct {
	FunctionName           string
	KeyGoType              GoType
	ValueGoType            GoType
	KeyResolver            ValueResolver
	KeyResolverWithError   bool
	ValueResolver          ValueResolver
	ValueResolverWithError bool
}

type MapOutputObject

type MapOutputObject struct {
	VariableName    string
	GraphQLName     string
	KeyObjectType   TypeResolver
	ValueObjectType TypeResolver
	ValueResolver   ValueResolver
}

type Method

type Method struct {
	OriginalName           string
	Name                   string
	QuotedComment          string
	GraphQLOutputType      TypeResolver
	Arguments              []MethodArgument
	RequestResolver        ValueResolver
	RequestResolverWithErr bool
	ClientMethodCaller     ClientMethodCaller
	RequestType            GoType
	PayloadErrorChecker    PayloadErrorChecker
	PayloadErrorAccessor   PayloadErrorAccessor
}

type MethodArgument

type MethodArgument struct {
	Name          string
	Type          TypeResolver
	QuotedComment string
}

type ObjectField

type ObjectField struct {
	Name          string
	Type          TypeResolver
	GoType        GoType
	QuotedComment string
	Value         ValueResolver
	NeedCast      bool
	CastTo        GoType
}

type OutputObject

type OutputObject struct {
	VariableName     string
	GraphQLName      string
	GoType           GoType
	Fields           []ObjectField
	DataLoaderFields []*DataLoaderField // TODO: move to dataloader plugin
	MapFields        []ObjectField
}

func (*OutputObject) FindFieldByName

func (s *OutputObject) FindFieldByName(name string) *ObjectField

type OutputObjectFieldRender

type OutputObjectFieldRender interface {
	RenderFields(o OutputObject, ctx BodyContext) (string, error)
}

type PayloadErrorAccessor

type PayloadErrorAccessor func(arg string) string

type PayloadErrorChecker

type PayloadErrorChecker func(arg string) string

type Plugin

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

func (*Plugin) AddOutputObjectFieldRenderer

func (p *Plugin) AddOutputObjectFieldRenderer(renderer OutputObjectFieldRender)

func (*Plugin) AddTypesFile

func (p *Plugin) AddTypesFile(outputPath string, file *TypesFile)

func (*Plugin) Generate

func (p *Plugin) Generate() error

func (*Plugin) Infos

func (p *Plugin) Infos() map[string]string

func (*Plugin) Init

func (p *Plugin) Init(config *generator.GenerateConfig, plugins []generator.Plugin) error

func (Plugin) Name

func (p Plugin) Name() string

func (*Plugin) Prepare

func (p *Plugin) Prepare() error

func (*Plugin) PrintInfo

func (p *Plugin) PrintInfo(infos generator.Infos)

func (*Plugin) SchemasObjects

func (p *Plugin) SchemasObjects() ([]SchemaObjects, error)

SchemasObjects returns info about schemas objects. Useful in external plugins.

func (*Plugin) Types

func (p *Plugin) Types() map[string]*TypesFile

Types returns info about all parsed types

type RenderFieldsContext

type RenderFieldsContext struct {
	OutputObject  OutputObject
	ObjectContext BodyContext
}

type SchemaBodyContext

type SchemaBodyContext struct {
	File           SchemaConfig
	Importer       *importer.Importer
	SchemaName     string
	Services       []SchemaService
	QueryObject    string
	MutationObject string
	Objects        []*gqlObject
	TracerEnabled  bool
}

type SchemaConfig

type SchemaConfig struct {
	Name          string            `mapstructure:"name"`
	OutputPath    string            `mapstructure:"output_path"`
	OutputPackage string            `mapstructure:"output_package"`
	Queries       *SchemaNodeConfig `mapstructure:"queries"`
	Mutations     *SchemaNodeConfig `mapstructure:"mutations"`
}

type SchemaNodeConfig

type SchemaNodeConfig struct {
	Type           string             `mapstructure:"type"` // "OBJECT|SERVICE"
	Service        string             `mapstructure:"service"`
	ObjectName     string             `mapstructure:"object_name"`
	Field          string             `mapstructure:"field"`
	Fields         []SchemaNodeConfig `mapstructure:"fields"`
	ExcludeMethods []string           `mapstructure:"exclude_methods"`
	FilterMethods  []string           `mapstructure:"filter_methods"`
}

type SchemaObjects

type SchemaObjects struct {
	SchemaName     string
	GoPkg          string
	Services       []SchemaService
	QueryObject    string
	MutationObject string
	Objects        []*gqlObject
}

type SchemaParserObjects

type SchemaParserObjects struct {
	Services       []SchemaService
	QueryObject    string
	MutationObject string
	Objects        []*gqlObject
}

type SchemaService

type SchemaService struct {
	Name            string
	ConstructorName string
	Fields          []string
	Pkg             string
	ClientGoType    GoType
}

type Service

type Service struct {
	OriginalName    string
	Name            string
	QuotedComment   string
	CallInterface   GoType
	QueryMethods    []Method
	MutationMethods []Method
}

type ServiceContext

type ServiceContext struct {
	Service        Service
	TracerEnabled  bool
	ServiceMethods []Method
	FieldType      string
	BodyContext    BodyContext
}

type TypeResolver

type TypeResolver func(ctx BodyContext) string

func GqlListTypeResolver

func GqlListTypeResolver(r TypeResolver) TypeResolver

func GqlNonNullTypeResolver

func GqlNonNullTypeResolver(r TypeResolver) TypeResolver

type TypesFile

type TypesFile struct {
	PackageName             string
	Package                 string
	Enums                   []Enum
	OutputObjects           []OutputObject
	InputObjects            []InputObject
	InputObjectResolvers    []InputObjectResolver
	MapInputObjects         []MapInputObject
	MapInputObjectResolvers []MapInputObjectResolver
	MapOutputObjects        []MapOutputObject
	Services                []Service
}

type ValueResolver

type ValueResolver func(arg string, ctx BodyContext) string

func IdentAccessValueResolver

func IdentAccessValueResolver(ident string) ValueResolver

func ResolverCall

func ResolverCall(resolverPkg, resolverFuncName string) ValueResolver

Directories

Path Synopsis
lib

Jump to

Keyboard shortcuts

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