transportws

package
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package transportws implements the subscriptions-transport-ws protocol.

Index

Constants

View Source
const ProtocolName = "graphql-ws"

Variables

This section is empty.

Functions

This section is empty.

Types

type Protocol

type Protocol struct {
	// InitFunc is called after receiving the "connection_init" message with the
	// WebSocket handshake HTTP request and the message payload.
	//
	// The returned Context, if not nil, is provided to GraphQL resolvers. When
	// the Context is done, the connection is also closed.
	//
	// The returned ObjectPayload, if not nil, is used as the payload for the
	// "connection_ack" message.
	//
	// If a non-nil error is returned, the connection is closed.
	//
	// If InitFunc is nil, all connections are accepted.
	InitFunc func(*http.Request, wsutil.ObjectPayload) (context.Context, wsutil.ObjectPayload, error)

	// InitTimeout is the duration to wait for a "connection_init" message before
	// closing the connection.
	//
	// Defaults to 3 seconds.
	InitTimeout time.Duration

	// If KeepAliveInterval is set, a "ka" message is sent if no message is
	// received for the specified duration.
	KeepAliveInterval time.Duration

	// AcceptOptions defines options used during the WebSocket handshake.
	AcceptOptions websocket.AcceptOptions
}

Protocol implements the subscriptions-transport-ws protocol described here: https://github.com/apollographql/subscriptions-transport-ws.

Protocol can be used as a gqlgenws.Protocol or directly as a gqlgen transport.

func (*Protocol) Do

func (*Protocol) Name

func (*Protocol) Name() string

func (*Protocol) Run

func (p *Protocol) Run(r *http.Request, c *websocket.Conn, exec graphql.GraphExecutor)

func (*Protocol) Supports

func (*Protocol) Supports(r *http.Request) (res bool)

Jump to

Keyboard shortcuts

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