Skip to content

Commit

Permalink
fix(core): add gql variables and extensions logs
Browse files Browse the repository at this point in the history
Signed-off-by: Godefroy Ponsinet <godefroy.ponsinet@outlook.com>
  • Loading branch information
90dy committed Oct 18, 2018
1 parent b8324e6 commit a6f9430
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions core/cmd/berty/daemon.go
Expand Up @@ -3,6 +3,7 @@ package main
import (
"context"
"encoding/base64"
"encoding/json"
"fmt"
"log"
"net"
Expand Down Expand Up @@ -303,12 +304,24 @@ func daemon(opts *daemonOptions) error {
gqlhandler.RequestMiddleware(func(ctx context.Context, next func(ctx context.Context) []byte) []byte {
req := graphql.GetRequestContext(ctx)
//verb := strings.TrimSpace(strings.Split(req.RawQuery, "{")[1]) // verb can be used to filter-out
variables := ""
if req.Variables != nil && len(req.Variables) > 0 {
out, _ := json.Marshal(req.Variables)
variables = string(out)
}
extensions := ""
if req.Extensions != nil && len(req.Extensions) > 0 {
out, _ := json.Marshal(req.Extensions)
extensions = string(out)
}
gqlLogger.Debug(
"gql query",
zap.String(
"query",
strings.Replace(req.RawQuery, "\n", "", -1),
),
zap.String("variables", variables),
zap.String("extensions", extensions),
)
return next(ctx)
}),
Expand Down

0 comments on commit a6f9430

Please sign in to comment.