middleware

package
v1.4.0 Latest Latest
Warning

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

Go to latest
Published: Mar 24, 2019 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InvokeMiddleware

func InvokeMiddleware(middleware GraphqlMiddleware, userValues map[string][]byte, schema, request string) (result string, err error)

InvokeMiddleware is a one off middleware invocation helper This should only be used for testing as it's a waste of resources It makes use of panics to don't use this in production!

Types

type ContextMiddleware

type ContextMiddleware struct {
}

ContextMiddleware does rewrite graphql requests based on schema annotations using a provided context object as input

example schema:

type Query {
	documents: [Document] @addArgumentFromContext(name: "user",contextKey: "user")
}

given there's an object with key "user" and value "jsmith@example.org" in the context

original Request:

query myDocuments {
	documents {
		sensitiveInformation
	}
}

Request after rewriting:

query myDocuments {
	documents(user: "jsmith@example.org") {
		sensitiveInformation
	}
}

func (*ContextMiddleware) OnRequest

func (a *ContextMiddleware) OnRequest(userValues map[string][]byte, l *lookup.Lookup, w *lookup.Walker, parser *parser.Parser, mod *parser.ManualAstMod) error

func (*ContextMiddleware) OnResponse

func (a *ContextMiddleware) OnResponse(userValues map[string][]byte, response *[]byte, l *lookup.Lookup, w *lookup.Walker, parser *parser.Parser, mod *parser.ManualAstMod) error

type ContextRewriteConfig

type ContextRewriteConfig struct {
	// contains filtered or unexported fields
}

type GraphqlMiddleware

type GraphqlMiddleware interface {
	OnRequest(userValues map[string][]byte, l *lookup.Lookup, w *lookup.Walker, parser *parser.Parser, mod *parser.ManualAstMod) error
	OnResponse(userValues map[string][]byte, response *[]byte, l *lookup.Lookup, w *lookup.Walker, parser *parser.Parser, mod *parser.ManualAstMod) error
}

type Invoker

type Invoker struct {
	// contains filtered or unexported fields
}

func NewInvoker

func NewInvoker(middleWares ...GraphqlMiddleware) *Invoker

func (*Invoker) InvokeMiddleWares

func (i *Invoker) InvokeMiddleWares(userValues map[string][]byte, request []byte) (err error)

func (*Invoker) RewriteRequest

func (i *Invoker) RewriteRequest(w io.Writer) error

func (*Invoker) SetSchema

func (i *Invoker) SetSchema(schema []byte) error

type InvokerPool added in v1.4.0

type InvokerPool struct {
	// contains filtered or unexported fields
}

func NewInvokerPool added in v1.4.0

func NewInvokerPool(size int, middleWares ...GraphqlMiddleware) *InvokerPool

func (*InvokerPool) Free added in v1.4.0

func (i *InvokerPool) Free(index int)

func (*InvokerPool) Get added in v1.4.0

func (i *InvokerPool) Get() (index int, invoker *Invoker)

type ValidationMiddleware added in v1.4.0

type ValidationMiddleware struct {
}

ValidationMiddleware is a middleware which validates the input Query against the Schema definition

func (*ValidationMiddleware) OnRequest added in v1.4.0

func (v *ValidationMiddleware) OnRequest(userValues map[string][]byte, l *lookup.Lookup, w *lookup.Walker, parser *parser.Parser, mod *parser.ManualAstMod) error

func (*ValidationMiddleware) OnResponse added in v1.4.0

func (v *ValidationMiddleware) OnResponse(userValues map[string][]byte, response *[]byte, l *lookup.Lookup, w *lookup.Walker, parser *parser.Parser, mod *parser.ManualAstMod) error

Jump to

Keyboard shortcuts

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