Documentation ¶
Index ¶
- Constants
- func CamelCase(s string) string
- func CamelCaseSlice(elem []string) string
- func CreateDescriptorsFromProto(req *pluginpb.CodeGeneratorRequest) (descs []*desc.FileDescriptor, err error)
- func GetRequestType(rpcOpts *gqlpb.Rpc, svcOpts *gqlpb.Svc) gqlpb.Type
- func GoCamelCase(s string) string
- func GraphqlFieldOptions(opts proto.Message) *gqlpb.Field
- func GraphqlMethodOptions(opts proto.Message) *gqlpb.Rpc
- func GraphqlOneofOptions(opts proto.Message) *gqlpb.Oneof
- func GraphqlServiceOptions(opts proto.Message) *gqlpb.Svc
- func IsAny(o *desc.MessageDescriptor) bool
- func IsEmpty(o *desc.MessageDescriptor) bool
- func SplitCamelCase(src string) (entries []string)
- func ToLowerFirst(s string) string
- type Callstack
- type FieldDescriptor
- type FieldDescriptorList
- type GoRef
- type MethodDescriptor
- type ObjectDescriptor
- type Registry
- type RootDefinition
- type SchemaDescriptor
- func (s *SchemaDescriptor) AsGraphql() *ast.Schema
- func (s *SchemaDescriptor) CreateObjects(d desc.Descriptor, input bool) (obj *ObjectDescriptor, err error)
- func (s *SchemaDescriptor) GetMutation() *RootDefinition
- func (s *SchemaDescriptor) GetQuery() *RootDefinition
- func (s *SchemaDescriptor) GetSubscription() *RootDefinition
- func (s *SchemaDescriptor) Objects() []*ObjectDescriptor
- type SchemaDescriptorList
- type ServiceAndMethod
Constants ¶
const ( Mutation rootName = "Mutation" Query rootName = "Query" Subscription rootName = "Subscription" )
const ( ScalarInt = "Int" ScalarFloat = "Float" ScalarString = "String" ScalarBoolean = "Boolean" ScalarID = "ID" )
const (
DefaultExtension = "graphql"
)
Variables ¶
This section is empty.
Functions ¶
func CamelCase ¶
CamelCase returns the CamelCased name. If there is an interior underscore followed by a lower case letter, drop the underscore and convert the letter to upper case. There is a remote possibility of this rewrite causing a name collision, but it's so remote we're prepared to pretend it's nonexistent - since the C++ generator lowercases names, it's extremely unlikely to have two fields with different capitalizations. In short, _my_field_name_2 becomes XMyFieldName_2.
func CamelCaseSlice ¶
CamelCaseSlice is like CamelCase, but the argument is a slice of strings to be joined with "_".
func CreateDescriptorsFromProto ¶
func CreateDescriptorsFromProto(req *pluginpb.CodeGeneratorRequest) (descs []*desc.FileDescriptor, err error)
func GoCamelCase ¶
GoCamelCase camel-cases a protobuf name for use as a Go identifier.
If there is an interior underscore followed by a lower case letter, drop the underscore and convert the letter to upper case.
func SplitCamelCase ¶
Split splits the camelcase word and returns a list of words. It also supports digits. Both lower camel case and upper camel case are supported. For more info please check: http://en.wikipedia.org/wiki/CamelCase
Examples
"" => [""] "lowercase" => ["lowercase"] "Class" => ["Class"] "MyClass" => ["My", "Class"] "MyC" => ["My", "C"] "HTML" => ["HTML"] "PDFLoader" => ["PDF", "Loader"] "AString" => ["A", "String"] "SimpleXMLParser" => ["Simple", "XML", "Parser"] "vimRPCPlugin" => ["vim", "RPC", "Plugin"] "GL11Version" => ["GL", "11", "Version"] "99Bottles" => ["99", "Bottles"] "May5" => ["May", "5"] "BFG9000" => ["BFG", "9000"] "BöseÜberraschung" => ["Böse", "Überraschung"] "Two spaces" => ["Two", " ", "spaces"] "BadUTF8\xe2\xe2\xa1" => ["BadUTF8\xe2\xe2\xa1"]
Splitting rules
- If string is not valid UTF-8, return it without splitting as single item array.
- Assign all unicode characters into one of 4 sets: lower case letters, upper case letters, numbers, and all other characters.
- Iterate through characters of string, introducing splits between adjacent characters that belong to different sets.
- Iterate through array of split strings, and if a given string is upper case: if subsequent string is lower case: move last character of upper case string to beginning of lower case string
func ToLowerFirst ¶
Types ¶
type Callstack ¶
type Callstack interface { Push(entry interface{}) Pop(entry interface{}) Has(entry interface{}) bool Free() Len() int }
func NewCallstack ¶
func NewCallstack() Callstack
type FieldDescriptor ¶
type FieldDescriptor struct { *ast.FieldDefinition *desc.FieldDescriptor // contains filtered or unexported fields }
func (*FieldDescriptor) GetType ¶
func (f *FieldDescriptor) GetType() *ObjectDescriptor
type FieldDescriptorList ¶
type FieldDescriptorList []*FieldDescriptor
func (FieldDescriptorList) AsGraphql ¶
func (fl FieldDescriptorList) AsGraphql() (dl []*ast.FieldDefinition)
type MethodDescriptor ¶
type MethodDescriptor struct { *desc.ServiceDescriptor *desc.MethodDescriptor *ast.FieldDefinition // contains filtered or unexported fields }
func (*MethodDescriptor) AsGraphql ¶
func (m *MethodDescriptor) AsGraphql() *ast.FieldDefinition
func (*MethodDescriptor) GetInput ¶
func (m *MethodDescriptor) GetInput() *ObjectDescriptor
func (*MethodDescriptor) GetOutput ¶
func (m *MethodDescriptor) GetOutput() *ObjectDescriptor
type ObjectDescriptor ¶
type ObjectDescriptor struct { *ast.Definition desc.Descriptor // contains filtered or unexported fields }
func (*ObjectDescriptor) AsGraphql ¶
func (o *ObjectDescriptor) AsGraphql() *ast.Definition
func (*ObjectDescriptor) GetFields ¶
func (o *ObjectDescriptor) GetFields() []*FieldDescriptor
func (*ObjectDescriptor) IsInput ¶
func (o *ObjectDescriptor) IsInput() bool
func (*ObjectDescriptor) IsMessage ¶
func (o *ObjectDescriptor) IsMessage() bool
type Registry ¶
type Registry interface { FindMethodByName(name string) *desc.MethodDescriptor FindObjectByName(name string) *desc.MessageDescriptor // Todo maybe find a better way to get ast definition FindObjectByFullyQualifiedName(fqn string) (*desc.MessageDescriptor, *ast.Definition) FindFieldByName(msg desc.Descriptor, name string) *desc.FieldDescriptor }
func NewRegistry ¶
func NewRegistry(files SchemaDescriptorList) Registry
type RootDefinition ¶
type RootDefinition struct { *ast.Definition Parent *SchemaDescriptor // contains filtered or unexported fields }
func NewRootDefinition ¶
func NewRootDefinition(name rootName, parent *SchemaDescriptor) *RootDefinition
func (*RootDefinition) Methods ¶
func (r *RootDefinition) Methods() []*MethodDescriptor
func (*RootDefinition) UniqueName ¶
func (r *RootDefinition) UniqueName(svc *descriptor.ServiceDescriptorProto, rpc *descriptor.MethodDescriptorProto) (name string)
type SchemaDescriptor ¶
type SchemaDescriptor struct { *ast.Schema FileDescriptors []*desc.FileDescriptor // contains filtered or unexported fields }
func NewSchemaDescriptor ¶
func NewSchemaDescriptor(genServiceDesc bool, goref GoRef) *SchemaDescriptor
func (*SchemaDescriptor) AsGraphql ¶
func (s *SchemaDescriptor) AsGraphql() *ast.Schema
func (*SchemaDescriptor) CreateObjects ¶
func (s *SchemaDescriptor) CreateObjects(d desc.Descriptor, input bool) (obj *ObjectDescriptor, err error)
func (*SchemaDescriptor) GetMutation ¶
func (s *SchemaDescriptor) GetMutation() *RootDefinition
func (*SchemaDescriptor) GetQuery ¶
func (s *SchemaDescriptor) GetQuery() *RootDefinition
func (*SchemaDescriptor) GetSubscription ¶
func (s *SchemaDescriptor) GetSubscription() *RootDefinition
func (*SchemaDescriptor) Objects ¶
func (s *SchemaDescriptor) Objects() []*ObjectDescriptor
type SchemaDescriptorList ¶
type SchemaDescriptorList []*SchemaDescriptor
func NewSchemas ¶
func NewSchemas(files []*desc.FileDescriptor, mergeSchemas, genServiceDesc bool, goref GoRef) (schemas SchemaDescriptorList, _ error)
func (SchemaDescriptorList) AsGraphql ¶
func (s SchemaDescriptorList) AsGraphql() (astSchema []*ast.Schema)
func (SchemaDescriptorList) GetForDescriptor ¶
func (s SchemaDescriptorList) GetForDescriptor(file *protogen.File) *SchemaDescriptor
type ServiceAndMethod ¶
type ServiceAndMethod struct {
// contains filtered or unexported fields
}