envelop icon indicating copy to clipboard operation
envelop copied to clipboard

Feedback for “useSentry”

Open enri90 opened this issue 2 years ago • 2 comments

Hi everyone I have been wondering for a few hours how to manage errors with Sentry I want to avoid reporting USER_NOT_FOUND on the Login or INCORRECT_PASSWORD or validation fileds

  • https://pothos-graphql.dev/docs/plugins/validation
  • GraphQLError and ZodError

new GraphQLError('User not registered', { extensions: { code: 'USER_NOT_FOUND', }, })

#DOC https://the-guild.dev/graphql/envelop/plugins/use-sentry

  • skipError (default: ignored EnvelopError) - Indicates whether or not to skip Sentry exception reporting for a given error. By default, this plugin skips all EnvelopError errors and does not report it to Sentry.

but

 /**
   * Indicates whether or not to skip Sentry exception reporting for a given error.
   * By default, this plugin skips all `GraphQLError` errors and does not report it to Sentry.
   */
  skipError?: (args: Error) => boolean;

I would like to use GraphQLError to report with Sentry when you really need how I have to use the skipError function If someone can help me at the confused thx

enri90 avatar Mar 05 '23 01:03 enri90

skipError: (error) => { return !(error instanceof GraphQLError) && !(error instanceof ZodError); },

in this way? does not work :(

enri90 avatar Mar 05 '23 13:03 enri90

skipError: (error) => { return (error instanceof GraphQLError) as boolean; }

it works but when used with pothos @pothos/plugin-errors for error handling in response the envelop plugin doesn't work

{ "errors": [ { "message": "User not registered", "locations": [ { "line": 2, "column": 3 } ], "path": [ "authenticate" ], "extensions": { "code": "USER_NOT_FOUND" } } ], "data": null }

with pothos @pothos/plugin-errors:

{ "data": { "authenticate": { "message": "User not registered", "code": "USER_NOT_FOUND" } } }

Condition errors

`return {

onExecuteDone(payload) {
    const handleResult = ({ result, setResult }) => {
        if (includeRawResult) {
            rootSpan.setData('result', result);
        }
        if (result.errors && result.errors.length > 0) {

`

enri90 avatar Mar 05 '23 14:03 enri90