Documentation ¶
Index ¶
- func Implements(interfaceValue interface{}, typeValue interface{}) bool
- func TypeRename(goType interface{}, newName string, force ...bool) string
- type AttrIsID
- type Ctx
- func (ctx *Ctx) GetContext() context.Context
- func (ctx *Ctx) GetPath() json.RawMessage
- func (ctx *Ctx) GetValue(key string) (value interface{})
- func (ctx *Ctx) GetValueOk(key string) (value interface{}, found bool)
- func (ctx *Ctx) SetContext(newContext context.Context)
- func (ctx *Ctx) SetValue(key string, value interface{})
- type Directive
- type DirectiveLocation
- type DirectiveModifier
- type ErrorWPath
- type RequestOptions
- type ResolveOptions
- type Schema
- func (s *Schema) Copy() *Schema
- func (s *Schema) HandleRequest(method string, getQuery func(key string) string, ...) ([]byte, []error)
- func (s *Schema) Parse(queries interface{}, methods interface{}, options *SchemaOptions) error
- func (s *Schema) RegisterDirective(directive Directive) error
- func (s *Schema) RegisterEnum(enumMap interface{}) (added bool, err error)
- func (s *Schema) Resolve(query []byte, opts ResolveOptions) []error
- func (s *Schema) SetCacheRules(cacheQueryFromLen *int)
- type SchemaOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Implements ¶
func Implements(interfaceValue interface{}, typeValue interface{}) bool
Implements registers a new type that implementation an interface The interfaceValue should be a pointer to the interface type like: (*InterfaceType)(nil) The typeValue should be a empty struct that implements the interfaceValue
Example:
var _ = Implements((*InterfaceType)(nil), StructThatImplements{})
func TypeRename ¶
TypeRename renames the graphql type of the input type By default the typename of the struct is used but you might want to change this form time to time and with this you can
Types ¶
type AttrIsID ¶
type AttrIsID uint8
AttrIsID can be added to a method response to make it a ID field For example:
func (Foo) ResolveExampleMethod() (string, AttrIsID) { return "i'm an ID type now", 0 }
Not that the response value doesn't matter
type Ctx ¶
type Ctx struct {
// contains filtered or unexported fields
}
Ctx contains all runtime information of a query
func (*Ctx) GetContext ¶ added in v0.9.0
GetContext returns the Go request context
func (*Ctx) GetPath ¶
func (ctx *Ctx) GetPath() json.RawMessage
GetPath returns the graphql path to the current field json encoded
func (*Ctx) GetValueOk ¶
GetValueOk returns a user defined value with a boolean indicating if the value was found
func (*Ctx) SetContext ¶ added in v0.9.0
SetContext overwrites the request's Go context
type Directive ¶
type Directive struct { // Required Name string Where []DirectiveLocation // Should be of type: func(args like any other method) DirectiveModifier Method interface{} // Not required Description string // contains filtered or unexported fields }
Directive is what defines a directive
type DirectiveLocation ¶
type DirectiveLocation uint8
DirectiveLocation defines the location a directive can be used in
const ( // DirectiveLocationField can be called from a field DirectiveLocationField DirectiveLocation = iota // DirectiveLocationFragment can be called from a fragment DirectiveLocationFragment // DirectiveLocationFragmentInline can be called from a inline fragment DirectiveLocationFragmentInline )
func (DirectiveLocation) String ¶
func (l DirectiveLocation) String() string
String returns the DirectiveLocation as a string
func (DirectiveLocation) ToQlDirectiveLocation ¶
func (l DirectiveLocation) ToQlDirectiveLocation() __DirectiveLocation
ToQlDirectiveLocation returns the matching graphql location
type DirectiveModifier ¶
type DirectiveModifier struct { // Skip field/(inline)fragment Skip bool }
DirectiveModifier defines modifications to the response Nothing is this struct is required and will be ignored if not set
type ErrorWPath ¶
type ErrorWPath struct {
// contains filtered or unexported fields
}
ErrorWPath is an error mesage with a graphql path to the field that created the error
func (ErrorWPath) Error ¶
func (e ErrorWPath) Error() string
type RequestOptions ¶
type RequestOptions struct { Context context.Context // Request context can be used to verify Values map[string]interface{} // Passed directly to the request context GetFormFile func(key string) (*multipart.FileHeader, error) // Get form file to support file uploading Tracing bool // https://github.com/apollographql/apollo-tracing }
RequestOptions are extra options / arguments for the (*Schema).HandleRequest method
type ResolveOptions ¶
type ResolveOptions struct { NoMeta bool // Returns only the data Context context.Context // Request context OperatorTarget string Values *map[string]interface{} // Passed directly to the request context GetFormFile func(key string) (*multipart.FileHeader, error) // Get form file to support file uploading Variables string // Expects valid JSON or empty string Tracing bool // https://github.com/apollographql/apollo-tracing }
ResolveOptions are options for the (*Schema).Resolve method
type Schema ¶
type Schema struct { MaxDepth uint8 // Default 255 // Zero alloc variables Result []byte // contains filtered or unexported fields }
Schema defines the graphql schema
func NewSchema ¶
func NewSchema() *Schema
NewSchema creates a new schema wherevia you can define the graphql types and make queries
func (*Schema) Copy ¶
Copy is meant to be used to create a pool of schema objects The function itself is quiet slow so don't use this function in every request
func (*Schema) HandleRequest ¶
func (s *Schema) HandleRequest( method string, getQuery func(key string) string, getFormField func(key string) (string, error), getBody func() []byte, contentType string, options *RequestOptions, ) ([]byte, []error)
HandleRequest handles a http request and returns a response
func (*Schema) Parse ¶
func (s *Schema) Parse(queries interface{}, methods interface{}, options *SchemaOptions) error
Parse parses your queries and methods
func (*Schema) RegisterDirective ¶
RegisterDirective registers a new directive
func (*Schema) RegisterEnum ¶
RegisterEnum registers a new enum type
func (*Schema) Resolve ¶
func (s *Schema) Resolve(query []byte, opts ResolveOptions) []error
Resolve resolves a query and returns errors if any The result json is written to (*Schema).Result
func (*Schema) SetCacheRules ¶
SetCacheRules sets the cacheing rules
type SchemaOptions ¶
type SchemaOptions struct { SkipGraphqlTypesInjection bool // contains filtered or unexported fields }
SchemaOptions are options for creating a new schema