Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor ApolloLoggerPlugin to skip message enrichment for business errors #27

Merged
merged 4 commits into from
May 23, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Refactor ApolloLoggerPlugin to skip logging for validation errors
  • Loading branch information
Tudor Stanciu committed May 22, 2024
commit f39e8f43d5f895f48ffacb1d111852a30ddbd842
2 changes: 2 additions & 0 deletions packages/pino-apollo/src/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,8 @@ export class ApolloLoggerPlugin implements ApolloServerPlugin<ApolloContextExten
},
didEncounterErrors: async (requestContext: GraphQLRequestContextDidEncounterErrors<ApolloContextExtension>) => {
for (const error of requestContext.errors) {
const isValidationError = error?.extensions?.code === 'GRAPHQL_VALIDATION_FAILED'
if (isValidationError) return
const message =
'[GraphQL_Execution][Error] The server encounters errors while parsing, validating, or executing the operation'
this._logRequestError(error, message, requestContext, error?.extensions, logger)
Expand Down
Loading