apollo

package
v1.1.0-beta.2 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Client sends this message after plain websocket connection to start the communication with the server
	GQL_CONNECTION_INIT = "connection_init"
	// The server may responses with this message to the GQL_CONNECTION_INIT from client, indicates the server rejected the connection.
	GQL_CONNECTION_ERROR = "connection_error"
	// Client sends this message to execute GraphQL operation
	GQL_START = "start"
	// Client sends this message in order to stop a running GraphQL operation execution (for example: unsubscribe)
	GQL_STOP = "stop"
	// Server sends this message upon a failing operation, before the GraphQL execution, usually due to GraphQL validation errors (resolver errors are part of GQL_DATA message, and will be added as errors array)
	GQL_ERROR = "error"
	// The server sends this message to transfter the GraphQL execution result from the server to the client, this message is a response for GQL_START message.
	GQL_DATA = "data"
	// Server sends this message to indicate that a GraphQL operation is done, and no more data will arrive for the specific operation.
	GQL_COMPLETE = "complete"
	// Server message that should be sent right after each GQL_CONNECTION_ACK processed and then periodically to keep the client connection alive.
	// The client starts to consider the keep alive message only upon the first received keep alive message from the server.
	GQL_CONNECTION_KEEP_ALIVE = "ka"
	// The server may responses with this message to the GQL_CONNECTION_INIT from client, indicates the server accepted the connection. May optionally include a payload.
	GQL_CONNECTION_ACK = "connection_ack"
	// Client sends this message to terminate the connection.
	GQL_CONNECTION_TERMINATE = "connection_terminate"
	// Unknown operation type, for logging only
	GQL_UNKNOWN = "unknown"
	// Internal status, for logging only
	GQL_INTERNAL = "internal"
)
View Source
const DisconnectPayload = "{\"type\":\"connection_error\"}"
View Source
const PingPayload = "{\"type\":\"ka\"}"

Variables

This section is empty.

Functions

func IdToIdentifier

func IdToIdentifier(id string, channel string) string

func IdentifierToId

func IdentifierToId(id string) (string, error)

Types

type Config

type Config struct {
	// Where to mount WS handler
	Path string
	// Action Cable channel class name
	Channel string
	// Action Cable channel action name
	Action string
}

func NewConfig

func NewConfig() Config

func (Config) Enabled

func (c Config) Enabled() bool

type Encoder

type Encoder struct {
}

func (Encoder) Decode

func (gql Encoder) Decode(raw []byte) (*common.Message, error)

func (Encoder) Encode

func (gql Encoder) Encode(msg encoders.EncodedMessage) (*ws.SentFrame, error)

func (Encoder) EncodeTransmission

func (gql Encoder) EncodeTransmission(raw string) (*ws.SentFrame, error)

func (Encoder) ID

func (Encoder) ID() string

type Executor

type Executor struct {
	// contains filtered or unexported fields
}

Handling Apollo commands and transforming them into Action Cable commands

func NewExecutor

func NewExecutor(node node.AppNode, config *Config) *Executor

func (*Executor) HandleCommand

func (ex *Executor) HandleCommand(s *node.Session, msg *common.Message) error

type GraphqlOperation

type GraphqlOperation struct {
	Id      string      `json:"id,omitempty"`
	Type    string      `json:"type"`
	Payload interface{} `json:"payload,omitempty"`
}

func (*GraphqlOperation) PayloadString

func (op *GraphqlOperation) PayloadString() (string, error)

func (*GraphqlOperation) ToJSON

func (op *GraphqlOperation) ToJSON() []byte

type GraphqlQuery

type GraphqlQuery struct {
	Query         string      `json:"query"`
	Variables     interface{} `json:"variables,omitempty"`
	OperationName string      `json:"operationName,omitempty"`
	OperationId   string      `json:"operationId,omitempty"`
	// Required for Action Cable compatibility
	Action string `json:"action,omitempty"`
}

func (*GraphqlQuery) ToJSON

func (op *GraphqlQuery) ToJSON() []byte

Jump to

Keyboard shortcuts

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