Documentation ¶
Index ¶
- Variables
- func GraphiQLHandler(url ...string) http.HandlerFunc
- func HTTPHandler(schema *internal.Schema) http.Handler
- func HTTPSubHandler(schema *internal.Schema, s *pubsub.Subscription) (http.Handler, func())
- func MaxDepth(n int)
- func SetLogger(logger *log.Logger)
- func Use(mm ...HandlerFunc)
- func UseStringDescriptions()
- type Context
- func (c *Context) ClientIP() string
- func (c *Context) Deadline() (deadline time.Time, ok bool)
- func (c *Context) Done() <-chan struct{}
- func (c *Context) Err() error
- func (ctx *Context) Next()
- func (c *Context) ServerError(msg string, code int)
- func (c *Context) Set(key, value interface{})
- func (c *Context) Value(key interface{}) interface{}
- type Handler
- type HandlerFunc
- type MiddlewareFunc
- type Resp
- type Response
Constants ¶
This section is empty.
Variables ¶
var Ctx = &Context{ Request: nil, Writer: nil, keys: nil, MaxDepth: 50, Logger: log.New(os.Stderr, "", 0), useStringDescriptions: false, HandlersChain: []HandlerFunc{}, Error: nil, index: -1, }
var URL = "query"
Functions ¶
func GraphiQLHandler ¶
func GraphiQLHandler(url ...string) http.HandlerFunc
func HTTPHandler ¶
HTTPHandler implements the handler required for executing the graphql queries and mutations
func HTTPSubHandler ¶
HTTPSubHandler implements the handler required for executing the graphql subscriptions
func MaxDepth ¶
func MaxDepth(n int)
MaxDepth specifies the maximum field nesting depth in a query. The default is 0 which disables max depth checking.
func SetLogger ¶
Logger is used to log panics during query execution. It defaults to exec.DefaultLogger.
func Use ¶
func Use(mm ...HandlerFunc)
func UseStringDescriptions ¶
func UseStringDescriptions()
UseStringDescriptions enables the usage of double quoted and triple quoted strings as descriptions as per the June 2018 spec https://facebook.github.io/graphql/June2018/. When this is not enabled, comments are parsed as descriptions instead.
Types ¶
type Context ¶
type Context struct { Request *http.Request Writer *Resp MaxDepth int Logger *log.Logger HandlersChain []HandlerFunc Error errors.MultiError OperationName string Method ast.OperationType // contains filtered or unexported fields }
func GetContext ¶
func (*Context) ClientIP ¶
ClientIP implements a best effort algorithm to return the real client IP, it parses X-Real-IP and X-Forwarded-For in order to work properly with reverse-proxies such us: nginx or haproxy. Use X-Forwarded-For before X-Real-Ip as nginx uses X-Real-Ip with the proxy's IP.
func (*Context) ServerError ¶
type Handler ¶
type HandlerFunc ¶
type HandlerFunc func(*Context)
type MiddlewareFunc ¶
type MiddlewareFunc func() HandlerFunc
type Resp ¶
type Resp struct { http.ResponseWriter // contains filtered or unexported fields }
func (*Resp) WriteHeader ¶
type Response ¶
type Response struct { Errors []*errors.GraphQLError `json:"errors,omitempty"` Data interface{} `json:"data,omitempty"` Extensions map[string]interface{} `json:"extensions,omitempty"` }
Resp represents a typical response of a GraphQL server. It may be encoded to JSON directly or it may be further processed to a custom response type, for example to include custom error data. Errors are intentionally serialized first based on the advice in https://github.com/facebook/graphql/commit/7b40390d48680b15cb93e02d46ac5eb249689876#diff-757cea6edf0288677a9eea4cfc801d87R107