gqlgenws

package module
v0.2.2 Latest Latest
Warning

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

Go to latest
Published: Nov 2, 2022 License: MIT Imports: 3 Imported by: 0

README

gqlgenws

Go Doc Badge Go Report Card Badge

WebSocket transports for gqlgen.

Provided protocol implementations follow their respective specification as closely as possible.

Protocols

Usage

srv := handler.New(executableSchema)

initFunc := func(r *http.Request, p wsutil.ObjectPayload) (context.Context, wsutil.ObjectPayload, error) {
    ctx := r.Context()
    // ...
    return ctx, nil, nil
}

p1 := &graphqlws.Protocol{
    InitFunc: initFunc,
    PingInterval: 25 * time.Second,
}

p2 := &transportws.Protocol{
    InitFunc: initFunc,
    KeepAliveInterval: 25 * time.Second,
}

// Use the protocol directly as a transport.
srv.AddTransport(p1)
srv.AddTransport(p2)

// OR

// Use with Negotiator to do protocol negotiation.
srv.AddTransport(wstransport.NewNegotiator(p1, p2))

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Protocol

type Protocol interface {
	// Name returns the WebSocket protocol name used by the
	// Sec-WebSocket-Protocol header.
	Name() string

	// Run is called after the request has been upgraded and the protocol has
	// been negotiated with the client.
	Run(*http.Request, *websocket.Conn, graphql.GraphExecutor)
}

Protocol is implemented by WebSocket protocols.

Directories

Path Synopsis
internal
Package wserr declares WebSocket error types and implements functions to pass WebSocket errors using context.
Package wserr declares WebSocket error types and implements functions to pass WebSocket errors using context.
wsprotocol
graphqlws
Package graphqlws implements the graphql-ws protocol.
Package graphqlws implements the graphql-ws protocol.
transportws
Package transportws implements the subscriptions-transport-ws protocol.
Package transportws implements the subscriptions-transport-ws protocol.
Package wstransport implements common gqlgen WebSocket transports.
Package wstransport implements common gqlgen WebSocket transports.
Package wsutil declares common types and implements some WebSocket utility functions.
Package wsutil declares common types and implements some WebSocket utility functions.

Jump to

Keyboard shortcuts

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