graphql 1.10.13 → 1.10.14

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: 617464390cac424fae4c09fe3db0abbaa6e0d980cb349a9b8e51c4d84b2cb662
4
- data.tar.gz: 4abf2fbac2606f6e8b493ca379a11569597500433bba51c8acbc7fdb891a3272
3
+ metadata.gz: e1d76918804bdeeba0c80bbcfcdde70d04132110aee8e4520dcba8480da390fc
4
+ data.tar.gz: c0e1954ae3f6d18bf03fc33807b94d482b83b4e4a6f8a392452e2f6e8297f241
5
5
  SHA512:
6
- metadata.gz: de0cca8810127cf5649e68f6968e970131d7f34a0b1cd33230b79e56ae7e311134f96f588820caf273ef529c89e12a8df8c9afe213dbb9477cb798923044beb7
7
- data.tar.gz: 30014092e85f256ace16b3635ed9e4e2c8a081904bca4e1e6197d0fff07f13d7997968ffc8aaee9de576d5372e219d432a8a62ae3406d81a61f9435debeaa247
6
+ metadata.gz: 3e945033f8657c252fcd99a18d4be5c9d267535753e88a94f3b589c968ca186e90f3368768ff2f3f7c7e1eff7a210bf57694bde763255ee0a91f1e46534b0b4d
7
+ data.tar.gz: de56338439eeb22b8484033c5acfb4ac027edee60ac30218c8a7516c5bc6d4bfa07b8be54ebd42a63fca5decdfbbcf85e4b96832bb8d7fcd304dc2fb98bc7625
@@ -99,6 +99,10 @@ module GraphQL
99
99
  def type_class
100
100
  metadata[:type_class]
101
101
  end
102
+
103
+ def get_argument(argument_name)
104
+ arguments[argument_name]
105
+ end
102
106
  end
103
107
  end
104
108
 
@@ -460,8 +460,9 @@ module GraphQL
460
460
  end
461
461
 
462
462
  def arguments(graphql_object, arg_owner, ast_node)
463
- # Don't cache arguments if field extras are requested since extras mutate the argument data structure
464
- if arg_owner.arguments_statically_coercible? && (!arg_owner.is_a?(GraphQL::Schema::Field) || arg_owner.extras.empty?)
463
+ # Don't cache arguments if field extras or extensions are requested since they can mutate the argument data structure
464
+ if arg_owner.arguments_statically_coercible? &&
465
+ (!arg_owner.is_a?(GraphQL::Schema::Field) || (arg_owner.extras.empty? && arg_owner.extensions.empty?))
465
466
  query.arguments_for(ast_node, arg_owner)
466
467
  else
467
468
  # The arguments must be prepared in the context of the given object
@@ -207,6 +207,10 @@ module GraphQL
207
207
  metadata[:type_class]
208
208
  end
209
209
 
210
+ def get_argument(argument_name)
211
+ arguments[argument_name]
212
+ end
213
+
210
214
  private
211
215
 
212
216
  def build_default_resolver
@@ -58,6 +58,10 @@ module GraphQL
58
58
  result
59
59
  end
60
60
 
61
+ def get_argument(argument_name)
62
+ arguments[argument_name]
63
+ end
64
+
61
65
  private
62
66
 
63
67
  def coerce_non_null_input(value, ctx)
@@ -60,7 +60,9 @@ module GraphQL
60
60
 
61
61
  # @return [GraphQL::Schema::Argument, nil] Argument defined on this thing, fetched by name.
62
62
  def get_argument(argument_name)
63
- if (a = own_arguments[argument_name])
63
+ a = own_arguments[argument_name]
64
+
65
+ if a || !self.is_a?(Class)
64
66
  a
65
67
  else
66
68
  for ancestor in ancestors
@@ -95,16 +95,17 @@ module GraphQL
95
95
  def required_input_fields_are_present(type, ast_node)
96
96
  # TODO - would be nice to use these to create an error message so the caller knows
97
97
  # that required fields are missing
98
- required_field_names = @warden.arguments(type)
99
- .select { |f| f.type.kind.non_null? }
98
+ required_field_names = type.arguments.each_value
99
+ .select { |argument| argument.type.kind.non_null? && @warden.get_argument(type, argument.name) }
100
100
  .map(&:name)
101
+
101
102
  present_field_names = ast_node.arguments.map(&:name)
102
103
  missing_required_field_names = required_field_names - present_field_names
103
104
  if @context.schema.error_bubbling
104
105
  missing_required_field_names.empty? ? @valid_response : @invalid_response
105
106
  else
106
107
  results = missing_required_field_names.map do |name|
107
- arg_type = @warden.arguments(type).find { |f| f.name == name }.type
108
+ arg_type = @warden.get_argument(type, name).type
108
109
  recursively_validate(GraphQL::Language::Nodes::NullValue.new(name: name), arg_type)
109
110
  end
110
111
  merge_results(results)
@@ -112,13 +113,12 @@ module GraphQL
112
113
  end
113
114
 
114
115
  def present_input_field_values_are_valid(type, ast_node)
115
- field_map = @warden.arguments(type).reduce({}) { |m, f| m[f.name] = f; m}
116
116
  results = ast_node.arguments.map do |value|
117
- field = field_map[value.name]
117
+ field = @warden.get_argument(type, value.name)
118
118
  # we want to call validate on an argument even if it's an invalid one
119
119
  # so that our raise exception is on it instead of the entire InputObject
120
- type = field && field.type
121
- recursively_validate(value.value, type)
120
+ field_type = field && field.type
121
+ recursively_validate(value.value, field_type)
122
122
  end
123
123
  merge_results(results)
124
124
  end
@@ -5,7 +5,7 @@ module GraphQL
5
5
  def on_argument(node, parent)
6
6
  parent_defn = parent_definition(parent)
7
7
 
8
- if parent_defn && context.warden.arguments(parent_defn).any? { |arg| arg.name == node.name }
8
+ if parent_defn && context.warden.get_argument(parent_defn, node.name)
9
9
  super
10
10
  elsif parent_defn
11
11
  kind_of_node = node_type(parent)
@@ -17,8 +17,8 @@ module GraphQL
17
17
 
18
18
  def assert_required_args(ast_node, defn)
19
19
  present_argument_names = ast_node.arguments.map(&:name)
20
- required_argument_names = context.warden.arguments(defn)
21
- .select { |a| a.type.kind.non_null? && !a.default_value? }
20
+ required_argument_names = defn.arguments.each_value
21
+ .select { |a| a.type.kind.non_null? && !a.default_value? && context.warden.get_argument(defn, a.name) }
22
22
  .map(&:name)
23
23
 
24
24
  missing_names = required_argument_names - present_argument_names
@@ -26,8 +26,7 @@ module GraphQL
26
26
  context.field_definition
27
27
  end
28
28
 
29
- parent_type = context.warden.arguments(defn)
30
- .find{|f| f.name == parent_name(parent, defn) }
29
+ parent_type = context.warden.get_argument(defn, parent_name(parent, defn))
31
30
  parent_type ? parent_type.type.unwrap : nil
32
31
  end
33
32
 
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "1.10.13"
3
+ VERSION = "1.10.14"
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.13
4
+ version: 1.10.14
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-16 00:00:00.000000000 Z
11
+ date: 2020-06-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips
@@ -696,7 +696,6 @@ 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
700
699
  - lib/graphql/type_kinds.rb
701
700
  - lib/graphql/types.rb
702
701
  - lib/graphql/types/big_int.rb
@@ -1,42 +0,0 @@
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