diff options
author | Michael Muré <batolettre@gmail.com> | 2024-08-28 11:43:42 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-28 09:43:42 +0000 |
commit | 57e7147021e38b847213d4dc7f0e0bf0b022850d (patch) | |
tree | 882650697950003e2325f0815353032a8596ca1d /api/graphql/tracer.go | |
parent | e45c3c5ee6dc5650fd8c3f480d9e09e5f3b221fd (diff) | |
download | git-bug-57e7147021e38b847213d4dc7f0e0bf0b022850d.tar.gz |
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
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) +} |