plugin

package
v0.7.4 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2020 License: Apache-2.0 Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScalarBytes      = "Bytes"
	ScalarFloat32    = "Float32"
	ScalarInt64      = "Int64"
	ScalarInt32      = "Int32"
	ScalarUint32     = "Uint32"
	ScalarUint64     = "Uint64"
	ScalarAny        = "Any"
	ScalarDirective  = "__Directive"
	ScalarType       = "__Type"
	ScalarField      = "__Field"
	ScalarEnumValue  = "__EnumValue"
	ScalarInputValue = "__InputValue"
	ScalarSchema     = "__Schema"
	ScalarInt        = "Int"
	ScalarFloat      = "Float"
	ScalarString     = "String"
	ScalarBoolean    = "Boolean"
	ScalarID         = "ID"
)

Variables

This section is empty.

Functions

func GetGqlFieldOptions

func GetGqlFieldOptions(field *descriptor.FieldDescriptorProto) *gql.Field

func Params

func Params(gen *generator.Generator) map[string]string

Match parsing algorithm from Generator.CommandLineParameters

func SplitCamelCase

func SplitCamelCase(src string) (entries []string)

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

  1. If string is not valid UTF-8, return it without splitting as single item array.
  2. Assign all unicode characters into one of 4 sets: lower case letters, upper case letters, numbers, and all other characters.
  3. Iterate through characters of string, introducing splits between adjacent characters that belong to different sets.
  4. 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

func ToLowerFirst(s string) string

Types

type Callstack

type Callstack interface {
	Push(entry string)
	Pop(entry string)
	Has(entry string) bool
	Free()
	List() []string
}

func NewCallstack

func NewCallstack() Callstack

type Method

type Method struct {
	Name         string
	InputType    string
	OutputType   string
	Phony        bool
	ServiceIndex int
	Index        int

	*descriptor.MethodDescriptorProto
	*descriptor.ServiceDescriptorProto
}

type Methods

type Methods []*Method

func (Methods) NameExists

func (ms Methods) NameExists(name string) bool

type ModelDescriptor

type ModelDescriptor struct {
	BuiltIn     bool
	PackageDir  string
	TypeName    string
	UsedAsInput bool
	Index       int
	OneofTypes  map[string]struct{}
	// contains filtered or unexported fields
}

type OneofRef

type OneofRef struct {
	Parent *Type
	Index  int32
}

type Plugin

type Plugin struct {
	*generator.Generator
	// contains filtered or unexported fields
}

func NewPlugin

func NewPlugin() *Plugin

func (*Plugin) Enums

func (p *Plugin) Enums() map[string]*Type

func (*Plugin) Error

func (p *Plugin) Error(err error, msgs ...string)

func (*Plugin) FillTypeMap

func (p *Plugin) FillTypeMap(typeName string, messages map[string]*Type, inputField bool)

recursively goes trough all fields of the types from messages map and fills it with child types. i. e. if message Type1 { Type2: field1 = 1; } exists in the map this function will look up Type2 and add Type2 to the map as well

func (*Plugin) GetOneof

func (p *Plugin) GetOneof(ref OneofRef) *Type

func (*Plugin) GetSchemaByIndex

func (p *Plugin) GetSchemaByIndex(index int) *bytes.Buffer

func (*Plugin) GqlModelNames

func (p *Plugin) GqlModelNames() map[*Type]string

func (*Plugin) GraphQLType

func (p *Plugin) GraphQLType(field *descriptor.FieldDescriptorProto, messagesIn map[string]*Type) string

func (*Plugin) In

func (p *Plugin) In()

func (*Plugin) InitFile

func (p *Plugin) InitFile(file *generator.FileDescriptor)

func (*Plugin) Inputs

func (p *Plugin) Inputs() map[string]*Type

func (*Plugin) IsAny

func (p *Plugin) IsAny(typeName string) (ok bool)

func (*Plugin) IsEmpty

func (p *Plugin) IsEmpty(t *Type) bool

same isEmpty but for mortals

func (*Plugin) Maps

func (p *Plugin) Maps() map[string]*Type

func (*Plugin) Mutations

func (p *Plugin) Mutations() Methods

func (*Plugin) Oneofs

func (p *Plugin) Oneofs() map[string]*Type

func (*Plugin) Out

func (p *Plugin) Out()

func (*Plugin) P

func (p *Plugin) P(str ...interface{})

func (*Plugin) PrintComments

func (p *Plugin) PrintComments(path ...int) bool

func (*Plugin) Queries

func (p *Plugin) Queries() Methods

func (*Plugin) Scalars

func (p *Plugin) Scalars() map[string]*Type

func (*Plugin) Subscriptions

func (p *Plugin) Subscriptions() Methods

func (*Plugin) Types

func (p *Plugin) Types() map[string]*Type

func (*Plugin) Warn

func (p *Plugin) Warn(msgs ...interface{})

type TypeMapEntry

type TypeMapEntry struct {
	Key   string
	Value *Type
}

type TypeMapList

type TypeMapList []*TypeMapEntry

func TypeMap2List

func TypeMap2List(t map[string]*Type) (m TypeMapList)

func (TypeMapList) Len

func (t TypeMapList) Len() int

func (TypeMapList) Less

func (t TypeMapList) Less(i, j int) bool

func (TypeMapList) Swap

func (t TypeMapList) Swap(i, j int)

Jump to

Keyboard shortcuts

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