graphql 1.10.12 → 1.10.13

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: 840c0d49f547bfb3a44878e0631df87f3b287179a077806169480a8d2820b30b
4
- data.tar.gz: 498c331da5d7f3818054def18b1a964f1ff97699b79b7be1635eefbad0dcc946
3
+ metadata.gz: 617464390cac424fae4c09fe3db0abbaa6e0d980cb349a9b8e51c4d84b2cb662
4
+ data.tar.gz: 4abf2fbac2606f6e8b493ca379a11569597500433bba51c8acbc7fdb891a3272
5
5
  SHA512:
6
- metadata.gz: 0cc7bdbeff9a1c70f28c50ffa93740020173a969d34e9aa8872073f721555ebe1c67fa74e13d012d6c547bc4aa6515ab7dafe173dd75bfdea9fe0c4a2b256ac8
7
- data.tar.gz: a466d22dd0e14f95b7273faedc68d3ff214e0f72411e491f454d037b1b74034a67b1eb6334cd567334cf5856c1b91e65a38024955426079c317c43eee47557c7
6
+ metadata.gz: de0cca8810127cf5649e68f6968e970131d7f34a0b1cd33230b79e56ae7e311134f96f588820caf273ef529c89e12a8df8c9afe213dbb9477cb798923044beb7
7
+ data.tar.gz: 30014092e85f256ace16b3635ed9e4e2c8a081904bca4e1e6197d0fff07f13d7997968ffc8aaee9de576d5372e219d432a8a62ae3406d81a61f9435debeaa247
@@ -166,10 +166,7 @@ module GraphQL
166
166
  return result
167
167
  end
168
168
 
169
- # We're not actually _using_ the coerced result, we're just
170
- # using these methods to make sure that the object will
171
- # behave like a hash below, when we call `each` on it.
172
- begin
169
+ input = begin
173
170
  input.to_h
174
171
  rescue
175
172
  begin
@@ -182,21 +179,25 @@ module GraphQL
182
179
  end
183
180
  end
184
181
 
185
- visible_arguments_map = warden.arguments(self).reduce({}) { |m, f| m[f.name] = f; m}
186
-
187
- # Items in the input that are unexpected
188
- input.each do |name, value|
189
- if visible_arguments_map[name].nil?
190
- result.add_problem("Field is not defined on #{self.graphql_name}", [name])
182
+ # Inject missing required arguments
183
+ missing_required_inputs = self.arguments.reduce({}) do |m, (argument_name, argument)|
184
+ if !input.key?(argument_name) && argument.type.non_null? && warden.get_argument(self, argument_name)
185
+ m[argument_name] = nil
191
186
  end
187
+
188
+ m
192
189
  end
193
190
 
194
- # Items in the input that are expected, but have invalid values
195
- visible_arguments_map.map do |name, argument|
196
- argument_result = argument.type.validate_input(input[name], ctx)
197
- if !argument_result.valid?
198
- result.merge_result!(name, argument_result)
191
+ input.merge(missing_required_inputs).each do |argument_name, value|
192
+ argument = warden.get_argument(self, argument_name)
193
+ # Items in the input that are unexpected
194
+ unless argument
195
+ result.add_problem("Field is not defined on #{self.graphql_name}", [argument_name])
196
+ next
199
197
  end
198
+ # Items in the input that are expected, but have invalid values
199
+ argument_result = argument.type.validate_input(value, ctx)
200
+ result.merge_result!(argument_name, argument_result) unless argument_result.valid?
200
201
  end
201
202
 
202
203
  result
@@ -58,6 +58,20 @@ module GraphQL
58
58
  end
59
59
  end
60
60
 
61
+ # @return [GraphQL::Schema::Argument, nil] Argument defined on this thing, fetched by name.
62
+ def get_argument(argument_name)
63
+ if (a = own_arguments[argument_name])
64
+ a
65
+ else
66
+ for ancestor in ancestors
67
+ if ancestor.respond_to?(:own_arguments) && a = ancestor.own_arguments[argument_name]
68
+ return a
69
+ end
70
+ end
71
+ nil
72
+ end
73
+ end
74
+
61
75
  # @param new_arg_class [Class] A class to use for building argument definitions
62
76
  def argument_class(new_arg_class = nil)
63
77
  self.class.argument_class(new_arg_class)
@@ -106,6 +106,12 @@ module GraphQL
106
106
  @visible_parent_fields[parent_type][field_name]
107
107
  end
108
108
 
109
+ # @return [GraphQL::Argument, nil] The argument named `argument_name` on `parent_type`, if it exists and is visible
110
+ def get_argument(parent_type, argument_name)
111
+ argument = parent_type.get_argument(argument_name)
112
+ return argument if argument && visible_argument?(argument)
113
+ end
114
+
109
115
  # @return [Array<GraphQL::BaseType>] The types which may be member of `type_defn`
110
116
  def possible_types(type_defn)
111
117
  @visible_possible_types ||= read_through { |type_defn|
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module GraphQL
4
+ module Tracing
5
+ class StatsdTracing < PlatformTracing
6
+ self.platform_keys = {
7
+ 'lex' => "graphql.lex",
8
+ 'parse' => "graphql.parse",
9
+ 'validate' => "graphql.validate",
10
+ 'analyze_query' => "graphql.analyze_query",
11
+ 'analyze_multiplex' => "graphql.analyze_multiplex",
12
+ 'execute_multiplex' => "graphql.execute_multiplex",
13
+ 'execute_query' => "graphql.execute_query",
14
+ 'execute_query_lazy' => "graphql.execute_query",
15
+ }
16
+
17
+ # @param statsd [Object] A statsd client
18
+ def initialize(statsd:, **rest)
19
+ @statsd = statsd
20
+ super(**rest)
21
+ end
22
+
23
+
24
+ def platform_trace(platform_key, key, data)
25
+ @statsd.time(platform_key) do
26
+ yield
27
+ end
28
+ end
29
+
30
+ def platform_field_key(type, field)
31
+ "graphql.#{type.graphql_name}.#{field.graphql_name}"
32
+ end
33
+
34
+ def platform_authorized_key(type)
35
+ "graphql.authorized.#{type.graphql_name}"
36
+ end
37
+
38
+ def platform_resolve_type_key(type)
39
+ "graphql.resolve_type.#{type.graphql_name}"
40
+ end
41
+ end
42
+ end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "1.10.12"
3
+ VERSION = "1.10.13"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.10.12
4
+ version: 1.10.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-13 00:00:00.000000000 Z
11
+ date: 2020-06-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips
@@ -696,6 +696,7 @@ files:
696
696
  - lib/graphql/tracing/prometheus_tracing/graphql_collector.rb
697
697
  - lib/graphql/tracing/scout_tracing.rb
698
698
  - lib/graphql/tracing/skylight_tracing.rb
699
+ - lib/graphql/tracing/statsd_tracing.rb
699
700
  - lib/graphql/type_kinds.rb
700
701
  - lib/graphql/types.rb
701
702
  - lib/graphql/types/big_int.rb