diff --git a/slog.go b/slog.go index 02cb5d3..06bbbeb 100644 --- a/slog.go +++ b/slog.go @@ -54,6 +54,16 @@ func (noopVariablesScrubber) Scrub(vars map[string]any) map[string]any { return nil } +var _ VariablesScrubber = (*DevScrubber)(nil) + +// DevScrubber is a VariablesScrubber that passes all var information from +// GraphQL variables. It is intended for use in development environments. +type DevScrubber struct{} + +func (DevScrubber) Scrub(vars map[string]any) map[string]any { + return vars +} + // NewSLogGraphQLResponseMiddleware is used to log GraphQL requests and responses. func NewSLogGraphQLResponseMiddleware(l *slog.Logger, s VariablesScrubber) graphql.ResponseMiddleware { if l == nil { diff --git a/slog_test.go b/slog_test.go index 4776a95..6b374f8 100644 --- a/slog_test.go +++ b/slog_test.go @@ -70,6 +70,17 @@ var _ = Describe("Logger", func() { }) }) + Describe("DevScrubber#Scrub", func() { + It("should return the same map", func() { + s := DevScrubber{} + + in := map[string]any{"test": struct{ Data string }{Data: "data"}} + res := s.Scrub(in) + + g.Expect(res).To(g.Equal(in)) + }) + }) + Describe("NewGraphQLResponseMiddleware", func() { It("should log GraphQL response and request info", func() { var (