schemaparser

package
v0.0.39 Latest Latest
Warning

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

Go to latest
Published: May 4, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindFunction

func FindFunction(code, pkgName, fnName string) (*packages.Package, *ast.FuncDecl, error)

func FindFunctionFromParser

func FindFunctionFromParser(parser Parser, fss ...FunctionSearch) (*packages.Package, map[string]*ast.FuncDecl, error)

func FindFunctions

func FindFunctions(code, pkgName string, fnNames ...string) (*packages.Package, map[string]*ast.FuncDecl, error)

func GetNodeNameFromEntConfig added in v0.0.38

func GetNodeNameFromEntConfig(configName string) (string, error)

func LoadPackage

func LoadPackage(p Parser) (*packages.Package, error)

func LoadPackageX

func LoadPackageX(p Parser) *packages.Package

func LoadPackages

func LoadPackages(p Parser) ([]*packages.Package, error)

func LoadPackagesX

func LoadPackagesX(p Parser) []*packages.Package

func ParseCustomGraphQLDefinitions

func ParseCustomGraphQLDefinitions(parser Parser, codeParser CustomCodeParser) chan ParseCustomGQLResult

ParseCustomGraphQLDefinitions takes a file Parser and a custom code Parser and returns a channel to the result

Types

type ConfigSchemaParser

type ConfigSchemaParser struct {
	AbsRootPath   string
	FilesToIgnore []string
}

func (*ConfigSchemaParser) GetConfig

func (p *ConfigSchemaParser) GetConfig() (*packages.Config, string, error)

type CustomCodeParser

type CustomCodeParser interface {
	// ReceiverRequired validates if the receiver of a function is required or not
	// e.g. can the function be a standalone function or does it have to be a method?
	// To further process if the method is of a valid struct, see CustomCodeParserWithReceiver
	// where we can evaluate to see that only methods of acceptable structs are parsed
	// A return value of true indicates it's a method and not a function
	ReceiverRequired() bool

	// ProcessFileName is used to indicate if the filename should be evaluated.
	// eg.. don't process these generated files since there wouldn't be any custom functions there
	// A return value of true indicates the file will be processed
	ProcessFileName(string) bool

	// TODO document
	CreatesComplexTypeForSingleResult() bool
}

CustomCodeParser is used to configure the parsing process

type CustomCodeParserWithReceiver

type CustomCodeParserWithReceiver interface {
	CustomCodeParser
	ValidateFnReceiver(name string) error
}

CustomCodeParserWithReceiver is for extra validation of the method see CustomCodeParser.ReceiverRequired

type EntConfigInfo

type EntConfigInfo struct {
	PackageName string `json:"packageName"`
	ConfigName  string `json:"configName"`
}

TODO kill this

func GetEntConfigFromEntConfig

func GetEntConfigFromEntConfig(configName string) (*EntConfigInfo, error)

func GetEntConfigFromName

func GetEntConfigFromName(packageName string) *EntConfigInfo

type Field

type Field struct {
	// Name of the field in argument or return list
	Name string
	Type enttype.Type
	// contains filtered or unexported fields
}

Field represents an item in an argument list or return list for a function

type Function

type Function struct {
	// e.g. User/Contact etc
	NodeName string
	// GraphQLName is the name of the Field in GraphQL
	GraphQLName string
	// FunctionName is the function that should be called in codegen. It includes the package if not in the "graphql"
	FunctionName string
	// Args are the arguments to the function
	Args []*Field
	// Results shows the list of return values of the function.
	Results []*Field
	// PackagePath is the package path as used by the go/types package.
	PackagePath string

	// CommentGroup return the comments associated with this function
	CommentGroup *GraphQLCommentGroup
}

Function represents a function that's parsed and needs to be represented in GraphQL

type FunctionMap

type FunctionMap map[string][]*Function

FunctionMap is a Map of GraphQL Type to list of Functions that need to be added to GQL

type FunctionSearch

type FunctionSearch struct {
	FnName   string
	FileName string
}

type GraphQLCommentGroup

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

func (*GraphQLCommentGroup) DisableGraphQLInputType

func (doc *GraphQLCommentGroup) DisableGraphQLInputType() bool

func (*GraphQLCommentGroup) GetGraphQLType

func (doc *GraphQLCommentGroup) GetGraphQLType() string

type Object

type Object struct {
	Name        string
	GraphQLName string
	PackagePath string
	Fields      []*Field
}

type ParseCustomGQLResult

type ParseCustomGQLResult struct {
	Functions FunctionMap
	Error     error
	Objects   []*Object
}

ParseCustomGQLResult is the result object of parsing the code path given

type Parser

type Parser interface {
	GetConfig() (*packages.Config, string, error)
}

type ParserNeedsCleanup

type ParserNeedsCleanup interface {
	Parser
	Cleanup()
}

type SourceSchemaParser

type SourceSchemaParser struct {
	Sources     map[string]string
	PackageName string // defaults to configs if not passed
	// contains filtered or unexported fields
}

func (*SourceSchemaParser) Cleanup

func (p *SourceSchemaParser) Cleanup()

func (*SourceSchemaParser) GetConfig

func (p *SourceSchemaParser) GetConfig() (*packages.Config, string, error)

Jump to

Keyboard shortcuts

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