Catch the highlights of GraphQLConf 2023!Click for recordings.Or check out our recap blog post.
useErrorHandler

useErrorHandler

Package nameWeekly DownloadsVersionLicenseUpdated
@envelop/core (opens in a new tab)DownloadsVersionLicenseOct 16th, 2023

useErrorHandler

This plugin triggers a custom function when execution encounters an error.

import { execute, parse, specifiedRules, subscribe, validate } from 'graphql'
import { envelop, useEngine, useErrorHandler } from '@envelop/core'
 
const getEnveloped = envelop({
  plugins: [
    useEngine({ parse, validate, specifiedRules, execute, subscribe }),
    useErrorHandler((errors, args) => {
      // This callback is called once, containing all GraphQLError emitted during execution phase
    })
    // ... other plugins ...
  ]
})