Desuuuu / gqlgenws

WebSocket transports for gqlgen

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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))

About

WebSocket transports for gqlgen

License:MIT License


Languages

Language:Go 100.0%