From 57e7147021e38b847213d4dc7f0e0bf0b022850d Mon Sep 17 00:00:00 2001 From: Michael Muré Date: Wed, 28 Aug 2024 11:43:42 +0200 Subject: graphql: properly namespace Bug to make space for other entities (#1254) Also: use gqlgen directives to help the type auto-binding Missing: - namespace mutations - adapt the webUI queries --- api/graphql/tracer.go | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) (limited to 'api/graphql/tracer.go') 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) +} -- cgit