graphql-metrics 3.0.0 → 4.0.1

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: 951dcb602534826881c09e30d3bbc37aa672aafb35aed258f9038d32b60db761
4
- data.tar.gz: 72893df9e0602d8e2ccea431bf8f9f93ebad5d770fe0c3efef82a386e6d8ae7d
3
+ metadata.gz: 45de407a0b5642ad74d27cdb4ab00635590a38d8b719fc448a3e94d6244d7daf
4
+ data.tar.gz: cae841292ce06f25031974127696594b426b41f469e4f7f74f37f1f3a8c8f521
5
5
  SHA512:
6
- metadata.gz: 0c882fcd0212576bef1cf956df63a71e8406b080f84db8ce349063707d684ec2c9c809a1a790f8c5b8065c5a92441a35dec63c2c9c1634b37483523f4cf366f8
7
- data.tar.gz: 598a1b7085197fac8ed3be9c57b701bef6518bd47d36ed001fe1f1520773a2ff8f2de8314ec35db15801cf6b64699b60f8286166539af35861f74751e35ae0d0
6
+ metadata.gz: 861b2728422d3f8c314024084497ef761c4ca83491f3967ccffa2d540ced0de524d318a380f7966b6555a539fd30ffdfaec83cafee42f020813875148434f734
7
+ data.tar.gz: 83bde1129c7492cd92ffc097e3072275f179262530a5fccbe6e61b5c485a08bb231a3af8e29ddf88a6f0f3cdfdf5bd7101f0266e042afe37d19232a07195d922
@@ -76,13 +76,6 @@ Style/BlockDelimiters:
76
76
  - proc
77
77
  - it
78
78
 
79
- Style/BracesAroundHashParameters:
80
- EnforcedStyle: no_braces
81
- SupportedStyles:
82
- - braces
83
- - no_braces
84
- - context_dependent
85
-
86
79
  Layout/CaseIndentation:
87
80
  EnforcedStyle: end
88
81
  SupportedStyles:
@@ -509,7 +502,7 @@ Style/WhileUntilModifier:
509
502
  Metrics/BlockNesting:
510
503
  Max: 3
511
504
 
512
- Metrics/LineLength:
505
+ Layout/LineLength:
513
506
  Max: 120
514
507
  AllowHeredoc: true
515
508
  AllowURI: true
@@ -1,3 +1,27 @@
1
+ 4.0.1
2
+ -----
3
+ - [24](https://github.com/Shopify/graphql-metrics/pull/24) Safely call `arguments_for` to handle arguments which may
4
+ raise `ExecutionError`s in their `prepare` methods.
5
+
6
+ 4.0.0
7
+ -----
8
+ - [23](https://github.com/Shopify/graphql-metrics/pull/23) graphql-ruby 1.10.8+ compatibility
9
+
10
+ 3.0.3
11
+ -----
12
+
13
+ - [#22](https://github.com/Shopify/graphql-metrics/pull/22) Optimization: use hash assignment over merge
14
+
15
+ 3.0.2
16
+ -----
17
+
18
+ - [#21](https://github.com/Shopify/graphql-metrics/pull/21) Optimize empty document check
19
+
20
+ 3.0.1
21
+ -----
22
+
23
+ Expand the range of graphql-ruby versions this gem is compatible with.
24
+
1
25
  3.0.0
2
26
  -----
3
27
 
@@ -1,9 +1,9 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- graphql-metrics (3.0.0)
4
+ graphql-metrics (4.0.1)
5
5
  concurrent-ruby (~> 1.1.0)
6
- graphql (~> 1.9.15)
6
+ graphql (>= 1.10.8)
7
7
 
8
8
  GEM
9
9
  remote: https://rubygems.org/
@@ -19,8 +19,8 @@ GEM
19
19
  diffy (3.3.0)
20
20
  fakeredis (0.7.0)
21
21
  redis (>= 3.2, < 5.0)
22
- graphql (1.9.16)
23
- graphql-batch (0.4.1)
22
+ graphql (1.10.8)
23
+ graphql-batch (0.4.2)
24
24
  graphql (>= 1.3, < 2)
25
25
  promise.rb (~> 0.7.2)
26
26
  hashdiff (1.0.0)
@@ -51,7 +51,6 @@ PLATFORMS
51
51
 
52
52
  DEPENDENCIES
53
53
  activesupport (~> 5.1.5)
54
- bundler (~> 2.0.2)
55
54
  diffy
56
55
  fakeredis
57
56
  graphql-batch
@@ -65,4 +64,4 @@ DEPENDENCIES
65
64
  rake
66
65
 
67
66
  BUNDLED WITH
68
- 2.0.2
67
+ 2.1.4
data/README.md CHANGED
@@ -172,9 +172,10 @@ class Schema < GraphQL::Schema
172
172
  use GraphQL::Execution::Interpreter # Required.
173
173
  use GraphQL::Analysis::AST # Required.
174
174
 
175
- instrument :query, GraphQL::Metrics::Instrumentation.new
176
175
  query_analyzer SimpleAnalyzer
177
- tracer GraphQL::Metrics::Tracer.new
176
+
177
+ instrument :query, GraphQL::Metrics::Instrumentation.new # Both of these are required if either is used.
178
+ tracer GraphQL::Metrics::Tracer.new # <-- Note!
178
179
 
179
180
  use GraphQL::Batch # Optional, but highly recommended. See https://github.com/Shopify/graphql-batch/.
180
181
  end
@@ -30,10 +30,8 @@ Gem::Specification.new do |spec|
30
30
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
31
31
  spec.require_paths = ["lib"]
32
32
 
33
+ spec.add_runtime_dependency "graphql", ">= 1.10.8"
33
34
  spec.add_runtime_dependency "concurrent-ruby", "~> 1.1.0"
34
- spec.add_runtime_dependency "graphql", "~> 1.9.15"
35
-
36
- spec.add_development_dependency "bundler", "~> 2.0.2"
37
35
  spec.add_development_dependency "rake", "~> 10.0"
38
36
  spec.add_development_dependency "minitest", "~> 5.0"
39
37
  spec.add_development_dependency 'graphql-batch'
@@ -35,14 +35,21 @@ module GraphQL
35
35
  return if visitor.field_definition.introspection?
36
36
  return if query.context[SKIP_FIELD_AND_ARGUMENT_METRICS]
37
37
 
38
- # NOTE: @rmosolgo "I think it could be reduced to `arguments = visitor.arguments_for(ast_node)`"
39
- arguments = visitor.arguments_for(node, visitor.field_definition)
40
- extract_arguments(arguments.argument_values.values, visitor.field_definition)
38
+ # Arguments can raise execution errors within their `prepare` methods
39
+ # which aren't properly handled during analysis so we have to handle
40
+ # them ourselves safely and return `nil`.
41
+ argument_values = begin
42
+ query.arguments_for(node, visitor.field_definition)
43
+ rescue ::GraphQL::ExecutionError
44
+ nil
45
+ end
46
+
47
+ extract_arguments(argument_values, visitor.field_definition) if argument_values
41
48
 
42
49
  static_metrics = {
43
50
  field_name: node.name,
44
- return_type_name: visitor.type_definition.name,
45
- parent_type_name: visitor.parent_type_definition.name,
51
+ return_type_name: visitor.type_definition.graphql_name,
52
+ parent_type_name: visitor.parent_type_definition.graphql_name,
46
53
  deprecated: visitor.field_definition.deprecation_reason.present?,
47
54
  path: visitor.response_path,
48
55
  }
@@ -61,14 +68,12 @@ module GraphQL
61
68
 
62
69
  @static_field_metrics.each do |static_metrics|
63
70
  resolver_timings = ns[GraphQL::Metrics::INLINE_FIELD_TIMINGS][static_metrics[:path]]
64
- lazy_field_timings = ns[GraphQL::Metrics::LAZY_FIELD_TIMINGS][static_metrics[:path]]
71
+ lazy_resolver_timings = ns[GraphQL::Metrics::LAZY_FIELD_TIMINGS][static_metrics[:path]]
65
72
 
66
- metrics = static_metrics.merge(
67
- resolver_timings: resolver_timings || [],
68
- lazy_resolver_timings: lazy_field_timings || [],
69
- )
73
+ static_metrics[:resolver_timings] = resolver_timings || []
74
+ static_metrics[:lazy_resolver_timings] = lazy_resolver_timings || []
70
75
 
71
- field_extracted(metrics)
76
+ field_extracted(static_metrics)
72
77
  end
73
78
  end
74
79
 
@@ -95,16 +100,16 @@ module GraphQL
95
100
  argument.each_value do |a|
96
101
  extract_arguments(a, field_defn, parent_input_object)
97
102
  end
98
- when ::GraphQL::Query::Arguments
103
+ when ::GraphQL::Execution::Interpreter::Arguments
99
104
  argument.each_value do |arg_val|
100
105
  extract_arguments(arg_val, field_defn, parent_input_object)
101
106
  end
102
- when ::GraphQL::Query::Arguments::ArgumentValue
107
+ when ::GraphQL::Execution::Interpreter::ArgumentValue
103
108
  extract_argument(argument, field_defn, parent_input_object)
104
109
  extract_arguments(argument.value, field_defn, parent_input_object)
105
110
  when ::GraphQL::Schema::InputObject
106
111
  input_object_argument_values = argument.arguments.argument_values.values
107
- parent_input_object = input_object_argument_values.first&.definition&.metadata&.fetch(:type_class, nil)&.owner
112
+ parent_input_object = input_object_argument_values.first&.definition&.owner
108
113
 
109
114
  extract_arguments(input_object_argument_values, field_defn, parent_input_object)
110
115
  end
@@ -112,10 +117,10 @@ module GraphQL
112
117
 
113
118
  def extract_argument(value, field_defn, parent_input_object = nil)
114
119
  static_metrics = {
115
- argument_name: value.definition.expose_as,
116
- argument_type_name: value.definition.type.unwrap.to_s,
117
- parent_field_name: field_defn.name,
118
- parent_field_type_name: field_defn.metadata[:type_class].owner.graphql_name,
120
+ argument_name: value.definition.graphql_name,
121
+ argument_type_name: value.definition.type.unwrap.graphql_name,
122
+ parent_field_name: field_defn.graphql_name,
123
+ parent_field_type_name: field_defn.owner.graphql_name,
119
124
  parent_input_object_type: parent_input_object&.graphql_name,
120
125
  default_used: value.default_used?,
121
126
  value_is_null: value.value.nil?,
@@ -47,7 +47,9 @@ module GraphQL
47
47
  private
48
48
 
49
49
  def query_present_and_valid?(query)
50
- query.valid? && query.document.to_query_string.present?
50
+ # Check for selected_operation as well for graphql 1.9 compatibility
51
+ # which did not reject "empty" documents in its parser.
52
+ query.valid? && !query.selected_operation.nil?
51
53
  end
52
54
  end
53
55
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GraphQL
4
4
  module Metrics
5
- VERSION = "3.0.0"
5
+ VERSION = "4.0.1"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,57 +1,43 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-metrics
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Butcher
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-03-11 00:00:00.000000000 Z
11
+ date: 2020-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: concurrent-ruby
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 1.1.0
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 1.1.0
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: graphql
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
- - - "~>"
17
+ - - ">="
32
18
  - !ruby/object:Gem::Version
33
- version: 1.9.15
19
+ version: 1.10.8
34
20
  type: :runtime
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
- - - "~>"
24
+ - - ">="
39
25
  - !ruby/object:Gem::Version
40
- version: 1.9.15
26
+ version: 1.10.8
41
27
  - !ruby/object:Gem::Dependency
42
- name: bundler
28
+ name: concurrent-ruby
43
29
  requirement: !ruby/object:Gem::Requirement
44
30
  requirements:
45
31
  - - "~>"
46
32
  - !ruby/object:Gem::Version
47
- version: 2.0.2
48
- type: :development
33
+ version: 1.1.0
34
+ type: :runtime
49
35
  prerelease: false
50
36
  version_requirements: !ruby/object:Gem::Requirement
51
37
  requirements:
52
38
  - - "~>"
53
39
  - !ruby/object:Gem::Version
54
- version: 2.0.2
40
+ version: 1.1.0
55
41
  - !ruby/object:Gem::Dependency
56
42
  name: rake
57
43
  requirement: !ruby/object:Gem::Requirement