Enable keepalive for websocket connection (#1134)

This commit is contained in:
InfiniteTF
2021-02-23 03:03:02 +01:00
committed by GitHub
parent f7a8899d90
commit 14230d7b52

View File

@@ -14,6 +14,7 @@ import (
"runtime/debug" "runtime/debug"
"strconv" "strconv"
"strings" "strings"
"time"
"github.com/99designs/gqlgen/handler" "github.com/99designs/gqlgen/handler"
"github.com/go-chi/chi" "github.com/go-chi/chi"
@@ -135,12 +136,14 @@ func Start() {
}, },
}) })
maxUploadSize := handler.UploadMaxSize(config.GetMaxUploadSize()) maxUploadSize := handler.UploadMaxSize(config.GetMaxUploadSize())
websocketKeepAliveDuration := handler.WebsocketKeepAliveDuration(10 * time.Second)
txnManager := manager.GetInstance().TxnManager txnManager := manager.GetInstance().TxnManager
resolver := &Resolver{ resolver := &Resolver{
txnManager: txnManager, txnManager: txnManager,
} }
gqlHandler := handler.GraphQL(models.NewExecutableSchema(models.Config{Resolvers: resolver}), recoverFunc, websocketUpgrader, maxUploadSize)
gqlHandler := handler.GraphQL(models.NewExecutableSchema(models.Config{Resolvers: resolver}), recoverFunc, websocketUpgrader, websocketKeepAliveDuration, maxUploadSize)
r.Handle("/graphql", gqlHandler) r.Handle("/graphql", gqlHandler)
r.Handle("/playground", handler.Playground("GraphQL playground", "/graphql")) r.Handle("/playground", handler.Playground("GraphQL playground", "/graphql"))