wsproto

package
v0.0.0-...-0911b43 Latest Latest
Warning

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

Go to latest
Published: May 2, 2024 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AbsintheWSSubProtocol = "absinthe"
)
View Source
const (

	// This might seem confusing, but the protocol is called graphql-ws and uses "graphql-transport-ws" as subprotocol
	GraphQLWSSubprotocol = "graphql-transport-ws"
)
View Source
const (

	// Again, this is not a typo. Somehow they managed to give each protocol name to the other's subprotocol identifier.
	SubscriptionsTransportWSSubprotocol = "graphql-ws"
)

Variables

This section is empty.

Functions

func IsSupportedSubprotocol

func IsSupportedSubprotocol(subProtocol string) bool

func Subprotocols

func Subprotocols() []string

Types

type JSONConn

type JSONConn interface {
	ReadJSON(v interface{}) error
	WriteJSON(v interface{}) error
}

type Message

type Message struct {
	ID      string
	Type    MessageType
	Payload json.RawMessage
}

type MessageType

type MessageType int

MessageType indicates the type of the message received from the client

const (
	MessageTypePing MessageType = iota + 1
	MessageTypePong
	MessageTypeSubscribe
	MessageTypeComplete
	MessageTypeTerminate
)

type Proto

type Proto interface {
	Subprotocol() string
	// Initialize starts the protocol and returns the initial payload received from the client
	Initialize() (json.RawMessage, error)
	ReadMessage() (*Message, error)

	Pong(*Message) error
	WriteGraphQLData(id string, data json.RawMessage, extensions json.RawMessage) error
	WriteGraphQLErrors(id string, errors json.RawMessage, extensions json.RawMessage) error
	// Done is sent to indicate the requested operation is done and no more results will come in
	Done(id string) error
}

func NewProtocol

func NewProtocol(subProtocol string, conn JSONConn) (Proto, error)

Jump to

Keyboard shortcuts

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