server

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: MIT Imports: 15 Imported by: 0

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"

ConnKey the connection key

View Source
var GraphiqlVersion = "1.4.1"

GraphiqlVersion is the current version of GraphiQL

View Source
var PlaygroundVersion = "1.7.27"

PlaygroundVersion the default version to use

Functions

func IsWSUpgrade

func IsWSUpgrade(r *http.Request) bool

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 GraphiQLOptions

type GraphiQLOptions struct {
	Version              string
	SSL                  bool
	Endpoint             string
	SubscriptionEndpoint string
}

func NewDefaultGraphiQLOptions

func NewDefaultGraphiQLOptions() *GraphiQLOptions

func NewDefaultSSLGraphiQLOption added in v0.3.3

func NewDefaultSSLGraphiQLOption() *GraphiQLOptions

type Options

type Options struct {
	Pretty             bool
	RootValueFunc      RootValueFunc
	FormatErrorFunc    FormatErrorFunc
	ContextFunc        ContextFunc
	WSContextFunc      ContextFunc
	ResultCallbackFunc ResultCallbackFunc
	Logger             logger.Logger
	WS                 *WSOptions
	Playground         *PlaygroundOptions
	GraphiQL           *GraphiQLOptions
}

type PlaygroundOptions

type PlaygroundOptions struct {
	Version              string
	SSL                  bool
	Endpoint             string
	SubscriptionEndpoint string
}

func NewDefaultPlaygroundOptions

func NewDefaultPlaygroundOptions() *PlaygroundOptions

func NewDefaultSSLPlaygroundOptions added in v0.3.3

func NewDefaultSSLPlaygroundOptions() *PlaygroundOptions

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, options *Options) *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)

type WSOptions

type WSOptions struct {
	AuthenticateFunc graphqlws.AuthenticateFunc
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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