parser

package
v0.9.3 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TypeIntReq = &FieldType{
	Kind:              "String",
	Required:          true,
	Collection:        false,
	CollectionSubtype: nil,
}

TypeIntReq is a pre-filled FieldType for a Required Int field. This is used primarily for unit testing.

View Source
var TypeStringReq = &FieldType{
	Kind:              "String",
	Required:          true,
	Collection:        false,
	CollectionSubtype: nil,
}

TypeStringReq is a pre-filled FieldType for a Required String field. This is used primarily for unit testing.

View Source
var TypeStringReqCollection = &FieldType{
	Required:          true,
	Collection:        true,
	CollectionSubtype: TypeStringReq,
}

TypeStringReqCollection is a pre-filled FieldType for a Required String field. This is used primarily for unit testing.

Functions

func ArgumentsFromMap

func ArgumentsFromMap(in map[string]any) (args map[string]*ParsedArgument)

ArgumentsFromMap generates a ParsedArgument map based on a Go map - this should be used only for testing purposes

Types

type EnumValue

type EnumValue struct {
	Name        string
	Description string
	Directives  map[string][]*ParsedDirective
}

type FieldType

type FieldType struct {
	Kind              string
	Required          bool
	Collection        bool
	CollectionSubtype *FieldType
}

FieldType is a struct that represents a field type, generated by parsing a graphql schema

func ParseFieldType

func ParseFieldType(typ *ast.Type) *FieldType

func (FieldType) AppSyncType

func (ft FieldType) AppSyncType() string

func (FieldType) DynamoPointerFunc

func (ft FieldType) DynamoPointerFunc() string

func (FieldType) DynamoType

func (ft FieldType) DynamoType() string

func (FieldType) GoType

func (ft FieldType) GoType() string

func (FieldType) GoTypeRequired

func (ft FieldType) GoTypeRequired() string

func (FieldType) IsCollectionOfObjects

func (ft FieldType) IsCollectionOfObjects() bool

func (FieldType) IsObject

func (ft FieldType) IsObject() bool

func (FieldType) Validate

func (ft FieldType) Validate() error

Validate is a validation function for field type object

func (FieldType) ZeroValueGo

func (ft FieldType) ZeroValueGo() string

type ParsedArgument

type ParsedArgument struct {
	Name  string
	Value Value
}

func (*ParsedArgument) Validate

func (pa *ParsedArgument) Validate() error

type ParsedArgumentDef

type ParsedArgumentDef struct {
	Name    string
	Type    *FieldType
	Default Value
}

func (*ParsedArgumentDef) GoStructTag

func (pad *ParsedArgumentDef) GoStructTag() string

func (*ParsedArgumentDef) NameCamel

func (pad *ParsedArgumentDef) NameCamel() string

func (*ParsedArgumentDef) NameDash

func (pad *ParsedArgumentDef) NameDash() string

func (*ParsedArgumentDef) NameTitle

func (pad *ParsedArgumentDef) NameTitle() string

func (*ParsedArgumentDef) NameUnder

func (pad *ParsedArgumentDef) NameUnder() string

func (*ParsedArgumentDef) Validate

func (pad *ParsedArgumentDef) Validate() error

type ParsedDirective

type ParsedDirective struct {
	Name      string
	Arguments map[string]*ParsedArgument
}

func (*ParsedDirective) Arg

func (pd *ParsedDirective) Arg(key string) string

func (*ParsedDirective) ArgBool

func (pd *ParsedDirective) ArgBool(key string) bool

func (*ParsedDirective) ArgGo

func (pd *ParsedDirective) ArgGo(key string) string

func (*ParsedDirective) ArgHCL

func (pd *ParsedDirective) ArgHCL(key string) string

func (*ParsedDirective) ArgIsNull

func (pd *ParsedDirective) ArgIsNull(key string) bool

func (*ParsedDirective) ArgJS

func (pd *ParsedDirective) ArgJS(key string) string

func (*ParsedDirective) ArgListString added in v0.9.2

func (pd *ParsedDirective) ArgListString(key string) []string

func (*ParsedDirective) HasArg

func (pd *ParsedDirective) HasArg(key string) bool

func (*ParsedDirective) Validate

func (pd *ParsedDirective) Validate() error

type ParsedEnum

type ParsedEnum struct {
	Name        string
	Description string
	Values      []*EnumValue
}

func (*ParsedEnum) NameCamel

func (e *ParsedEnum) NameCamel() string

func (*ParsedEnum) NameDash

func (e *ParsedEnum) NameDash() string

func (*ParsedEnum) NameTitle

func (e *ParsedEnum) NameTitle() string

func (*ParsedEnum) NameUnder

func (e *ParsedEnum) NameUnder() string

func (*ParsedEnum) Validate

func (e *ParsedEnum) Validate() error

func (*ParsedEnum) ValueString

func (e *ParsedEnum) ValueString() []string

type ParsedField

type ParsedField struct {
	Name        string
	Directives  map[string][]*ParsedDirective
	Description string
	Arguments   map[string]*ParsedArgumentDef
	Type        *FieldType
}

func (*ParsedField) GoStructTag

func (pf *ParsedField) GoStructTag() string

func (*ParsedField) HasDirective

func (pf *ParsedField) HasDirective(key string) bool

func (*ParsedField) NameCamel

func (pf *ParsedField) NameCamel() string

func (*ParsedField) NameDash

func (pf *ParsedField) NameDash() string

func (*ParsedField) NameTitle

func (pf *ParsedField) NameTitle() string

func (*ParsedField) NameUnder

func (pf *ParsedField) NameUnder() string

func (*ParsedField) NormaliseGo added in v0.9.2

func (pf *ParsedField) NormaliseGo(key string) (ret string)

NormaliseGo generates Go code to normalise a value as per the @normalise directive. The key parameter defines the variable name in VTL associated with this field, e.g. "object.myField"

func (*ParsedField) NormaliseVTL added in v0.9.2

func (pf *ParsedField) NormaliseVTL(key string) (ret string)

NormaliseVTL generates VTL (Velocity Template Language, for AppSync) to normalise a value as per the @normalise directive. The key parameter defines the variable name in VTL associated with this field, e.g. "$context.source.x"

func (*ParsedField) SingleDirective

func (pf *ParsedField) SingleDirective(key string) *ParsedDirective

func (*ParsedField) Validate

func (pf *ParsedField) Validate() error

type ParsedObject

type ParsedObject struct {
	Name        string
	Directives  map[string][]*ParsedDirective
	Description string
	Fields      []*ParsedField
	Interfaces  []string
}

func (*ParsedObject) Field

func (po *ParsedObject) Field(key string) *ParsedField

func (*ParsedObject) HasDirective

func (po *ParsedObject) HasDirective(key string) bool

func (*ParsedObject) NameCamel

func (po *ParsedObject) NameCamel() string

func (*ParsedObject) NameDash

func (po *ParsedObject) NameDash() string

func (*ParsedObject) NameTitle

func (po *ParsedObject) NameTitle() string

func (*ParsedObject) NameUnder

func (po *ParsedObject) NameUnder() string

func (*ParsedObject) SingleDirective

func (po *ParsedObject) SingleDirective(key string) *ParsedDirective

func (*ParsedObject) Validate

func (po *ParsedObject) Validate() error

type ParsedUnion

type ParsedUnion struct {
	Name        string
	Description string
	Objects     []string
}

type Schema

type Schema struct {
	Objects      map[string]*ParsedObject
	InputObjects map[string]*ParsedObject
	Enums        map[string]*ParsedEnum
	Unions       map[string]*ParsedUnion

	Query        map[string]*ParsedField
	Mutation     map[string]*ParsedField
	Subscription map[string]*ParsedField
}

func Parse

func Parse(schemaFiles []string) (output *Schema, err error)

func (*Schema) Validate

func (s *Schema) Validate() error

type Value

type Value interface {
	String() string
	GoString() string
	JSString() string
	HCLString() string
}

Jump to

Keyboard shortcuts

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