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 c1876907b..f195843d7 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,10 +53,23 @@ class ApolloSubscriptionProtocolHandler( private val basicConnectionErrorMessage = SubscriptionOperationMessage(type = GQL_ERROR.type) private val acknowledgeMessage = SubscriptionOperationMessage(GQL_CONNECTION_ACK.type) + private fun getOperationName(payload: Any?): String { + val unknownOperationName = "__UNKNOWN__" + + try { + @Suppress("UNCHECKED_CAST") + return (payload as Map)["operationName"] ?: unknownOperationName + } catch (e: Exception) { + return unknownOperationName + } + } + fun handleMessage(context: WsMessageContext): Flow { val operationMessage = convertToMessageOrNull(context.message()) ?: return flowOf(basicConnectionErrorMessage) logger.debug { - "GraphQL subscription client message, sessionId=${context.sessionId} ${ + "GraphQL subscription client message, sessionId=${context.sessionId} type=${operationMessage.type} operationName=${ + getOperationName(operationMessage.payload) + } ${ if (serverConfig.gqlDebugLogsEnabled.value) { "operationMessage=$operationMessage" } else {