Skip to content

Commit

Permalink
fix(backend): no introspection query in log
Browse files Browse the repository at this point in the history
  • Loading branch information
Mogge committed Apr 17, 2024
1 parent 378156d commit ef2b759
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions backend/src/server/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Context>) {
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<Context>) {
Expand All @@ -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)
},
}
},
Expand Down

0 comments on commit ef2b759

Please sign in to comment.