graphql-rails_logger 1.2.2 → 1.2.3

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
  SHA256:
3
- metadata.gz: 40575fbb699f19b2d53ebc889e24e4faa81a7234260dc0bcee0e3c341384afa6
4
- data.tar.gz: 786acc0de584b668d66c88239bb3b567622e494f15ed83b53f2ccc9ec0ba421f
3
+ metadata.gz: ec122c5449dca8d9c4ad3cbfcf566b3fb326f3dda9e4ab873780a4789e716ae4
4
+ data.tar.gz: 37797d6232ce4e3befc9138d71a9fea3596d8b888f13917eb5221ef9c8709187
5
5
  SHA512:
6
- metadata.gz: 2bc6e83e96609f049f26e4086c38c0a9552a809bf991e3e6c9ad646d0949a7ed23b3f4e5738d075cfcdfe549d582c41af9c6b313dbf1fd0b7e7ce1269b7f213e
7
- data.tar.gz: 543404c254c0350335ece8b7107309000678dcd03dc14663f92020568f691927644c47a1c7795bb348c2464819469fecc0644176dbc6773f91755f2c1d89bb52
6
+ metadata.gz: 52b519e43fd717f8235ec0ab27014cacec433561560b87c17288e657d0109f71aae30ccd0966c7cd0cabca534c586d349030616a3f411a3fa188e490e161b1a7
7
+ data.tar.gz: 44f1c66f08bdfbdfd5f6089ebbe1e9e0a25dc5e26528e4c93dfe69e0beb75e1f413a5a249084bb584841fe977f1a8d9398b7d0478571fbe2ff38113e9f28faf9
@@ -16,8 +16,6 @@ Gem::Specification.new do |spec|
16
16
  spec.files = `git ls-files -z`.split("\x0").reject do |f|
17
17
  f.match(%r{^(test|spec|features)/})
18
18
  end
19
- spec.bindir = 'bin'
20
- spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
21
19
  spec.require_paths = ['lib']
22
20
 
23
21
  spec.add_dependency 'rouge', '~> 3.0'
@@ -35,19 +35,36 @@ module GraphQL
35
35
  query_lexer = Rouge::Lexers::GraphQL.new
36
36
  variables_lexer = Rouge::Lexers::Ruby.new
37
37
 
38
- (params['_json'] || [params.slice('query', 'variables')]).each do |data|
38
+ (params['_json'] || [params.slice('query', 'variables', 'extensions')]).each do |data|
39
39
 
40
40
  next if config.skip_introspection_query && data['query'].index(/query IntrospectionQuery/)
41
41
 
42
- query = data['query'].lines.map { |line| " #{line}" }.join.chomp # add indentation
43
- variables = PP.pp(data['variables'] || {}, '')
44
- info " Variables: #{formatter.format(variables_lexer.lex(variables))}"
45
- info formatter.format(query_lexer.lex(query))
42
+ # Cleanup and indent params for logging
43
+ query = indent(data.fetch('query', ''))
44
+ variables = indent(pretty(data.fetch('variables', '')))
45
+ extensions = indent(pretty(data.fetch('extensions', '')))
46
+
47
+ info "\nVariables:\n#{formatter.format(variables_lexer.lex(variables))}" if variables.present?
48
+ info "\nQuery:\n#{formatter.format(query_lexer.lex(query))}" if query.present?
49
+ info "\nExtensions:\n#{formatter.format(variables_lexer.lex(extensions))}" if extensions.present?
46
50
  end
47
51
  else
48
- info " Parameters: #{params.inspect}" unless params.empty?
52
+ info "\nParameters:\n#{params.inspect}" unless params.empty?
49
53
  end
50
54
  end
55
+
56
+ private
57
+
58
+ def indent(data)
59
+ data.lines.map { |line| " #{line}" }.join.chomp
60
+ end
61
+
62
+ def pretty(data)
63
+ return '' if data.blank?
64
+
65
+ data = JSON.parse(data) if data.is_a?(String)
66
+ PP.pp(data, '')
67
+ end
51
68
  end
52
69
  end
53
70
  end
@@ -1,5 +1,5 @@
1
1
  module GraphQL
2
2
  module RailsLogger
3
- VERSION = '1.2.2'.freeze
3
+ VERSION = '1.2.3'.freeze
4
4
  end
5
5
  end
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: 1.2.2
4
+ version: 1.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - JetRuby
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-21 00:00:00.000000000 Z
11
+ date: 2021-02-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rouge
@@ -97,9 +97,7 @@ dependencies:
97
97
  description: Display GraphQL queries in a more readable format.
98
98
  email:
99
99
  - engineering@jetruby.com
100
- executables:
101
- - console
102
- - setup
100
+ executables: []
103
101
  extensions: []
104
102
  extra_rdoc_files: []
105
103
  files:
@@ -123,7 +121,7 @@ homepage: https://github.com/jetruby/graphql-rails_logger
123
121
  licenses:
124
122
  - MIT
125
123
  metadata: {}
126
- post_install_message:
124
+ post_install_message:
127
125
  rdoc_options: []
128
126
  require_paths:
129
127
  - lib
@@ -138,9 +136,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
138
136
  - !ruby/object:Gem::Version
139
137
  version: '0'
140
138
  requirements: []
141
- rubyforge_project:
139
+ rubyforge_project:
142
140
  rubygems_version: 2.7.3
143
- signing_key:
141
+ signing_key:
144
142
  specification_version: 4
145
143
  summary: Pretty logger for Rails + GraphQL applications.
146
144
  test_files: []