Documentation ¶
Index ¶
Constants ¶
const ProtocolGraphQLWS = "graphql-ws"
ProtocolGraphQLWS is websocket subprotocol ID for GraphQL over WebSocket see https://github.com/apollographql/subscriptions-transport-ws
Variables ¶
This section is empty.
Functions ¶
func NewHandler ¶
func NewHandler() handler
NewHandler creates new GraphQL over websocket Handler with default websocket Upgrader.
func NewHandlerFunc ¶
func NewHandlerFunc(svc connection.GraphQLService, httpHandler http.Handler, options ...Option) http.HandlerFunc
NewHandlerFunc returns an http.HandlerFunc that supports GraphQL over websockets
Types ¶
type ContextGenerator ¶
type ContextGenerator interface {
BuildContext(context.Context, *http.Request) (context.Context, error)
}
A ContextGenerator handles any changes made to the the connection context prior to creating the websocket connection routine.
type ContextGeneratorFunc ¶
The ContextGeneratorFunc takes a context and the http request it can be used to take values out of the request context and assign them to a new context that will be supplied to the websocket connection go routine and be accessible in the resolver. The http request context should not be modified as any changes made will not be accessible in the resolver.
func (ContextGeneratorFunc) BuildContext ¶
func (f ContextGeneratorFunc) BuildContext(ctx context.Context, r *http.Request) (context.Context, error)
BuildContext calls f(ctx, r) and returns a context and error
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option applies configuration when a graphql websocket connection is handled
func WithContextGenerator ¶
func WithContextGenerator(f ContextGenerator) Option
WithContextGenerator specifies that the background context of the websocket connection go routine should be built upon by executing provided context generators
func WithReadLimit ¶ added in v0.0.2
WithReadLimit limits the maximum size of incoming messages
func WithWriteTimeout ¶ added in v0.0.2
WithWriteTimeout sets a timeout for outgoing messages