graphql-rails_logger 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 718affecc756a81b55c2a9184d6c548d280494d4
|
4
|
+
data.tar.gz: 890ecf5d194cba6d4a032f4bf62838c2d061b9df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bcc3afed83c469732b55749ff531892aa6d8cca7d311ef67e9a6183a8e480598b98c84b6695865986304cb9b342e0124d22224ca81aefcbcb7170e3935c1253b
|
7
|
+
data.tar.gz: e6b26301123958355ee9a82da0d04a9f30a8697b2693fee5b76ae925cf9a94ce62179b9ec7122274022a2c89422303324503be428ff160d82a3db752418c230d
|
data/README.md
CHANGED
@@ -23,15 +23,25 @@ And then execute:
|
|
23
23
|
|
24
24
|
$ bundle
|
25
25
|
|
26
|
-
##
|
26
|
+
## Configuration
|
27
27
|
|
28
28
|
By default this gem formats params only for `GraphqlController#execute`.
|
29
29
|
|
30
|
-
If you want to change this behaviour, add `config/
|
30
|
+
If you want to change this behaviour, add `config/initializers/graphql_rails_logger.rb` file and set proper controller and actions like this:
|
31
31
|
```ruby
|
32
|
-
|
32
|
+
GraphQL::RailsLogger.configure do |config|
|
33
|
+
config.white_list = {
|
33
34
|
'QueriesController' => %w(create)
|
34
35
|
}
|
36
|
+
end
|
37
|
+
```
|
38
|
+
|
39
|
+
There is an option to suppress (hide) the GraphQL Introspection Query from the console output. This may be helpful to declutter the console during client testing as these can be rather lengthy.
|
40
|
+
|
41
|
+
```ruby
|
42
|
+
GraphQL::RailsLogger.configure do |config|
|
43
|
+
config.skip_introspection_query = true
|
44
|
+
end
|
35
45
|
```
|
36
46
|
|
37
47
|
## Contributing
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module GraphQL
|
2
|
+
module RailsLogger
|
3
|
+
class Configuration
|
4
|
+
attr_accessor :skip_introspection_query, :white_list
|
5
|
+
|
6
|
+
def initialize
|
7
|
+
@skip_introspection_query = nil
|
8
|
+
|
9
|
+
# controller => [actions]
|
10
|
+
@white_list = {
|
11
|
+
'GraphqlController' => %w[execute]
|
12
|
+
}
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -3,11 +3,6 @@ require 'graphql/rails_logger/subscriber'
|
|
3
3
|
module GraphQL
|
4
4
|
module RailsLogger
|
5
5
|
class Railtie < Rails::Railtie
|
6
|
-
# Allowed controllers and actions
|
7
|
-
config.graphql_logger = {
|
8
|
-
'GraphqlController' => %w[execute]
|
9
|
-
}
|
10
|
-
|
11
6
|
initializer 'graphql.unsubscribe_default_logger' do
|
12
7
|
ActiveSupport::Notifications.unsubscribe 'start_processing.action_controller'
|
13
8
|
Subscriber.attach_to :action_controller
|
@@ -1,8 +1,21 @@
|
|
1
|
+
require 'graphql/rails_logger/configuration'
|
1
2
|
require 'action_controller/log_subscriber'
|
2
3
|
require 'rouge'
|
3
4
|
|
4
5
|
module GraphQL
|
5
6
|
module RailsLogger
|
7
|
+
class << self
|
8
|
+
attr_accessor :configuration
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.configuration
|
12
|
+
@configuration ||= Configuration.new
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.configure
|
16
|
+
yield(configuration)
|
17
|
+
end
|
18
|
+
|
6
19
|
class Subscriber < ActionController::LogSubscriber
|
7
20
|
def start_processing(event)
|
8
21
|
return unless logger.info?
|
@@ -12,14 +25,19 @@ module GraphQL
|
|
12
25
|
format = payload[:format]
|
13
26
|
format = format.to_s.upcase if format.is_a?(Symbol)
|
14
27
|
|
28
|
+
config = GraphQL::RailsLogger.configuration
|
29
|
+
|
15
30
|
info "Processing by #{payload[:controller]}##{payload[:action]} as #{format}"
|
16
31
|
|
17
|
-
if
|
32
|
+
if config.white_list.fetch(payload[:controller], []).include?(payload[:action])
|
18
33
|
formatter = Rouge::Formatters::Terminal256.new
|
19
34
|
query_lexer = Rouge::Lexers::GraphQL.new
|
20
35
|
variables_lexer = Rouge::Lexers::Ruby.new
|
21
36
|
|
22
37
|
(params['_json'] || [params.slice('query', 'variables')]).each do |data|
|
38
|
+
|
39
|
+
next if config.skip_introspection_query && data['query'].index(/query IntrospectionQuery/)
|
40
|
+
|
23
41
|
query = data['query'].lines.map { |line| " #{line}" }.join.chomp # add indentation
|
24
42
|
variables = PP.pp(data['variables'] || {}, '')
|
25
43
|
info " Variables: #{formatter.format(variables_lexer.lex(variables))}"
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: graphql-rails_logger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- JetRuby
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2018-01-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rouge
|
@@ -85,6 +85,7 @@ files:
|
|
85
85
|
- bin/setup
|
86
86
|
- graphql-rails_logger.gemspec
|
87
87
|
- lib/graphql/rails_logger.rb
|
88
|
+
- lib/graphql/rails_logger/configuration.rb
|
88
89
|
- lib/graphql/rails_logger/railtie.rb
|
89
90
|
- lib/graphql/rails_logger/subscriber.rb
|
90
91
|
- lib/graphql/rails_logger/version.rb
|