types

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: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetGRPCType

func GetGRPCType(t string) string

GetGRPCType protobuf type from matro type

func GetGoGraphQLType

func GetGoGraphQLType(t string) string

GetGoGraphQLType returns graphql go implementation

type from matro type

func GetGoType

func GetGoType(t string) string

GetGoType returns go type from matro type

func GetGraphQLType

func GetGraphQLType(t *Field) string

GetGraphQLType returns graphql schema type from matro type

func IsCompositeType

func IsCompositeType(t string) bool

Types

type CompositeType

type CompositeType struct {
	Name               string
	Fields             map[string]*Field
	ReferedTypes       map[string]*CompositeType
	ParentTypes        map[string]*CompositeType
	IsNode             bool
	IsEdge             bool
	Filters            []string
	GraphqlOps         parser.Ops
	SearchFields       []string
	MutatableFields    []string
	SortBy             []string
	Module             *parser.Module
	AllReferedFields   bool
	HardcodedFilters   map[string]string
	NoGraphql          bool
	IsViewerType       bool
	ViewerRefenceField string
}

CompositeType defines a non trivial type with a set of informations like what all fields, opeations supported, etc.

func NewCompositeType

func NewCompositeType(d *parser.Definition, module parser.Module, typesMap map[string]*parser.Type, typeDef *parser.Type) (*CompositeType, error)

NewCompositeType return an instance of the CompositeType

func (*CompositeType) ConnectionName

func (c *CompositeType) ConnectionName() string

ConnectionName returns the connection type name

func (*CompositeType) EdgeFields

func (c *CompositeType) EdgeFields() *utils.Set[string]

EdgeFields return the paginated fields that can be an edge

func (*CompositeType) EdgeName

func (c *CompositeType) EdgeName() string

EdgeName returns the edge type name

func (*CompositeType) FieldType

func (c *CompositeType) FieldType(field string) string

FieldType return the type of the given field

func (*CompositeType) Mutatable

func (c *CompositeType) Mutatable() bool

Mutatable will say this type is mutatable for not

func (*CompositeType) Queries

func (c *CompositeType) Queries() []Query

type Field

type Field struct {
	Name             string
	Type             string
	GraphQLType      string
	IsList           bool
	IsNullable       bool
	IsPaginated      bool
	MaxCount         int
	IsQuery          bool
	Args             []Field
	IsPrimitive      bool
	IsJoinedData     bool
	IsMutatable      bool
	HardcodedFilters map[string]string
	NoGraphql        bool
	ViewerRefence    bool
}

Field defines the field meta data by its type, is it a list, is it nullable etc..

func NewField

func NewField(d *parser.Definition, typesMap map[string]*parser.Type, typeDef *parser.Type, name string, isViewerReferece bool) *Field

TODO(@gokultp) clean up this function, make it more readable NewField returns an instance of the field

func (*Field) ArgNames

func (f *Field) ArgNames() []string

func (*Field) GoInputName

func (f *Field) GoInputName(allExported ...bool) string

GoName return the field name to be used in go code

func (*Field) GoName

func (f *Field) GoName(allExported ...bool) string

GoName return the field name to be used in go code

func (*Field) GoType

func (f *Field) GoType(args ...bool) string

GoType return the gotype to be used in go code args[0] graphql enabled args[1] update type

func (*Field) GraphQLFormattedName

func (f *Field) GraphQLFormattedName() string

GraphQLFormattedName returns the formatted graphql name for the field if it is queiriable it formats like field(args...):Type!

func (*Field) GraphQLFortmattedInputType

func (f *Field) GraphQLFortmattedInputType(args ...bool) string

TODO: @gokul clean this up GraphQLFortmattedType return the graphql type name

func (*Field) GraphQLFortmattedType

func (f *Field) GraphQLFortmattedType(args ...bool) string

GraphQLFortmattedType return the graphql type name

type Query

type Query struct {
	*Field
	Parent *CompositeType
}

Query encapsulates a graphql query metadata

func (Query) InputName

func (q Query) InputName() string

type TypeDefs

type TypeDefs struct {
	Types      map[string]*CompositeType
	Queries    []Query
	QueryTypes map[string]*CompositeType
}

TypeDefs encapsulates the list of types it keeps the information in the form of a map of type name to Type struct

func GetTypeDefs

func GetTypeDefs(d *parser.Definition) (*TypeDefs, error)

GetTypeDefs get all typedefs from the parsed json schema

func (*TypeDefs) GetTypes

func (g *TypeDefs) GetTypes(types map[string]*parser.Type) []*CompositeType

GetTypes gets list of types by name

Jump to

Keyboard shortcuts

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