gql

package module
v0.0.0-...-4ebdfc9 Latest Latest
Warning

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

Go to latest
Published: Mar 30, 2017 License: MIT Imports: 3 Imported by: 0

README

gql: GraphQL For Go

Build Status Coverage Status

Experimental

A Ragel + Yacc toolkit for GraphQL support in Go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BuiltinDefinitions

func BuiltinDefinitions() map[string]TypeDefinition

func IsRequired

func IsRequired(input TypeFlags) bool

func ValueAsInt

func ValueAsInt(input reflect.Value) (int, error)

func ValueAsString

func ValueAsString(input reflect.Value) (string, error)

Types

type Argument

type Argument struct {
	Name  string
	Value reflect.Value
}

type Definition

type Definition struct {
	Operation Operation
	Fragment  Fragment
}

type Directive

type Directive struct {
	Name      string
	Arguments map[string]Argument
}

type DirectiveLocation

type DirectiveLocation int
const (
	DirectiveLocation_QUERY DirectiveLocation = iota
	DirectiveLocation_MUTATION
	DirectiveLocation_FIELD
	DirectiveLocation_FRAGMENT_DEFINITION
	DirectiveLocation_FRAGMENT_SPREAD
	DirectiveLocation_INLINE_FRAGMENT
	DirectiveLocation_SCHEMA
	DirectiveLocation_SCALAR
	DirectiveLocation_OBJECT
	DirectiveLocation_FIELD_DEFINITION
	DirectiveLocation_ARGUMENT_DEFINITION
	DirectiveLocation_INTERFACE
	DirectiveLocation_UNION
	DirectiveLocation_ENUM
	DirectiveLocation_ENUM_VALUE
	DirectiveLocation_INPUT_OBJECT
	DirectiveLocation_INPUT_FIELD_DEFINITION
)

type EnumDefinition

type EnumDefinition struct {
	Name       string
	Values     []string
	Directives []Directive
}

func (EnumDefinition) TypeKind

func (e EnumDefinition) TypeKind() TypeKind

func (EnumDefinition) TypeName

func (e EnumDefinition) TypeName() string

func (EnumDefinition) ValueFromName

func (e EnumDefinition) ValueFromName(input string) interface{}

type Field

type Field struct {
	Name         string
	Arguments    map[string]Argument
	SelectionSet []Selection
	Directives   []Directive
	Alias        string
	Ix           int
}

func (Field) StringValue

func (f Field) StringValue(arg, defaultValue string, required bool) (string, error)

type FieldDefinition

type FieldDefinition struct {
	Name       string
	Arguments  map[string]InputValueDefinition
	Type       TypeDescription
	Directives []Directive
}

type Fragment

type Fragment struct {
	Name          string
	TypeCondition string
	Directives    []Directive
	SelectionSet  []Selection
}

type FragmentSpread

type FragmentSpread struct {
	Name       string
	Directives []Directive
}

type HandlerFunc

type HandlerFunc func(context.Context, Selection) (Selectable, error)

type InputObjectDefinition

type InputObjectDefinition struct {
	Name       string
	InputDefs  map[string]InputValueDefinition
	Directives []Directive
}

func (InputObjectDefinition) TypeKind

func (i InputObjectDefinition) TypeKind() TypeKind

func (InputObjectDefinition) TypeName

func (i InputObjectDefinition) TypeName() string

func (InputObjectDefinition) ValueFromName

func (i InputObjectDefinition) ValueFromName(input string) interface{}

type InputValueDefinition

type InputValueDefinition struct {
	Name       string
	Type       TypeDescription
	Default    reflect.Value
	Directives []Directive
}

func (InputValueDefinition) TypeName

func (i InputValueDefinition) TypeName() string

func (InputValueDefinition) ValueFromName

func (i InputValueDefinition) ValueFromName(input string) interface{}

type InterfaceDefinition

type InterfaceDefinition struct {
	Name string

	Fields     []FieldDefinition
	Directives []Directive
}

func (InterfaceDefinition) TypeKind

func (i InterfaceDefinition) TypeKind() TypeKind

func (InterfaceDefinition) TypeName

func (i InterfaceDefinition) TypeName() string

func (InterfaceDefinition) ValueFromName

func (i InterfaceDefinition) ValueFromName(input string) interface{}

type ObjectDefinition

type ObjectDefinition struct {
	Name        string
	Implements  []string
	Fields      []FieldDefinition
	Directives  []Directive
	IsOperation bool
}

func (ObjectDefinition) AsType

func (o ObjectDefinition) AsType(isRequired, isList bool) Type

func (ObjectDefinition) TypeKind

func (o ObjectDefinition) TypeKind() TypeKind

func (ObjectDefinition) TypeName

func (o ObjectDefinition) TypeName() string

func (ObjectDefinition) ValueFromName

func (o ObjectDefinition) ValueFromName(input string) interface{}

type ObjectField

type ObjectField struct {
	Key   string
	Value reflect.Value
}

type OpType

type OpType int
const (
	Query OpType = iota
	Mutation
	Subscription
)

type Operation

type Operation struct {
	OpType       OpType
	Name         string
	SelectionSet []Selection
	Variables    []Variable
	Directives   []Directive
}

type OperationTypeDefinition

type OperationTypeDefinition struct {
	OpType OpType
	Name   string
}

type ScalarDefinition

type ScalarDefinition struct {
	Name       string
	Directives []Directive
}

func (ScalarDefinition) TypeKind

func (s ScalarDefinition) TypeKind() TypeKind

func (ScalarDefinition) TypeName

func (s ScalarDefinition) TypeName() string

func (ScalarDefinition) ValueFromName

func (s ScalarDefinition) ValueFromName(input string) interface{}

type Schema

type Schema struct {
	Types        map[string]TypeDefinition // [__Type!]!
	QueryType    ObjectDefinition          // __Type!
	MutationType ObjectDefinition          // __Type
	Directives   map[string]Directive      //[__Directive!]!
}

func (Schema) ValueFromName

func (s Schema) ValueFromName(field string) interface{}

type Selectable

type Selectable interface {
	ValueFromName(string) interface{}
}

type Selection

type Selection struct {
	Field          Field
	FragmentSpread FragmentSpread
	InlineFragment Fragment
}

type Service

type Service interface {
	Handlers() map[string]HandlerFunc
	Schema() Schema
}

type Type

type Type struct {
	Kind          TypeKind
	Name          string
	Description   string
	Fields        []FieldDefinition
	Interfaces    []Type
	PossibleTypes []Type
	EnumValues    EnumDefinition
	InputFields   []InputValueDefinition
	OfType        *Type
}

func (Type) EnumValuesF

func (t Type) EnumValuesF(includeDeprecated bool) Selectable

func (Type) FieldsF

func (t Type) FieldsF(includeDeprecated bool) Selectable

func (Type) ValueFromName

func (t Type) ValueFromName(input string) interface{}

type TypeDefinition

type TypeDefinition interface {
	Selectable
	TypeName() string
	TypeKind() TypeKind
}

type TypeDescription

type TypeDescription struct {
	Name  string
	Flags TypeFlags
}

type TypeFlags

type TypeFlags byte
const (
	List TypeFlags = 1 << iota
	Required
)

type TypeKind

type TypeKind int
const (
	TypeKind_SCALAR TypeKind = iota
	TypeKind_OBJECT
	TypeKind_INTERFACE
	TypeKind_UNION
	TypeKind_ENUM
	TypeKind_INPUT_OBJECT
	TypeKind_LIST
	TypeKind_NON_NULL
)

type UnionDefinition

type UnionDefinition struct {
	Name       string
	Types      []string
	Directives []Directive
}

func (UnionDefinition) TypeKind

func (u UnionDefinition) TypeKind() TypeKind

func (UnionDefinition) TypeName

func (u UnionDefinition) TypeName() string

func (UnionDefinition) ValueFromName

func (u UnionDefinition) ValueFromName(input string) interface{}

type Variable

type Variable struct {
	Name    string
	Type    TypeDescription
	Default reflect.Value
}

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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