@@ -30,6 +30,7 @@ func ParseSchema(schemaString string, resolver interface{}, opts ...SchemaOpt) (
3030 maxParallelism : 10 ,
3131 tracer : trace.OpenTracingTracer {},
3232 logger : & log.DefaultLogger {},
33+ panicHandler : & errors.DefaultPanicHandler {},
3334 }
3435 for _ , opt := range opts {
3536 opt (s )
@@ -78,6 +79,7 @@ type Schema struct {
7879 tracer trace.Tracer
7980 validationTracer trace.ValidationTracerContext
8081 logger log.Logger
82+ panicHandler errors.PanicHandler
8183 useStringDescriptions bool
8284 disableIntrospection bool
8385 subscribeResolverTimeout time.Duration
@@ -143,6 +145,14 @@ func Logger(logger log.Logger) SchemaOpt {
143145 }
144146}
145147
148+ // PanicHandler is used to customize the panic errors during query execution.
149+ // It defaults to errors.DefaultPanicHandler.
150+ func PanicHandler (panicHandler errors.PanicHandler ) SchemaOpt {
151+ return func (s * Schema ) {
152+ s .panicHandler = panicHandler
153+ }
154+ }
155+
146156// DisableIntrospection disables introspection queries.
147157func DisableIntrospection () SchemaOpt {
148158 return func (s * Schema ) {
@@ -244,9 +254,10 @@ func (s *Schema) exec(ctx context.Context, queryString string, operationName str
244254 Schema : s .schema ,
245255 DisableIntrospection : s .disableIntrospection ,
246256 },
247- Limiter : make (chan struct {}, s .maxParallelism ),
248- Tracer : s .tracer ,
249- Logger : s .logger ,
257+ Limiter : make (chan struct {}, s .maxParallelism ),
258+ Tracer : s .tracer ,
259+ Logger : s .logger ,
260+ PanicHandler : s .panicHandler ,
250261 }
251262 varTypes := make (map [string ]* introspection.Type )
252263 for _ , v := range op .Vars {
0 commit comments