graphql-go / graphql-go/handler
Logging Panic Stack Trace
- Dominant language
- Go
- Stars
- 451
- Forks
- 135
- PR merge metrics
- No merged PRs in 30d
Description
I'm looking to be able to log a stack trace when one of my field resolvers panics.
Currently, I get something like this:
```
{ "query": "query AllAttributes() {attributes(key: $value) {names}}", "variables": {} }
[
{
"message": "runtime error: invalid memory address or nil pointer dereference",
"locations": []
}
]
```
I've tried to FormatErrorFn which works well for regular errors that get bubbled up, but by the time it gets triggered, the panic's stack trace is missing. I believe the defer-recover function in executor.go `completeValueCatchingError` would need to capture the stack in `debug.Stack()` and stash it on the `gqlerrors.Error`.
I'm happy to attempt to implement it and open a PR, but I'd like to make sure I wasn't missing something first.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.