Documentation
¶
Index ¶
- func AddFieldDirective(name string, ...)
- func AddFieldRuntimeDirective(name string, ...)
- func AddObjectDirective(name string, ...)
- func BuildRelation(field *Field) string
- func ExtractValue(v Value) (interface{}, error)
- func Fields(fields map[string]*Field) string
- func IsValidLocation(loc Location) bool
- func Model(typeNode *ObjectNode) string
- func PrefixModels(typeName string) string
- func ValidateDirectives(name string, directives []*Directive, store *NodeStore, location Location) errors.GraphqlErrorInterface
- type Argument
- type BaseLocation
- type BaseNode
- func (n *BaseNode) GetDescription() string
- func (n *BaseNode) GetDirectives() []*Directive
- func (n *BaseNode) GetDirectivesByName(name string) []*Directive
- func (n *BaseNode) GetFields() map[string]*Field
- func (n *BaseNode) GetKind() Kind
- func (n *BaseNode) GetName() string
- func (n *BaseNode) GetPossibleTypes() map[string]*ObjectNode
- func (n *BaseNode) Validate(store *NodeStore) errors.GraphqlErrorInterface
- type BooleanValue
- type Directive
- type DirectiveDefinition
- type EnumNode
- type EnumValue
- type Field
- type FloatValue
- type Fragment
- type InputObjectNode
- type IntValue
- type InterfaceNode
- type Kind
- type ListValue
- type Location
- type Locationable
- type Node
- type NodeStore
- func (s *NodeStore) AddDirective(name string, node *DirectiveDefinition)
- func (s *NodeStore) AddEnum(name string, node *EnumNode)
- func (s *NodeStore) AddInput(name string, node *InputObjectNode)
- func (s *NodeStore) AddInterface(name string, node *InterfaceNode)
- func (s *NodeStore) AddObject(name string, node *ObjectNode)
- func (s *NodeStore) AddScalar(name string, node *ScalarNode)
- func (s *NodeStore) AddUnion(name string, node *UnionNode)
- func (s *NodeStore) InitStore()
- type NullValue
- type ObjectNode
- type ObjectValue
- type Relation
- type RelationType
- type ScalarNode
- type ScalarType
- type StringValue
- type TypeRef
- func (t *TypeRef) GetGoName() string
- func (t *TypeRef) GetGoType(NonNull bool) string
- func (t *TypeRef) GetRealType() *TypeRef
- func (t *TypeRef) IsEnum() bool
- func (t *TypeRef) IsList() bool
- func (t *TypeRef) IsObject() bool
- func (t *TypeRef) IsScalar() bool
- func (t *TypeRef) Validate(store *NodeStore) errors.GraphqlErrorInterface
- func (t *TypeRef) ValidateValue(v interface{}, isVariable bool) errors.GraphqlErrorInterface
- type UnionNode
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddFieldDirective ¶
func AddFieldRuntimeDirective ¶ added in v0.0.4
func AddObjectDirective ¶
func AddObjectDirective(name string, fn func(o *ObjectNode, d *Directive, store *NodeStore) errors.GraphqlErrorInterface)
func BuildRelation ¶
func ExtractValue ¶
func IsValidLocation ¶
func Model ¶
func Model(typeNode *ObjectNode) string
func PrefixModels ¶ added in v0.0.2
func ValidateDirectives ¶
Types ¶
type Argument ¶
type Argument struct { BaseLocation Name string `json:"name"` Description *string `json:"description"` Directives []*Directive `json:"-"` Type *TypeRef `json:"type"` DefaultValue any `json:"default_value"` Value any `json:"-"` IsVariable bool `json:"-"` IsReference bool `json:"-"` }
func (*Argument) GetDefaultValue ¶
func (*Argument) GetValue ¶ added in v0.0.4
func (a *Argument) GetValue() (interface{}, errors.GraphqlErrorInterface)
type BaseLocation ¶
func (*BaseLocation) GetLocation ¶
func (l *BaseLocation) GetLocation() *errors.GraphqlLocation
type BaseNode ¶
type BaseNode struct { Name string `json:"name"` Description *string `json:"description"` Fields map[string]*Field `json:"fields"` InputFields map[string]*Field `json:"inputFields"` Interfaces map[string]*InterfaceNode `json:"interfaces"` EnumValues map[string]*EnumValue `json:"enumValues"` PossibleTypes map[string]*ObjectNode `json:"possibleTypes"` Kind Kind `json:"kind"` Directives []*Directive `json:"-"` IsReserved bool `json:"-"` }
func (*BaseNode) GetDescription ¶
func (*BaseNode) GetDirectives ¶
func (*BaseNode) GetDirectivesByName ¶
func (*BaseNode) GetPossibleTypes ¶
func (n *BaseNode) GetPossibleTypes() map[string]*ObjectNode
type BooleanValue ¶
type BooleanValue struct{ Value bool }
func (*BooleanValue) IsValue ¶
func (v *BooleanValue) IsValue() bool
type Directive ¶
type Directive struct { BaseLocation Name string `json:"name"` Args map[string]*Argument `json:"args"` Definition *DirectiveDefinition `json:"-"` }
func GetDirective ¶
type DirectiveDefinition ¶
type DirectiveDefinition struct { BaseLocation Name string `json:"name"` Description *string `json:"description"` Args map[string]*Argument `json:"args"` Locations []Location `json:"locations"` Repeatable bool `json:"repeatable"` Directives []*Directive `json:"-"` }
func (*DirectiveDefinition) GetDescription ¶
func (d *DirectiveDefinition) GetDescription() string
func (*DirectiveDefinition) Validate ¶
func (d *DirectiveDefinition) Validate(store *NodeStore) errors.GraphqlErrorInterface
type EnumNode ¶
type EnumNode struct { BaseNode BaseLocation EnumValues map[string]*EnumValue `json:"enumValues"` }
type EnumValue ¶
type Field ¶
type Field struct { BaseLocation Alias string `json:"-"` Name string `json:"name"` Description *string `json:"description"` Args map[string]*Argument `json:"args"` Type *TypeRef `json:"type"` IsDeprecated bool `json:"isDeprecated"` DeprecationReason *string `json:"deprecationReason"` Children map[string]*Field `json:"-"` Directives []*Directive `json:"-"` IsFragment bool `json:"-"` IsUnion bool `json:"-"` Fragment *Fragment `json:"-"` DefinitionDirectives []*Directive `json:"-"` DefinitionArgs map[string]*Argument `json:"-"` Relation *Relation `json:"-"` }
func (*Field) ParseFieldDirectives ¶
func (f *Field) ParseFieldDirectives(store *NodeStore, parent Node) errors.GraphqlErrorInterface
type FloatValue ¶
type FloatValue struct{ Value float64 }
func (*FloatValue) IsValue ¶
func (v *FloatValue) IsValue() bool
type Fragment ¶
type Fragment struct { BaseLocation Name string `json:"name"` On string `json:"on"` Object *ObjectNode `json:"-"` Directives []*Directive `json:"-"` Fields map[string]*Field `json:"fields"` }
type InputObjectNode ¶
type InputObjectNode struct { BaseNode BaseLocation Fields map[string]*Field `json:"inputFields"` }
func (*InputObjectNode) GetFields ¶
func (i *InputObjectNode) GetFields() map[string]*Field
func (*InputObjectNode) Validate ¶
func (i *InputObjectNode) Validate(store *NodeStore) errors.GraphqlErrorInterface
type InterfaceNode ¶
type InterfaceNode struct { BaseNode BaseLocation Fields map[string]*Field `json:"fields"` }
func (*InterfaceNode) GetFields ¶
func (o *InterfaceNode) GetFields() map[string]*Field
func (*InterfaceNode) Validate ¶
func (o *InterfaceNode) Validate(store *NodeStore) errors.GraphqlErrorInterface
type Location ¶
type Location string
const ( LocationQuery Location = `QUERY` LocationMutation Location = `MUTATION` LocationSubscription Location = `SUBSCRIPTION` LocationField Location = `FIELD` LocationFragmentDefinition Location = `FRAGMENT_DEFINITION` LocationFragmentSpread Location = `FRAGMENT_SPREAD` LocationInlineFragment Location = `INLINE_FRAGMENT` LocationSchema Location = `SCHEMA` // deprecated LocationScalar Location = `SCALAR` LocationObject Location = `OBJECT` LocationFieldDefinition Location = `FIELD_DEFINITION` LocationArgumentDefinition Location = `ARGUMENT_DEFINITION` LocationInterface Location = `INTERFACE` LocationUnion Location = `UNION` LocationEnum Location = `ENUM` LocationEnumValue Location = `ENUM_VALUE` LocationInputObject Location = `INPUT_OBJECT` LocationInputFieldDefinition Location = `INPUT_FIELD_DEFINITION` LocationVariableDefinition Location = `VARIABLE_DEFINITION` )
type Locationable ¶
type Locationable interface {
GetLocation() errors.GraphqlLocation
}
type Node ¶
type Node interface { // GetName returns the name of the node. GetName() string // GetKind returns the kind of the node. GetKind() Kind // GetDescription returns the description of the node, if available. // It may return an empty string if no description is provided. GetDescription() string // GetDirectivesByName returns a slice of directives with the specified name. // It may return an empty slice if no directives are found. GetDirectivesByName(name string) []*Directive // Validate validates the node. Validate(store *NodeStore) errors.GraphqlErrorInterface // GetDirectives returns the directives of the node. GetDirectives() []*Directive GetFields() map[string]*Field GetPossibleTypes() map[string]*ObjectNode }
Node represents a GraphQL AST node.
type NodeStore ¶
type NodeStore struct { // Scalars is a map of all scalars Scalars map[string]*ScalarNode // Interfaces is a map of all interfaces Interfaces map[string]*InterfaceNode // Objects is a map of all objects Objects map[string]*ObjectNode // Unions is a map of all unions Unions map[string]*UnionNode // Enums is a map of all enums Enums map[string]*EnumNode // Inputs is a map of all inputs Inputs map[string]*InputObjectNode // Directives is a map of all directives Directives map[string]*DirectiveDefinition // ScalarTypes is a map of all scalar types ScalarTypes map[string]ScalarType // Names is a map of all names , it can be a type, enum, interface, input, scalar, union, directive, extend Names map[string]any // Nodes is a map of all nodes Nodes map[string]Node }
func (*NodeStore) AddDirective ¶
func (s *NodeStore) AddDirective(name string, node *DirectiveDefinition)
func (*NodeStore) AddInput ¶
func (s *NodeStore) AddInput(name string, node *InputObjectNode)
func (*NodeStore) AddInterface ¶
func (s *NodeStore) AddInterface(name string, node *InterfaceNode)
func (*NodeStore) AddObject ¶
func (s *NodeStore) AddObject(name string, node *ObjectNode)
func (*NodeStore) AddScalar ¶
func (s *NodeStore) AddScalar(name string, node *ScalarNode)
type ObjectNode ¶
type ObjectNode struct { BaseNode BaseLocation Fields map[string]*Field `json:"fields"` InterfaceNames []string `json:"-"` IsModel bool `json:"-"` Table string `json:"-"` }
func (*ObjectNode) GetFields ¶
func (o *ObjectNode) GetFields() map[string]*Field
func (*ObjectNode) ParseObjectDirectives ¶
func (o *ObjectNode) ParseObjectDirectives(store *NodeStore) errors.GraphqlErrorInterface
func (*ObjectNode) Validate ¶
func (o *ObjectNode) Validate(store *NodeStore) errors.GraphqlErrorInterface
type ObjectValue ¶
func (*ObjectValue) IsValue ¶
func (v *ObjectValue) IsValue() bool
type RelationType ¶
type RelationType string
const ( RelationTypeBelongsTo RelationType = "RelationTypeBelongsTo" RelationTypeHasMany RelationType = "RelationTypeHasMany" RelationTypeHasOne RelationType = "RelationTypeHasOne" RelationTypeMorphTo RelationType = "RelationTypeMorphTo" RelationTypeMorphMany RelationType = "RelationTypeMorphMany" RelationTypeBelongsToMany RelationType = "RelationTypeBelongsToMany" )
type ScalarNode ¶
type ScalarNode struct { BaseNode BaseLocation ScalarType ScalarType `json:"-"` }
func (*ScalarNode) Validate ¶
func (s *ScalarNode) Validate(store *NodeStore) errors.GraphqlErrorInterface
type ScalarType ¶
type ScalarType interface { ParseValue(v interface{}, location *errors.GraphqlLocation) (interface{}, errors.GraphqlErrorInterface) Serialize(v interface{}, location *errors.GraphqlLocation) (interface{}, errors.GraphqlErrorInterface) ParseLiteral(v interface{}, location *errors.GraphqlLocation) (interface{}, errors.GraphqlErrorInterface) GoType() string }
type StringValue ¶
type StringValue struct{ Value string }
func (*StringValue) IsValue ¶
func (v *StringValue) IsValue() bool
type TypeRef ¶
type TypeRef struct { BaseLocation Kind Kind `json:"kind"` Name string `json:"name"` OfType *TypeRef `json:"ofType"` TypeNode Node `json:"-"` }
func (*TypeRef) GetRealType ¶
func (*TypeRef) Validate ¶
func (t *TypeRef) Validate(store *NodeStore) errors.GraphqlErrorInterface
func (*TypeRef) ValidateValue ¶
func (t *TypeRef) ValidateValue(v interface{}, isVariable bool) errors.GraphqlErrorInterface
Click to show internal directories.
Click to hide internal directories.