Documentation
¶
Index ¶
- Constants
- func GoPackageByPath(path, vendorPath string) (string, error)
- type Config
- type DataLoaderConfig
- type FieldsConfig
- type GenerateConfig
- type MessageConfig
- type MethodConfig
- type Plugin
- type Proto2GraphQL
- func (g *Proto2GraphQL) AddSourceByConfig(config *ProtoFileConfig) error
- func (g *Proto2GraphQL) FieldOutputGraphQLTypeResolver(message *parser.Message, fieldName string) (graphql.TypeResolver, error)
- func (g *Proto2GraphQL) FieldOutputValueResolver(message *parser.Message, fieldName string) (_ graphql.ValueResolver, err error)
- func (g *Proto2GraphQL) TypeInputGraphQLTypeResolver(typeFile *parsedFile, typ parser.Type) (graphql.TypeResolver, error)
- func (g *Proto2GraphQL) TypeOutputGraphQLTypeResolver(typeFile *parsedFile, typ parser.Type) (graphql.TypeResolver, error)
- func (g *Proto2GraphQL) TypeValueResolver(typeFile *parsedFile, typ parser.Type, ctxKey string, ptr bool) (_ graphql.ValueResolver, withErr, fromArgs bool, err error)
- type ProtoFileConfig
- func (pc *ProtoFileConfig) GetGQLEnumsPrefix() string
- func (pc *ProtoFileConfig) GetGQLMessagePrefix() string
- func (pc *ProtoFileConfig) GetGoPackage() string
- func (pc *ProtoFileConfig) GetImportsAliases() []map[string]string
- func (pc *ProtoFileConfig) GetMessages() []map[string]MessageConfig
- func (pc *ProtoFileConfig) GetName() string
- func (pc *ProtoFileConfig) GetOutputPath() string
- func (pc *ProtoFileConfig) GetOutputPkg() string
- func (pc *ProtoFileConfig) GetPaths() []string
- func (pc *ProtoFileConfig) GetProtoPath() string
- func (pc *ProtoFileConfig) GetServices() map[string]ServiceConfig
- func (pc *ProtoFileConfig) MessageConfig(msgName string) (MessageConfig, error)
- type SchemaConfig
- type SchemaNodeConfig
- type ServiceConfig
Constants ¶
View Source
const ( RequestTypeQuery = "QUERY" RequestTypeMutation = "MUTATION" )
View Source
const ( DataLoaderType1ToN = "1-N" DataLoaderType1To1 = "1-1" )
View Source
const ( PluginName = "proto2gql" PluginConfigKey = "proto2gql" PluginImportConfigKey = "proto2gql_files" )
Variables ¶
This section is empty.
Functions ¶
func GoPackageByPath ¶
Types ¶
type Config ¶
type Config struct {
Files []*ProtoFileConfig `mapstructure:"files"`
// Global configs for proto files
Paths []string `mapstructure:"paths"`
OutputPath string `mapstructure:"output_path"`
ImportsAliases []map[string]string `mapstructure:"imports_aliases"`
Messages []map[string]MessageConfig `mapstructure:"messages"`
}
func (*Config) GetOutputPath ¶
type DataLoaderConfig ¶
type FieldsConfig ¶
type FieldsConfig struct {
ContextKey string `mapstructure:"context_key"`
}
type GenerateConfig ¶
type MessageConfig ¶
type MessageConfig struct {
ErrorField string `mapstructure:"error_field"`
Fields map[string]FieldsConfig `mapstructure:"fields"`
DataLoaders []dataloader.FieldConfig `mapstructure:"data_loaders"`
UnwrapField bool `mapstructure:"unwrap_field"`
}
type MethodConfig ¶
type MethodConfig struct {
Alias string `mapstructure:"alias"`
RequestType string `mapstructure:"request_type"` // QUERY | MUTATION
DataLoaderProvider map[string]DataLoaderConfig `mapstructure:"data_loaders"`
}
type Plugin ¶
type Plugin struct {
// contains filtered or unexported fields
}
type Proto2GraphQL ¶
type Proto2GraphQL struct {
DataLoaderPlugin *dataloader.Plugin
VendorPath string
GenerateTracers bool
ParsedFiles []*parsedFile
OutputPath string
// contains filtered or unexported fields
}
func (*Proto2GraphQL) AddSourceByConfig ¶
func (g *Proto2GraphQL) AddSourceByConfig(config *ProtoFileConfig) error
AddSourceByConfig parse source proto files according to config definition
func (*Proto2GraphQL) FieldOutputGraphQLTypeResolver ¶
func (g *Proto2GraphQL) FieldOutputGraphQLTypeResolver(message *parser.Message, fieldName string) (graphql.TypeResolver, error)
func (*Proto2GraphQL) FieldOutputValueResolver ¶
func (g *Proto2GraphQL) FieldOutputValueResolver(message *parser.Message, fieldName string) (_ graphql.ValueResolver, err error)
func (*Proto2GraphQL) TypeInputGraphQLTypeResolver ¶
func (g *Proto2GraphQL) TypeInputGraphQLTypeResolver(typeFile *parsedFile, typ parser.Type) (graphql.TypeResolver, error)
func (*Proto2GraphQL) TypeOutputGraphQLTypeResolver ¶
func (g *Proto2GraphQL) TypeOutputGraphQLTypeResolver(typeFile *parsedFile, typ parser.Type) (graphql.TypeResolver, error)
func (*Proto2GraphQL) TypeValueResolver ¶
func (g *Proto2GraphQL) TypeValueResolver(typeFile *parsedFile, typ parser.Type, ctxKey string, ptr bool) (_ graphql.ValueResolver, withErr, fromArgs bool, err error)
type ProtoFileConfig ¶
type ProtoFileConfig struct {
Name string `mapstructure:"name"`
Paths []string `mapstructure:"paths"`
ImportsAliases []map[string]string `mapstructure:"imports_aliases"`
ProtoPath string `mapstructure:"proto_path"`
OutputPkg string `mapstructure:"output_package"`
OutputPath string `mapstructure:"output_path"`
ProtoGoPackage string `mapstructure:"proto_go_package"` // go package of protoc generated code
GQLEnumsPrefix string `mapstructure:"gql_enums_prefix"`
GQLMessagePrefix string `mapstructure:"gql_messages_prefix"`
Services map[string]ServiceConfig `mapstructure:"services"`
Messages []map[string]MessageConfig `mapstructure:"messages"`
}
func (*ProtoFileConfig) GetGQLEnumsPrefix ¶
func (pc *ProtoFileConfig) GetGQLEnumsPrefix() string
func (*ProtoFileConfig) GetGQLMessagePrefix ¶
func (pc *ProtoFileConfig) GetGQLMessagePrefix() string
func (*ProtoFileConfig) GetGoPackage ¶
func (pc *ProtoFileConfig) GetGoPackage() string
func (*ProtoFileConfig) GetImportsAliases ¶
func (pc *ProtoFileConfig) GetImportsAliases() []map[string]string
func (*ProtoFileConfig) GetMessages ¶
func (pc *ProtoFileConfig) GetMessages() []map[string]MessageConfig
func (*ProtoFileConfig) GetName ¶
func (pc *ProtoFileConfig) GetName() string
func (*ProtoFileConfig) GetOutputPath ¶
func (pc *ProtoFileConfig) GetOutputPath() string
func (*ProtoFileConfig) GetOutputPkg ¶
func (pc *ProtoFileConfig) GetOutputPkg() string
func (*ProtoFileConfig) GetPaths ¶
func (pc *ProtoFileConfig) GetPaths() []string
func (*ProtoFileConfig) GetProtoPath ¶
func (pc *ProtoFileConfig) GetProtoPath() string
func (*ProtoFileConfig) GetServices ¶
func (pc *ProtoFileConfig) GetServices() map[string]ServiceConfig
func (*ProtoFileConfig) MessageConfig ¶
func (pc *ProtoFileConfig) MessageConfig(msgName string) (MessageConfig, error)
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"
Proto string `mapstructure:"proto"`
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 ServiceConfig ¶
type ServiceConfig struct {
ServiceName string `mapstructure:"service_name"`
Methods map[string]MethodConfig `mapstructure:"methods"`
}
Source Files
¶
Click to show internal directories.
Click to hide internal directories.