diff --git a/backend/src/server/logger.ts b/backend/src/server/logger.ts index bdfa258ce0..31f5fffc7c 100644 --- a/backend/src/server/logger.ts +++ b/backend/src/server/logger.ts @@ -12,23 +12,26 @@ export default { async requestDidStart(requestContext: GraphQLRequestContext) { const isIntrospectionQuery = requestContext.request.operationName === 'IntrospectionQuery' const qID = randomBytes(4).toString('hex') - const logRequest = ['Apollo Request', qID, requestContext.request.operationName] - logRequest.push(JSON.stringify(requestContext.request.query)) - if (requestContext.request.variables) { - logRequest.push(JSON.stringify(requestContext.request.variables)) + if (!isIntrospectionQuery) { + const logRequest = ['Apollo Request', qID, requestContext.request.operationName] + 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) { - const logResponse = ['Apollo Response', qID] - if (requestContext.errors) { - logger.error(...logResponse, JSON.stringify(requestContext.errors)) - return + if (!isIntrospectionQuery) { + const logResponse = ['Apollo Response', qID] + if (requestContext.errors) { + logger.error(...logResponse, JSON.stringify(requestContext.errors)) + return + } + logResponse.push(JSON.stringify(requestContext.response.body)) + logger.debug(...logResponse) } - - logResponse.push(JSON.stringify(requestContext.response.body)) - if (!isIntrospectionQuery) logger.debug(...logResponse) }, } },