Documentation ¶
Index ¶
- Variables
- func NewConnection(ctx context.Context, config Config) (*wsConnection, error)
- type CloseCode
- type CompleteMessage
- type Config
- type ErrorMessage
- type NextMessage
- type RawMessage
- func (m RawMessage) HasPayload() bool
- func (m RawMessage) ID() (string, error)
- func (m RawMessage) Payload() interface{}
- func (m RawMessage) RecordPayload() (map[string]interface{}, error)
- func (m RawMessage) SubscribePayload() (*SubscribePayload, error)
- func (m RawMessage) Type() (protocol.MessageType, error)
- type SubscribeMessage
- type SubscribePayload
Constants ¶
This section is empty.
Variables ¶
View Source
var (
CloseDeadlineDuration time.Duration = 100 * time.Millisecond
)
Functions ¶
Types ¶
type CloseCode ¶
type CloseCode int
CloseCode a closing code
const ( // Subprotocol - https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md // this is the successor protocol to graphql-ws which is confusing because the // library for the spec is graphql-ws Subprotocol = "graphql-transport-ws" // Close codes Noop CloseCode = -1 NormalClosure CloseCode = 1000 InternalServerError CloseCode = 4500 InternalClientError CloseCode = 4005 BadRequest CloseCode = 4400 BadResponse CloseCode = 4004 Forbidden CloseCode = 4403 SubprotocolNotAcceptable CloseCode = 4406 ConnectionInitialisationTimeout CloseCode = 4408 ConnectionAcknowledgementTimeout CloseCode = 4504 SubscriberAlreadyExists CloseCode = 4409 TooManyInitialisationRequests CloseCode = 4429 // Thresholds WriteTimeout = 10 * time.Second )
type CompleteMessage ¶
type CompleteMessage struct { ID string `json:"id"` Type protocol.MessageType `json:"type"` }
type Config ¶
type Config struct { WS *websocket.Conn Schema *graphql.Schema Logger *logger.LogWrapper Request *http.Request ConnectionInitWaitTimeout time.Duration RootValueFunc func(ctx context.Context, r *http.Request, op *ast.OperationDefinition) map[string]interface{} ContextValueFunc func(c protocol.Context, msg protocol.OperationMessage, execArgs graphql.Params) (context.Context, gqlerrors.FormattedErrors) OnConnect func(c protocol.Context) (interface{}, error) OnPing func(c protocol.Context, payload map[string]interface{}) OnPong func(c protocol.Context, payload map[string]interface{}) OnDisconnect func(c protocol.Context, code CloseCode, reason string) OnClose func(c protocol.Context, code CloseCode, reason string) OnSubscribe func(c protocol.Context, msg SubscribeMessage) (*graphql.Params, gqlerrors.FormattedErrors) OnNext func(c protocol.Context, msg NextMessage, args graphql.Params, Result *graphql.Result) (*protocol.ExecutionResult, error) OnError func(c protocol.Context, msg ErrorMessage, errs gqlerrors.FormattedErrors) (gqlerrors.FormattedErrors, error) OnComplete func(c protocol.Context, msg CompleteMessage) error OnOperation func(c protocol.Context, msg SubscribeMessage, args graphql.Params, result interface{}) (interface{}, error) }
ConnectionConfig defines the configuration parameters of a GraphQL WebSocket connection.
type ErrorMessage ¶
type ErrorMessage struct { ID string `json:"id"` Type protocol.MessageType `json:"type"` Payload gqlerrors.FormattedErrors `json:"payload"` }
ErrorMessage
type NextMessage ¶
type NextMessage struct { ID string `json:"id"` Type protocol.MessageType `json:"type"` Payload protocol.ExecutionResult `json:"payload"` }
type RawMessage ¶
type RawMessage map[string]interface{}
RawMessage is the raw message data
func (RawMessage) HasPayload ¶
func (m RawMessage) HasPayload() bool
HasPayload returns true if the payload field exists and is not null
func (RawMessage) ID ¶
func (m RawMessage) ID() (string, error)
ID validates and extracts the id field value from a raw message
func (RawMessage) Payload ¶
func (m RawMessage) Payload() interface{}
Payload returns the raw payload
func (RawMessage) RecordPayload ¶
func (m RawMessage) RecordPayload() (map[string]interface{}, error)
PayloadRecord converts the payload to a record
func (RawMessage) SubscribePayload ¶
func (m RawMessage) SubscribePayload() (*SubscribePayload, error)
SubscribePayload converts the payload to a subscribe payload
func (RawMessage) Type ¶
func (m RawMessage) Type() (protocol.MessageType, error)
Type validates and extracts the type field value from a raw message
type SubscribeMessage ¶
type SubscribeMessage struct { ID string `json:"id"` Type protocol.MessageType `json:"type"` Payload SubscribePayload `json:"payload"` }
Click to show internal directories.
Click to hide internal directories.