proto2gql

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: 16 Imported by: 0

Documentation

Index

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

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

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

func (c *Config) GetOutputPath() string

type DataLoaderConfig

type DataLoaderConfig struct {
	RequestField string        `mapstructure:"request_field"`
	ResultField  string        `mapstructure:"result_field"`
	MatchField   string        `mapstructure:"match_field"`
	Type         string        `mapstructure:"type"`
	WaitDuration time.Duration `mapstructure:"wait_duration"`
}

type FieldsConfig

type FieldsConfig struct {
	ContextKey string `mapstructure:"context_key"`
}

type GenerateConfig

type GenerateConfig struct {
	Tracer     bool
	VendorPath string
}

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
}

func (Plugin) Generate

func (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 (Plugin) Name() string

func (*Plugin) Prepare

func (p *Plugin) Prepare() error

func (*Plugin) PrintInfo

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

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"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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