spec

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2021 License: MIT Imports: 12 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsGooglePackage added in v0.6.0

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 added in v0.6.0

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 added in v0.6.0

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

type Dependencies added in v0.6.0

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

func NewDependencies added in v0.6.0

func NewDependencies() *Dependencies

func (*Dependencies) Depend added in v0.6.0

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

func (*Dependencies) GetDependendencies added in v0.6.0

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

func (*Dependencies) IsDepended added in v0.6.0

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 added in v0.6.0

func (e *Enum) FullPath() string

func (*Enum) Name

func (e *Enum) Name() string

Get name for definition generation

func (*Enum) PathName added in v0.18.0

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 added in v0.6.0

func (f *Field) DefaultValue() string

func (*Field) FieldName added in v0.13.0

func (f *Field) FieldName() string

func (*Field) FieldType added in v0.6.0

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

func (*Field) FieldTypeInput added in v0.6.0

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 added in v0.15.0

func (f *Field) IsOmit() bool

func (*Field) IsRepeated

func (f *Field) IsRepeated() bool

func (*Field) IsRequired added in v0.6.0

func (f *Field) IsRequired() bool

func (*Field) IsResolve added in v0.16.0

func (f *Field) IsResolve() bool

func (*Field) Label

func (*Field) Name

func (f *Field) Name() string

func (*Field) ResolveSubField added in v0.16.0

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

func (*Field) SchemaInputType added in v0.6.0

func (f *Field) SchemaInputType() string

func (*Field) SchemaType added in v0.6.0

func (f *Field) SchemaType() string

func (*Field) Type

func (*Field) TypeName

func (f *Field) TypeName() string

type File

type File struct {
	CompilerVersion *plugin.Version
	// 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,
	cv *plugin.Version,
	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 added in v0.6.0

func (m *Message) FullPath() string

func (*Message) Interfaces added in v0.6.0

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 added in v0.6.0

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

func (*Message) TypeName added in v0.6.0

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 added in v0.6.0

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

Mutation spec wraps MethodDescriptorProto.

func NewMutation added in v0.6.0

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

func (*Mutation) Args added in v0.6.0

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

func (*Mutation) InputName added in v0.6.0

func (m *Mutation) InputName() string

func (*Mutation) InputType added in v0.6.0

func (m *Mutation) InputType() string

func (*Mutation) IsCamel added in v0.13.0

func (m *Mutation) IsCamel() bool

func (*Mutation) IsPluckRequest added in v0.6.0

func (m *Mutation) IsPluckRequest() bool

func (*Mutation) IsPluckResponse added in v0.6.0

func (m *Mutation) IsPluckResponse() bool

func (*Mutation) MutationName added in v0.6.0

func (m *Mutation) MutationName() string

func (*Mutation) MutationType added in v0.6.0

func (m *Mutation) MutationType() string

func (*Mutation) OutputName added in v0.6.0

func (m *Mutation) OutputName() string

func (*Mutation) Package added in v0.6.0

func (m *Mutation) Package() string

func (*Mutation) PluckRequest added in v0.6.0

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

func (*Mutation) PluckResponse added in v0.6.0

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

func (*Mutation) PluckResponseFieldName added in v0.6.0

func (m *Mutation) PluckResponseFieldName() string

func (*Mutation) Request added in v0.6.0

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

func (*Mutation) Response added in v0.6.0

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

type Package added in v0.6.0

type Package struct {
	Name      string
	CamelName string
	Path      string
}

func NewGoPackageFromString added in v0.8.1

func NewGoPackageFromString(pkg string) *Package

func NewGooglePackage added in v0.14.0

func NewGooglePackage(m PackageGetter) *Package

func NewPackage added in v0.6.0

func NewPackage(g PackageGetter) *Package

type PackageGetter added in v0.6.0

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

type Params

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

Params spec have plugin parameters

func NewParams

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

func (*Params) IsExclude added in v0.8.2

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

func (*Params) IsSourceRelative added in v0.22.0

func (p *Params) IsSourceRelative() bool

type Query added in v0.6.0

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

Query spec wraps MethodDescriptorProto.

func NewQuery added in v0.6.0

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

func (*Query) Args added in v0.6.0

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

func (*Query) InputType added in v0.6.0

func (q *Query) InputType() string

func (*Query) IsCamel added in v0.13.0

func (q *Query) IsCamel() bool

func (*Query) IsPluckRequest added in v0.6.0

func (q *Query) IsPluckRequest() bool

func (*Query) IsPluckResponse added in v0.6.0

func (q *Query) IsPluckResponse() bool

func (*Query) IsResolver added in v0.16.0

func (q *Query) IsResolver() bool

func (*Query) OutputName added in v0.6.0

func (q *Query) OutputName() string

func (*Query) Package added in v0.6.0

func (q *Query) Package() string

func (*Query) PluckRequest added in v0.6.0

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

func (*Query) PluckResponse added in v0.6.0

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

func (*Query) PluckResponseFieldName added in v0.6.0

func (q *Query) PluckResponseFieldName() string

func (*Query) QueryName added in v0.6.0

func (q *Query) QueryName() string

func (*Query) QueryType added in v0.6.0

func (q *Query) QueryType() string

func (*Query) Request added in v0.6.0

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

func (*Query) Response added in v0.6.0

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

func (*Query) SchemaArgs added in v0.6.0

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