graphqlws

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	CloseDeadlineDuration time.Duration = 100 * time.Millisecond
)

Functions

func NewConnection

func NewConnection(ctx context.Context, config Config) (*wsConnection, error)

NewConnection establishes a GraphQL WebSocket connection. It implements the GraphQL WebSocket protocol by managing its internal state and handling the client-server communication.

Types

type CloseCode added in v0.2.0

type CloseCode int
const (
	// Subprotocol - https://github.com/apollographql/subscriptions-transport-ws/blob/master/PROTOCOL.md
	Subprotocol = "graphql-ws"

	// CloseCodes
	NormalClosure       CloseCode = 1000
	ProtocolError       CloseCode = 1002
	UnexpectedCondition CloseCode = 1011

	// Thresholds
	WriteTimeout = 10 * time.Second
)

type Config added in v0.2.0

type Config struct {
	WS                  *websocket.Conn
	Schema              *graphql.Schema
	Logger              *logger.LogWrapper
	Request             *http.Request
	KeepAlive           time.Duration
	Roots               *options.Roots
	ContextValueFunc    func(c protocols.Context, msg protocols.OperationMessage, execArgs graphql.Params) (context.Context, gqlerrors.FormattedErrors)
	OnConnect           func(c protocols.Context, payload interface{}) interface{}
	OnDisconnect        func(c protocols.Context)
	OnOperation         func(c protocols.Context, msg StartMessage, params *graphql.Params) (*graphql.Params, error)
	OnOperationComplete func(c protocols.Context, id string)
}

ConnectionConfig defines the configuration parameters of a GraphQL WebSocket connection.

type ExecutionResult added in v0.2.0

type ExecutionResult struct {
	Errors     gqlerrors.FormattedErrors `json:"errors,omitempty"`
	Data       interface{}               `json:"data,omitempty"`
	Extensions map[string]interface{}    `json:"extensions,omitempty"`
}

ExecutionResult result of an execution

type StartMessage added in v0.2.0

type StartMessage struct {
	ID      string                `json:"id,omitempty"`
	Type    protocols.MessageType `json:"type"`
	Payload StartMessagePayload   `json:"payload,omitempty"`
}

type StartMessagePayload

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

StartMessagePayload defines the parameters of an operation that a client requests to be started.

func (*StartMessagePayload) Validate added in v0.2.0

func (s *StartMessagePayload) Validate() error

Jump to

Keyboard shortcuts

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