Debug subscription not returning response for clients


#1

Is there any way to log the request and response for subscriptions to clients? I am trying to troubleshoot why messages are not pushed to clients.

For now, I am only able to log the connect and disconnect events, however disconnect events are never triggered.

const _ = require('lodash-uuid');
function onSubscriptionConnect(connectionParams, webSocket, ctx) {
  const requestId = _.uuid();
  const reqStr = `${requestId} - GraphQL Subscription Connected`;
  queryLogger.info(reqStr);

  return {
    requestId,
    Authorization: connectionParams.Authorization
  }
}

function onSubscriptionDisconnect(webSocket, ctx) {
  const requestId = ctx.connection ? ctx.connection.context.requstId : null;
  if (requestId) {
    const reqStr = `${requestId} - GraphQL Subscription Disconnected`;
    queryLogger.info(reqStr);
  }
 
}

// Set Server Options
const subscriptions = {
  onConnect: onSubscriptionConnect,
  onDisconnect: onSubscriptionDisconnect,
  keepAlive: 30000 //interval in ms to send KEEPALIVE messages to all clients
};