Skip to content

Log every graphql request #1357

@mg98

Description

@mg98

I wanted to ask if there is a convenient way to log all incoming graphql api requests. The middleware function could be a way, but I think there's not really a nice way to get information like the graphql path and the inputs etc.

I would like to do something in a similar fashion that I've implemented to log errors:

rootHandler.SetErrorPresenter(func(ctx context.Context, e error) *gqlerror.Error {
	err := graphql.DefaultErrorPresenter(ctx, e)
	logger.Debugw("graphql request failed",
		"message", err.Message,
		"path", err.Path,
		"locations", err.Locations,
		"extensions", err.Extensions,
		"rule", err.Rule,
	)
	
	return err
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions