diff options
Diffstat (limited to 'api/graphql/tracer.go')
-rw-r--r-- | api/graphql/tracer.go | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/api/graphql/tracer.go b/api/graphql/tracer.go index 4dc66c37..4141901e 100644 --- a/api/graphql/tracer.go +++ b/api/graphql/tracer.go @@ -14,32 +14,21 @@ import ( // adapted from https://github.com/99designs/gqlgen/blob/master/graphql/handler/debug/tracer.go +var _ graphql.HandlerExtension = &Tracer{} +var _ graphql.ResponseInterceptor = &Tracer{} + type Tracer struct { Out io.Writer } -var _ interface { - graphql.HandlerExtension - graphql.ResponseInterceptor -} = &Tracer{} - func (a Tracer) ExtensionName() string { return "error tracer" } -func (a *Tracer) Validate(schema graphql.ExecutableSchema) error { +func (a Tracer) Validate(schema graphql.ExecutableSchema) error { return nil } -func stringify(value interface{}) string { - valueJson, err := json.MarshalIndent(value, " ", " ") - if err == nil { - return string(valueJson) - } - - return fmt.Sprint(value) -} - func (a Tracer) InterceptResponse(ctx context.Context, next graphql.ResponseHandler) *graphql.Response { resp := next(ctx) @@ -65,3 +54,12 @@ func (a Tracer) InterceptResponse(ctx context.Context, next graphql.ResponseHand _, _ = fmt.Fprintln(a.Out) return resp } + +func stringify(value interface{}) string { + valueJson, err := json.MarshalIndent(value, " ", " ") + if err == nil { + return string(valueJson) + } + + return fmt.Sprint(value) +} |