@@ -28,6 +28,7 @@ func ParseSchema(schemaString string, resolver interface{}, opts ...SchemaOpt) (
2828 tracer : trace.OpenTracingTracer {},
2929 validationTracer : trace.NoopValidationTracer {},
3030 logger : & log.DefaultLogger {},
31+ panicHandler : & errors.DefaultPanicHandler {},
3132 }
3233 for _ , opt := range opts {
3334 opt (s )
@@ -67,6 +68,7 @@ type Schema struct {
6768 tracer trace.Tracer
6869 validationTracer trace.ValidationTracer
6970 logger log.Logger
71+ panicHandler errors.PanicHandler
7072 useStringDescriptions bool
7173 disableIntrospection bool
7274}
@@ -126,6 +128,14 @@ func Logger(logger log.Logger) SchemaOpt {
126128 }
127129}
128130
131+ // PanicHandler is used to customize the panic errors during query execution.
132+ // It defaults to errors.DefaultPanicHandler.
133+ func PanicHandler (panicHandler errors.PanicHandler ) SchemaOpt {
134+ return func (s * Schema ) {
135+ s .panicHandler = panicHandler
136+ }
137+ }
138+
129139// DisableIntrospection disables introspection queries.
130140func DisableIntrospection () SchemaOpt {
131141 return func (s * Schema ) {
@@ -197,9 +207,10 @@ func (s *Schema) exec(ctx context.Context, queryString string, operationName str
197207 Schema : s .schema ,
198208 DisableIntrospection : s .disableIntrospection ,
199209 },
200- Limiter : make (chan struct {}, s .maxParallelism ),
201- Tracer : s .tracer ,
202- Logger : s .logger ,
210+ Limiter : make (chan struct {}, s .maxParallelism ),
211+ Tracer : s .tracer ,
212+ Logger : s .logger ,
213+ PanicHandler : s .panicHandler ,
203214 }
204215 varTypes := make (map [string ]* introspection.Type )
205216 for _ , v := range op .Vars {
0 commit comments