[next] Websocket Keep Alive (#2394)

* feat: added keepalive config

* fix: format

* fix: adjusted client timeout default

* Update server.ts
This commit is contained in:
Wyatt Johnson
2019-07-09 16:27:58 +00:00
committed by GitHub
parent 9a191b44ba
commit 9e55ea66fa
4 changed files with 20 additions and 0 deletions
@@ -223,6 +223,13 @@ export function createSubscriptionServer(
schema: GraphQLSchema,
options: Options
) {
const keepAlive = options.config.get("websocket_keep_alive_timeout");
if (typeof keepAlive !== "number" || keepAlive <= 0) {
throw new Error(
"expected the websocket_keep_alive_timeout configuration to be a positive number"
);
}
return SubscriptionServer.create(
{
schema,
@@ -230,6 +237,7 @@ export function createSubscriptionServer(
subscribe,
onConnect: onConnect(options),
onOperation: onOperation(options),
keepAlive,
},
{
server,