graphqlws

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2022 License: BSD-2-Clause Imports: 6 Imported by: 23

Documentation

Index

Constants

View Source
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

type ContextGeneratorFunc func(context.Context, *http.Request) (context.Context, error)

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

func WithReadLimit(limit int64) Option

WithReadLimit limits the maximum size of incoming messages

func WithWriteTimeout added in v0.0.2

func WithWriteTimeout(d time.Duration) Option

WithWriteTimeout sets a timeout for outgoing messages

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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