server

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2022 License: MIT Imports: 16 Imported by: 0

README

graphql-go-server

Server implementation for graphql-go

Documentation

Index

Constants

View Source
const (
	ContentTypeJSON           = "application/json"
	ContentTypeGraphQL        = "application/graphql"
	ContentTypeFormURLEncoded = "application/x-www-form-urlencoded"
)

Constants

Variables

View Source
var (
	ConnKey interface{} = "conn"
)

Functions

This section is empty.

Types

type ChanMgr

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

func (*ChanMgr) Add

func (c *ChanMgr) Add(rc *ResultChan)

func (*ChanMgr) Del

func (c *ChanMgr) Del(cid, oid string) bool

func (*ChanMgr) DelConn

func (c *ChanMgr) DelConn(cid string) bool

type ContextFunc

type ContextFunc func(r *http.Request) context.Context

type FormatErrorFunc

type FormatErrorFunc func(err error) gqlerrors.FormattedError

type Option

type Option func(opts *serverOptions)

func WithContextFunc

func WithContextFunc(f ContextFunc) Option

func WithFormatErrorFunc

func WithFormatErrorFunc(f FormatErrorFunc) Option

func WithGraphiQLOptions

func WithGraphiQLOptions(o *ide.GraphiQLOptions) Option

func WithLogger

func WithLogger(l logger.Logger) Option

func WithPlaygroundOptions

func WithPlaygroundOptions(o *ide.PlaygroundOptions) Option

func WithPretty

func WithPretty() Option

func WithResultCallbackFunc

func WithResultCallbackFunc(f ResultCallbackFunc) Option

func WithRootValueFunc

func WithRootValueFunc(f RootValueFunc) Option

func WithWebsocketContextFunc

func WithWebsocketContextFunc(f ContextFunc) Option

type RequestOptions

type RequestOptions struct {
	Query         string                 `json:"query" url:"query" schema:"query"`
	Variables     map[string]interface{} `json:"variables" url:"variables" schema:"variables"`
	OperationName string                 `json:"operationName" url:"operationName" schema:"operationName"`
}

RequestOptions options

func GetRequestOptions

func GetRequestOptions(r *http.Request) *RequestOptions

GetRequestOptions Parses a http.Request into GraphQL request options struct without clearning the body

func NewRequestOptions

func NewRequestOptions(r *http.Request) *RequestOptions

NewRequestOptions Parses a http.Request into GraphQL request options struct

type ResultCallbackFunc

type ResultCallbackFunc func(ctx context.Context, params *graphql.Params, result *graphql.Result, responseBody []byte)

type ResultChan

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

type RootValueFunc

type RootValueFunc func(ctx context.Context, r *http.Request) map[string]interface{}

type Server

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

func New

func New(schema graphql.Schema, opts ...Option) *Server

func (*Server) ContextHandler

func (s *Server) ContextHandler(ctx context.Context, w http.ResponseWriter, r *http.Request)

ContextHandler provides an entrypoint into executing graphQL queries with a user-provided context.

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP provides an entrypoint into executing graphQL queries.

func (*Server) WSHandler

func (s *Server) WSHandler(ctx context.Context, w http.ResponseWriter, r *http.Request)

WSHandler handles websocket connection upgrade

type WSOptions

type WSOptions struct {
	AuthenticateFunc connection.AuthenticateFunc
}

Directories

Path Synopsis
example
server command
ws

Jump to

Keyboard shortcuts

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