dotansimha / dotansimha/graphql-code-generator

[cli] Add onError callback to handle runtime errors

Open
#10,355 0 comments 1 reaction 1 assignee Claimed by @eddeee888 View on GitHub
Dominant language
TypeScript
Stars
11.3k
Forks
1.4k
Avg merge
1d 1h
Merged PRs (30d)
23

Description

### Is your feature request related to a problem? Please describe.

It could be useful to have a way to trigger functionalities when errors happen while running codegen.
Some uses cases:
- Write errors to a file when schema fails to load (usually by `@graphql-codegen/cli`)
- If plugins or presets encounters runtime error, report extra context with the thrown error

### Describe the solution you'd like

```
const config: CodegenConfig = {
generates: {
"src/types": {
plugins: ['typescript'],
onError: (error) => { // add a callback to handle arbitrary thrown errors during runtime. This could be loader errors or plugin runtime errors, etc.
// handle error
}
}
},
}
```

### Describe alternatives you've considered

_No response_

### Any additional important details?

_No response_

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.