graphql
graphql copied to clipboard
executor: adds panic handler
Overview
- graphql: adds
PanicHandler
type. - graphql: adds
Params.PanicHandler
field. - executor: calls PanicHandler when there's a panic while resolving a field.
- closes: https://github.com/graphql-go/graphql/issues/243
- built on top of: https://github.com/graphql-go/graphql/pull/252 — thanks a lot @scottjg :+1:
Test plan
- Unit test.
Coverage increased (+0.009%) to 82.091% when pulling 47767e0f4bbeddee4def9141c0f8909591386f65 on panic-handler into 7731016ba482d3741eea075d23dc6366b932f8f4 on master.
@chris-ramon thanks for your help with this patch!
i was going over your changes and i have a question... originally my patch would only call the panic handler on an actual panic. it appears with your changes, it gets called when a resolver returns any errors (maybe due to reverting the change here https://github.com/graphql-go/graphql/pull/253/commits/b63c4f02154a8075d775df2a8ccf960485717907#diff-58bccd1b2cfaf06d4d4ac893e4712c88L592 ). was that intentional? if so, is it possible to distinguish between a panic and an error in the panic handler? i think everything gets flattened to a graphql formatted error type so i'm not sure if it's possible.
Coverage increased (+0.009%) to 82.234% when pulling 451533e82374cae4032ce83553bb374af94c5a62 on panic-handler into 9b5a661117d443fbf730f165e7424d7ae199856b on master.
I stuck around on this problem also, I need to know where the stacktrace of the panic in my resolver. is this patch possible to solve that? I used to manually add
defer func() {
if r := recover(); r != nil {
log.Println("panic: ", string(debug.Stack()))
panic(r)
}
}()
on every resolver. So with this handler I should print with debug.Stack() in the handler? and also why this PR still not merged to master yet, or should I use another version for using this patch?
@chris-ramon Do you have any forecast for the release?
looking forward to get this merged.
any updates on this?
any updates on this?