No release in over 3 years
Low commit activity in last 3 years
Easily add GraphQL params and resolvers to logs
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

Runtime

 Project Readme

Graphql::LogHelper

GraphQL is amazing. But one disadvantage is that with Ruby you lose some of the logging that "just works" with REST. That is, all of the log messages have the same controller (API::GraphqlController) and the params are lost or unstructured.

This gem aims to make is easy to include this information in logs messages.

Installation

Add this line to your application's Gemfile:

gem 'graphql-log_helper'

And then execute:

$ bundle install

Or install it yourself as:

$ gem install graphql-log_helper

Getting Started

Add lograge to your Gemfile and include the following in config/initializers/lograge.rb

Rails.application.configure do
  config.lograge.enabled = true
  config.lograge.formatter = Lograge::Formatters::Json.new
  config.lograge.custom_options = lambda do |event|
    if event.payload[:controller] == 'GraphqlController'
      Graphql::LogHelper.log_details(event.payload[:params])
    else
      { params: event.payload[:params] }
    end.compact
  end
end

Documentation

TODO

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/hoverinc/graphql-log_helper. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the code of conduct.

License

The gem is available as open source under the terms of the MIT License.

Code of Conduct

Everyone interacting in the Graphql::LogHelper project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the code of conduct.