spec

package
v0.18.10 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsGooglePackage

func IsGooglePackage(p PackageGetter) bool

func PrefixEnum

func PrefixEnum(name string) string

PrefixEnum adds prefix to avoid conflicting name

func PrefixInput

func PrefixInput(name string) string

PrefixInput adds prefix to avoid conflicting name

func PrefixInterface

func PrefixInterface(name string) string

PrefixInterface adds prefix to avoid conflicting name

func PrefixType

func PrefixType(name string) string

PrefixType adds prefix to avoid conflicting name

Types

type CommentType

type CommentType int

CommentType indicates comment format.

const (
	GraphqlComment CommentType = iota
	GoComment
)

type Comments

type Comments map[string]string

type DependType

type DependType int
const (
	DependTypeMessage DependType = iota
	DependTypeInput
	DependTypeEnum
	DependTypeInterface
)

type Dependencies

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

func NewDependencies

func NewDependencies() *Dependencies

func (*Dependencies) Depend

func (d *Dependencies) Depend(t DependType, pkg string)

func (*Dependencies) GetDependendencies

func (d *Dependencies) GetDependendencies() map[string][]string

func (*Dependencies) IsDepended

func (d *Dependencies) IsDepended(t DependType, pkg string) bool

type Enum

type Enum struct {
	*File

	*Dependencies
	// contains filtered or unexported fields
}

Enum spec wraps EnumDescriptorProto with keeping file definition.

func NewEnum

func NewEnum(
	d *descriptor.EnumDescriptorProto,
	f *File,
	prefix []string,
	paths ...int,
) *Enum

func (*Enum) Comment

func (e *Enum) Comment() string

func (*Enum) FullPath

func (e *Enum) FullPath() string

func (*Enum) Name

func (e *Enum) Name() string

Get name for definition generation

func (*Enum) PathName

func (e *Enum) PathName() string

Get path name with prefix

func (*Enum) SingleName

func (e *Enum) SingleName() string

func (*Enum) Values

func (e *Enum) Values() []*EnumValue

type EnumValue

type EnumValue struct {
	*File
	// contains filtered or unexported fields
}

EnumValue spec wraps EnumValueDescriptorProto with keeping file definition.

func NewEnumValue

func NewEnumValue(
	d *descriptor.EnumValueDescriptorProto,
	f *File,
	paths ...int,
) *EnumValue

func (*EnumValue) Comment

func (e *EnumValue) Comment() string

func (*EnumValue) Name

func (e *EnumValue) Name() string

func (*EnumValue) Number

func (e *EnumValue) Number() int32

type Field

type Field struct {
	Option *graphql.GraphqlField
	*File

	DependType interface{}
	IsCyclic   bool
	// contains filtered or unexported fields
}

Field spec wraps FieldDescriptorProto with keeping file info

func NewField

func NewField(
	d *descriptor.FieldDescriptorProto,
	f *File,
	isCamel bool,
	paths ...int,
) *Field

func (*Field) Comment

func (f *Field) Comment() string

func (*Field) DefaultValue

func (f *Field) DefaultValue() string

func (*Field) FieldName

func (f *Field) FieldName() string

func (*Field) FieldType

func (f *Field) FieldType(rootPackage string) string

func (*Field) FieldTypeInput

func (f *Field) FieldTypeInput(rootPackage string) string

func (*Field) GraphqlGoType

func (f *Field) GraphqlGoType(rootPackage string, isInput bool) string

GraphqlGoType returns appropriate graphql-go type

func (*Field) GraphqlType

func (f *Field) GraphqlType() string

GraphqlType returns appropriate GraphQL type

func (*Field) IsOmit

func (f *Field) IsOmit() bool

func (*Field) IsRepeated

func (f *Field) IsRepeated() bool

func (*Field) IsRequired

func (f *Field) IsRequired() bool

func (*Field) IsResolve

func (f *Field) IsResolve() bool

func (*Field) Label

func (*Field) Name

func (f *Field) Name() string

func (*Field) ResolveSubField

func (f *Field) ResolveSubField(services []*Service) *Query

func (*Field) SchemaInputType

func (f *Field) SchemaInputType() string

func (*Field) SchemaType

func (f *Field) SchemaType() string

func (*Field) Type

func (*Field) TypeName

func (f *Field) TypeName() string

type File

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

File spec wraps FileDescriptorProto and this spec will be passed in all other specs in order to get filename, package name, etc...

func NewFile

func NewFile(d *descriptor.FileDescriptorProto, isCamel bool) *File

func (*File) Enums

func (f *File) Enums() []*Enum

func (*File) Filename

func (f *File) Filename() string

func (*File) GoPackage

func (f *File) GoPackage() string

func (*File) Messages

func (f *File) Messages() []*Message

func (*File) Package

func (f *File) Package() string

func (*File) Services

func (f *File) Services() []*Service

type Message

type Message struct {
	*File

	*Dependencies
	PluckFields []*Field
	// contains filtered or unexported fields
}

Message spec wraps DescriptorProto

func NewMessage

func NewMessage(
	d *descriptor.DescriptorProto,
	f *File,
	prefix []string,
	isCamel bool,
	paths ...int,
) *Message

func (*Message) Comment

func (m *Message) Comment() string

func (*Message) Fields

func (m *Message) Fields() []*Field

func (*Message) FullPath

func (m *Message) FullPath() string

func (*Message) Interfaces

func (m *Message) Interfaces() (ifs []*Message)

func (*Message) Name

func (m *Message) Name() string

func (*Message) SingleName

func (m *Message) SingleName() string

func (*Message) StructName

func (m *Message) StructName(ptr bool) string

func (*Message) TypeFields

func (m *Message) TypeFields() []*Field

func (*Message) TypeName

func (m *Message) TypeName() string

type Method

type Method struct {
	Service *Service
	Schema  *graphql.GraphqlSchema
	*File
	// contains filtered or unexported fields
}

Method spec wraps MethodDescriptorProto with GraphqlQuery and GraphqlMutation options.

func NewMethod

func NewMethod(
	m *descriptor.MethodDescriptorProto,
	s *Service,
	paths ...int,
) *Method

func (*Method) Comment

func (m *Method) Comment() string

func (*Method) Input

func (m *Method) Input() string

func (*Method) Name

func (m *Method) Name() string

func (*Method) Output

func (m *Method) Output() string

func (*Method) ServiceName

func (m *Method) ServiceName() string

type Mutation

type Mutation struct {
	*Method
	Input  *Message
	Output *Message
	// contains filtered or unexported fields
}

Mutation spec wraps MethodDescriptorProto.

func NewMutation

func NewMutation(m *Method, input, output *Message, isCamel bool) *Mutation

func (*Mutation) Args

func (m *Mutation) Args() []*Field

func (*Mutation) InputName

func (m *Mutation) InputName() string

func (*Mutation) InputType

func (m *Mutation) InputType() string

func (*Mutation) IsCamel

func (m *Mutation) IsCamel() bool

func (*Mutation) IsPluckRequest

func (m *Mutation) IsPluckRequest() bool

func (*Mutation) IsPluckResponse

func (m *Mutation) IsPluckResponse() bool

func (*Mutation) MutationName

func (m *Mutation) MutationName() string

func (*Mutation) MutationType

func (m *Mutation) MutationType() string

func (*Mutation) OutputName

func (m *Mutation) OutputName() string

func (*Mutation) Package

func (m *Mutation) Package() string

func (*Mutation) PluckRequest

func (m *Mutation) PluckRequest() []*Field

func (*Mutation) PluckResponse

func (m *Mutation) PluckResponse() []*Field

func (*Mutation) PluckResponseFieldName

func (m *Mutation) PluckResponseFieldName() string

func (*Mutation) Request

func (m *Mutation) Request() *graphql.GraphqlRequest

func (*Mutation) Response

func (m *Mutation) Response() *graphql.GraphqlResponse

type Package

type Package struct {
	Name      string
	CamelName string
	Path      string
}

func NewGoPackageFromString

func NewGoPackageFromString(pkg string) *Package

func NewGooglePackage

func NewGooglePackage(m PackageGetter) *Package

func NewPackage

func NewPackage(g PackageGetter) *Package

type PackageGetter

type PackageGetter interface {
	Package() string
	GoPackage() string
	Filename() string
}

type Params

type Params struct {
	QueryOut       string
	Excludes       []*regexp.Regexp
	Verbose        bool
	FieldCamelCase bool
	RelativePaths  bool
}

Params spec have plugin parameters

func NewParams

func NewParams(p string) (*Params, error)

func (*Params) IsExclude

func (p *Params) IsExclude(pkg string) bool

type Query

type Query struct {
	*Method
	Input  *Message
	Output *Message
	// contains filtered or unexported fields
}

Query spec wraps MethodDescriptorProto.

func NewQuery

func NewQuery(m *Method, input, output *Message, isCamel bool) *Query

func (*Query) Args

func (q *Query) Args() []*Field

func (*Query) InputType

func (q *Query) InputType() string

func (*Query) IsCamel

func (q *Query) IsCamel() bool

func (*Query) IsPluckRequest

func (q *Query) IsPluckRequest() bool

func (*Query) IsPluckResponse

func (q *Query) IsPluckResponse() bool

func (*Query) IsResolver

func (q *Query) IsResolver() bool

func (*Query) OutputName

func (q *Query) OutputName() string

func (*Query) Package

func (q *Query) Package() string

func (*Query) PluckRequest

func (q *Query) PluckRequest() []*Field

func (*Query) PluckResponse

func (q *Query) PluckResponse() []*Field

func (*Query) PluckResponseFieldName

func (q *Query) PluckResponseFieldName() string

func (*Query) QueryName

func (q *Query) QueryName() string

func (*Query) QueryType

func (q *Query) QueryType() string

func (*Query) Request

func (q *Query) Request() *graphql.GraphqlRequest

func (*Query) Response

func (q *Query) Response() *graphql.GraphqlResponse

func (*Query) SchemaArgs

func (q *Query) SchemaArgs() string

type Service

type Service struct {
	Option *graphql.GraphqlService
	*File

	Queries   []*Query
	Mutations []*Mutation
	// contains filtered or unexported fields
}

Service spec wraps ServiceDescriptorProto with GraphqlService option.

func NewService

func NewService(
	d *descriptor.ServiceDescriptorProto,
	f *File,
	paths ...int,
) *Service

func (*Service) Comment

func (s *Service) Comment() string

func (*Service) Host

func (s *Service) Host() string

func (*Service) Insecure

func (s *Service) Insecure() bool

func (*Service) Methods

func (s *Service) Methods() []*Method

func (*Service) Name

func (s *Service) Name() string

Jump to

Keyboard shortcuts

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