parser

package
v0.0.0-...-5afa41d Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// String defines the string type
	String = "string"
	// Int defines the int type supported, here the system uses int32 internally
	// as google v8 engine and graphql supports only int32
	Int = "int"
	// Float defines the float type
	Float = "float"
	// ID defines the ID type, the sustem uses string version of uuid
	ID = "id"
	// Time defines timestamp type, internally uses time.Time
	Time = "time"
	// Bool defines boolean type
	Bool = "bool"
	// Object defines object type schema for composite types
	Object = "object"
	// List defines list type schema for composite types
	List = "list"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Defaults

type Defaults struct {
	ViewerType string `json:"viewer_type"`
}

type Definition

type Definition struct {
	Modules  []Module  `json:"modules"`
	Repo     string    `json:"repo"`
	Queries  []*Type   `json:"high_level_queries"`
	Defaults *Defaults `json:"defaults"`
}

Definition encapsulates the input schema definiton

func NewDefinition

func NewDefinition() *Definition

NewDefinition return an instance of Definition

func (*Definition) ParseFrom

func (d *Definition) ParseFrom(reader io.Reader) (*Definition, error)

ParseFrom parses the definitions from the given reader returns an instance of the same object and error if any. the duplicate return of object helps in chaining the functions like NewDefinition().ParseFrom()

func (*Definition) Validate

func (d *Definition) Validate() error

type Meta

type Meta struct {
	SearchFields       []string `json:"search_fields"`
	Filters            []string `json:"filters"`
	GraphqlOps         Ops      `json:"graphql_ops"`
	MutatableFields    []string `json:"mutatable_fields"`
	SortBy             []string `json:"sort_by"`
	ViewerRefenceField string   `json:"viewer_reference_field"`
}

Meta defines the data schema meta data properties

type Module

type Module struct {
	Name       string           `json:"name"`
	DataSource string           `json:"data_source"`
	DB         string           `json:"db"`
	Entities   map[string]*Type `json:"entities"`
}

Module encapsulates the module meta data

func (*Module) Store

func (m *Module) Store() string

func (*Module) Validate

func (m *Module) Validate() error

type Ops

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

Ops defines the supported graphql CRUD operations

func (*Ops) Create

func (o *Ops) Create() bool

func (*Ops) Delete

func (o *Ops) Delete() bool

func (*Ops) Read

func (o *Ops) Read() bool

func (*Ops) Union

func (o *Ops) Union(op2 Ops)

func (*Ops) UnmarshalJSON

func (m *Ops) UnmarshalJSON(data []byte) error

UnmarshalJSON is a custom json unmarshaller the operations value will be given as a string `CRUD` for eg: to support only Create and Read ops, it will be `CR` this custom unmarshaller will parse the string and construct the Ops object

func (*Ops) Update

func (o *Ops) Update() bool

type Type

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

Type encapsulates the type definition meta data

func (*Type) IsPrimitive

func (t *Type) IsPrimitive() bool

IsPrimitive says the type is primitive or not

func (*Type) UnmarshalJSON

func (t *Type) UnmarshalJSON(b []byte) error

UnmarshalJSON is a custom json unmarshaller type can be either a sting or an object in a given format eg: "int" or {type: "int", meta: {}}

func (*Type) Validate

func (t *Type) Validate() error

Validate will validate parsed type

Jump to

Keyboard shortcuts

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