Documentation
¶
Index ¶
Constants ¶
const ( // Client -> Server MessageTypeConnectionInit = "connection_init" MessageTypeSubscribe = "subscribe" MessageTypeComplete = "complete" MessageTypePing = "ping" // Server -> Client MessageTypeConnectionAck = "connection_ack" MessageTypeNext = "next" MessageTypeError = "error" // MessageTypeComplete is used bidirectionally (already defined above) MessageTypePong = "pong" )
graphql-ws protocol message types https://github.com/enisdenjo/graphql-ws/blob/master/PROTOCOL.md
Variables ¶
This section is empty.
Functions ¶
func Handler ¶
func Handler(schema SchemaExecutor) http.HandlerFunc
Handler creates a WebSocket handler for GraphQL subscriptions
Types ¶
type ErrorPayload ¶
type ErrorPayload struct {
Message string `json:"message"`
}
ErrorPayload is the payload for an error message
type GraphQLError ¶
type GraphQLError struct {
Message string `json:"message"`
Path []interface{} `json:"path,omitempty"`
}
GraphQLError represents a GraphQL error
type Message ¶
type Message struct {
ID string `json:"id,omitempty"`
Type string `json:"type"`
Payload json.RawMessage `json:"payload,omitempty"`
}
Message represents a graphql-ws protocol message
func CompleteMessage ¶
CompleteMessage creates a complete message
func ConnectionAckMessage ¶
func ConnectionAckMessage() Message
ConnectionAckMessage creates a connection_ack message
func ConnectionInitMessage ¶
func ConnectionInitMessage() Message
ConnectionInitMessage creates a connection_init message
func ErrorMessage ¶
ErrorMessage creates an error message
func NextMessage ¶
func NextMessage(id string, data interface{}, errors []GraphQLError) (Message, error)
NextMessage creates a next message with data
type NextPayload ¶
type NextPayload struct {
Data interface{} `json:"data,omitempty"`
Errors []GraphQLError `json:"errors,omitempty"`
}
NextPayload is the payload for a next message (subscription data)
type SchemaExecutor ¶
type SchemaExecutor interface {
ExecuteSubscription(ctx context.Context, query string, variables map[string]interface{}, operationName string) (<-chan interface{}, error)
}
SchemaExecutor defines the interface for executing GraphQL subscriptions This avoids import cycles with the main rocket package
type SubscribePayload ¶
type SubscribePayload struct {
Query string `json:"query"`
Variables map[string]interface{} `json:"variables,omitempty"`
OperationName string `json:"operationName,omitempty"`
}
SubscribePayload is the payload for a subscribe message