You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
What's the recommended approach for reading and capturing errors? We mainly would like to track certain errors in Sentry. In apollo we could do something like this:
export const apolloSentryPlugin: ApolloServerPlugin = {
requestDidStart() {
return {
didEncounterErrors(rc) {
Sentry.withScope(scope => {
scope.setTags({
graphql: rc?.operation?.operation || 'parse_err',
graphqlName: rc?.operationName || rc?.request?.operationName,
stage: process.env.STAGE
})
rc.errors.forEach(error => {
if (error.path || error.name !== 'GraphQLError') {
// If an error contains the string "code:", e.g. code:auth/not-allowed we have explicitly set that error
// Because the error is intentional, we dont' want to capture it in sentry, we just want to pass it to the client
if (!error.message.includes('code:')) {
scope.setExtras({ path: error.path })
Sentry.captureException(error)
}
} else {
// It's debatable wether we should log this to this sentry
// for now, leave it in as it logs a wrong query or mutation to Sentry
Sentry.captureMessage(`GraphQLWrongQuery ${error.message}`)
}
})
})
}
}
}
}
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
What's the recommended approach for reading and capturing errors? We mainly would like to track certain errors in Sentry. In apollo we could do something like this:
Is it doable using middleware?
Beta Was this translation helpful? Give feedback.
All reactions