From ef2b759a8e1f66898c9a4e42f8dad2ffbcfa5425 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Wed, 17 Apr 2024 14:04:07 +0200 Subject: [PATCH] fix(backend): no introspection query in log --- backend/src/server/logger.ts | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/backend/src/server/logger.ts b/backend/src/server/logger.ts index 76a7aa9df9..bdfa258ce0 100644 --- a/backend/src/server/logger.ts +++ b/backend/src/server/logger.ts @@ -10,15 +10,14 @@ export default { // Fires whenever a GraphQL request is received from a client. // eslint-disable-next-line @typescript-eslint/require-await async requestDidStart(requestContext: GraphQLRequestContext) { + const isIntrospectionQuery = requestContext.request.operationName === 'IntrospectionQuery' const qID = randomBytes(4).toString('hex') const logRequest = ['Apollo Request', qID, requestContext.request.operationName] - if (requestContext.request.operationName !== 'IntrospectionQuery') { - logRequest.push(JSON.stringify(requestContext.request.query)) - } + logRequest.push(JSON.stringify(requestContext.request.query)) if (requestContext.request.variables) { logRequest.push(JSON.stringify(requestContext.request.variables)) } - logger.debug(...logRequest) + if (!isIntrospectionQuery) logger.debug(...logRequest) return { // eslint-disable-next-line @typescript-eslint/require-await async willSendResponse(requestContext: GraphQLRequestContextWillSendResponse) { @@ -28,11 +27,8 @@ export default { return } - if (requestContext.request.operationName !== 'IntrospectionQuery') { - logResponse.push(JSON.stringify(requestContext.response.body)) - } - - logger.debug(...logResponse) + logResponse.push(JSON.stringify(requestContext.response.body)) + if (!isIntrospectionQuery) logger.debug(...logResponse) }, } },