Documentation ¶
Index ¶
- Constants
- Variables
- func IsNestedPath(value string) bool
- func NewArgs(props *specs.ParameterMap) (graphql.FieldConfigArgument, error)
- func NewEmptyObject(objects *Objects, name string) *graphql.Object
- func NewInputArgObject(prop *specs.Property) (*graphql.InputObject, error)
- func NewListener(addr string, opts specs.Options) transport.NewListener
- func NewObject(name string, description string, template specs.Template) (*graphql.Object, error)
- func NewPath(parts []string) string
- func NewSchemaObject(objects *Objects, name string, object *transport.Object) (*graphql.Object, error)
- func NewType(name string, description string, property specs.Template) (graphql.Output, error)
- func ParsePath(path string) []string
- func ResponseObject(specs *specs.Property, store references.Store, tracker references.Tracker) (map[string]interface{}, error)
- func ResponseValue(tmpl specs.Template, store references.Store, tracker references.Tracker) (interface{}, error)
- func SetField(path string, fields graphql.Fields, field *graphql.Field) error
- func SetFieldPath(object *graphql.Object, path string, field *graphql.Field) error
- type EndpointOptions
- type ErrDuplicateObject
- type ErrFieldAlreadySet
- type ErrTypeMismatch
- type ErrUnexpectedType
- type ErrUnknownBase
- type Listener
- type Objects
Constants ¶
const ( // PathOption represents the object name option key PathOption = "path" // BaseOption represents the object base option key BaseOption = "base" // NameOption represents the object name option key NameOption = "name" )
Variables ¶
var ( QueryObject = "query" MutationObject = "mutation" )
Schema base
var ErrInvalidObject = errors.New("graphql only supports object types as root elements")
ErrInvalidObject is thrown when the given property is not of type message
Functions ¶
func IsNestedPath ¶
IsNestedPath checks whether the given value is a path
func NewArgs ¶
func NewArgs(props *specs.ParameterMap) (graphql.FieldConfigArgument, error)
NewArgs construct new field config arguments for the graphql schema
func NewEmptyObject ¶
NewEmptyObject constructs a new empty object with the given name and stores it inside the objects collection. The object is claimed inside the object properties as nil. If the name is already claimed is the configured graphql object returned.
func NewInputArgObject ¶
func NewInputArgObject(prop *specs.Property) (*graphql.InputObject, error)
NewInputArgObject constructs a new input argument object
func NewListener ¶
func NewListener(addr string, opts specs.Options) transport.NewListener
NewListener constructs a new listener for the given addr
func NewSchemaObject ¶
func NewSchemaObject(objects *Objects, name string, object *transport.Object) (*graphql.Object, error)
NewSchemaObject constructs a new object for the given property with the given name. If a object with the same name already exists is it used instead.
func ResponseObject ¶
func ResponseObject(specs *specs.Property, store references.Store, tracker references.Tracker) (map[string]interface{}, error)
ResponseObject constructs the response value send back to the client
func ResponseValue ¶
func ResponseValue(tmpl specs.Template, store references.Store, tracker references.Tracker) (interface{}, error)
ResponseValue constructs a new response used inside a response object
Types ¶
type EndpointOptions ¶
EndpointOptions represents the available HTTP options
func ParseEndpointOptions ¶
func ParseEndpointOptions(endpoint *transport.Endpoint) (EndpointOptions, error)
ParseEndpointOptions parses the given specs options into HTTP options
type ErrDuplicateObject ¶
type ErrDuplicateObject struct { Name string // contains filtered or unexported fields }
ErrDuplicateObject occurs when a duplicate object is provided
func (ErrDuplicateObject) Error ¶
func (e ErrDuplicateObject) Error() string
Error returns a description of the given error as a string
func (ErrDuplicateObject) Prettify ¶
func (e ErrDuplicateObject) Prettify() prettyerr.Error
Prettify returns the prettified version of the given error
type ErrFieldAlreadySet ¶
type ErrFieldAlreadySet struct { Field string Path string // contains filtered or unexported fields }
ErrFieldAlreadySet occurs when field has already being set
func (ErrFieldAlreadySet) Error ¶
func (e ErrFieldAlreadySet) Error() string
Error returns a description of the given error as a string
func (ErrFieldAlreadySet) Prettify ¶
func (e ErrFieldAlreadySet) Prettify() prettyerr.Error
Prettify returns the prettified version of the given error
type ErrTypeMismatch ¶
type ErrTypeMismatch struct { Expected string Type string // contains filtered or unexported fields }
ErrTypeMismatch occurs when there is a mismatch in schema definations
func (ErrTypeMismatch) Error ¶
func (e ErrTypeMismatch) Error() string
Error returns a description of the given error as a string
func (ErrTypeMismatch) Prettify ¶
func (e ErrTypeMismatch) Prettify() prettyerr.Error
Prettify returns the prettified version of the given error
type ErrUnexpectedType ¶
type ErrUnexpectedType struct { Type types.Type Expected types.Type // contains filtered or unexported fields }
ErrUnexpectedType occurs when a non-object is passed as property
func (ErrUnexpectedType) Error ¶
func (e ErrUnexpectedType) Error() string
Error returns a description of the given error as a string
func (ErrUnexpectedType) Prettify ¶
func (e ErrUnexpectedType) Prettify() prettyerr.Error
Prettify returns the prettified version of the given error
type ErrUnknownBase ¶
type ErrUnknownBase struct { Base string // contains filtered or unexported fields }
ErrUnknownBase occurs when an unknown base is provided
func (ErrUnknownBase) Error ¶
func (e ErrUnknownBase) Error() string
Error returns a description of the given error as a string
func (ErrUnknownBase) Prettify ¶
func (e ErrUnknownBase) Prettify() prettyerr.Error
Prettify returns the prettified version of the given error
type Listener ¶
type Listener struct {
// contains filtered or unexported fields
}
Listener represents a GraphQL listener
func (*Listener) Handle ¶
func (listener *Listener) Handle(ctx *broker.Context, endpoints []*transport.Endpoint, constructors map[string]codec.Constructor) error
Handle parses the given endpoints and constructs route handlers