From 70075ba8ea05f44db747653c1df4801fd2bcb396 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Wed, 4 Oct 2023 23:48:34 +0200 Subject: [PATCH] Always log message type and operation name --- .../ApolloSubscriptionProtocolHandler.kt | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/subscriptions/ApolloSubscriptionProtocolHandler.kt b/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/subscriptions/ApolloSubscriptionProtocolHandler.kt index c1876907b4..ce9c421dc1 100644 --- a/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/subscriptions/ApolloSubscriptionProtocolHandler.kt +++ b/server/src/main/kotlin/suwayomi/tachidesk/graphql/server/subscriptions/ApolloSubscriptionProtocolHandler.kt @@ -53,15 +53,26 @@ class ApolloSubscriptionProtocolHandler( private val basicConnectionErrorMessage = SubscriptionOperationMessage(type = GQL_ERROR.type) private val acknowledgeMessage = SubscriptionOperationMessage(GQL_CONNECTION_ACK.type) + private fun getOperationName(payload: Any?): String { + try { + @Suppress("UNCHECKED_CAST") + return (payload as Map)["operationName"]!! + } catch (e: Exception) { + return "__UNKNOWN__" + } + } + fun handleMessage(context: WsMessageContext): Flow { val operationMessage = convertToMessageOrNull(context.message()) ?: return flowOf(basicConnectionErrorMessage) logger.debug { - "GraphQL subscription client message, sessionId=${context.sessionId} ${ - if (serverConfig.gqlDebugLogsEnabled.value) { - "operationMessage=$operationMessage" - } else { - "" - } + "GraphQL subscription client message, sessionId=${context.sessionId} type=${operationMessage.type} operationName=${ + getOperationName(operationMessage.payload) + } ${ + if (serverConfig.gqlDebugLogsEnabled.value) { + "operationMessage=$operationMessage" + } else { + "" + } }" }