graphql 1.5.5 → 1.5.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. checksums.yaml +4 -4
  2. data/lib/graphql.rb +1 -2
  3. data/lib/graphql/analysis/query_complexity.rb +0 -1
  4. data/lib/graphql/argument.rb +43 -3
  5. data/lib/graphql/base_type.rb +50 -7
  6. data/lib/graphql/boolean_type.rb +2 -2
  7. data/lib/graphql/compatibility/execution_specification.rb +1 -1
  8. data/lib/graphql/compatibility/execution_specification/specification_schema.rb +2 -2
  9. data/lib/graphql/compatibility/lazy_execution_specification.rb +1 -1
  10. data/lib/graphql/enum_type.rb +35 -27
  11. data/lib/graphql/execution/execute.rb +3 -5
  12. data/lib/graphql/execution/lazy/lazy_method_map.rb +2 -2
  13. data/lib/graphql/float_type.rb +2 -2
  14. data/lib/graphql/function.rb +5 -0
  15. data/lib/graphql/id_type.rb +2 -2
  16. data/lib/graphql/input_object_type.rb +46 -36
  17. data/lib/graphql/int_type.rb +2 -2
  18. data/lib/graphql/introspection/input_value_type.rb +1 -1
  19. data/lib/graphql/list_type.rb +17 -17
  20. data/lib/graphql/non_null_type.rb +6 -11
  21. data/lib/graphql/query.rb +2 -2
  22. data/lib/graphql/query/literal_input.rb +15 -8
  23. data/lib/graphql/query/null_context.rb +29 -0
  24. data/lib/graphql/query/serial_execution/value_resolution.rb +2 -4
  25. data/lib/graphql/query/variables.rb +9 -7
  26. data/lib/graphql/relay/mutation.rb +6 -7
  27. data/lib/graphql/scalar_type.rb +54 -19
  28. data/lib/graphql/schema.rb +21 -5
  29. data/lib/graphql/schema/build_from_definition.rb +3 -1
  30. data/lib/graphql/schema/catchall_middleware.rb +1 -1
  31. data/lib/graphql/schema/default_type_error.rb +1 -1
  32. data/lib/graphql/schema/loader.rb +2 -2
  33. data/lib/graphql/schema/printer.rb +1 -1
  34. data/lib/graphql/schema/validation.rb +1 -2
  35. data/lib/graphql/static_validation/arguments_validator.rb +1 -1
  36. data/lib/graphql/static_validation/literal_validator.rb +5 -4
  37. data/lib/graphql/static_validation/rules/operation_names_are_valid.rb +1 -1
  38. data/lib/graphql/static_validation/validation_context.rb +1 -1
  39. data/lib/graphql/string_encoding_error.rb +10 -0
  40. data/lib/graphql/string_type.rb +8 -3
  41. data/lib/graphql/version.rb +1 -1
  42. data/spec/graphql/argument_spec.rb +13 -0
  43. data/spec/graphql/base_type_spec.rb +1 -1
  44. data/spec/graphql/boolean_type_spec.rb +1 -1
  45. data/spec/graphql/enum_type_spec.rb +11 -11
  46. data/spec/graphql/field_spec.rb +1 -1
  47. data/spec/graphql/float_type_spec.rb +4 -4
  48. data/spec/graphql/function_spec.rb +5 -4
  49. data/spec/graphql/input_object_type_spec.rb +28 -20
  50. data/spec/graphql/int_type_spec.rb +4 -4
  51. data/spec/graphql/language/lexer_spec.rb +0 -1
  52. data/spec/graphql/list_type_spec.rb +3 -3
  53. data/spec/graphql/query/literal_input_spec.rb +51 -0
  54. data/spec/graphql/query/variables_spec.rb +8 -4
  55. data/spec/graphql/relay/array_connection_spec.rb +1 -1
  56. data/spec/graphql/relay/page_info_spec.rb +1 -1
  57. data/spec/graphql/relay/relation_connection_spec.rb +3 -3
  58. data/spec/graphql/scalar_type_spec.rb +8 -8
  59. data/spec/graphql/schema/build_from_definition_spec.rb +2 -2
  60. data/spec/graphql/schema/loader_spec.rb +4 -4
  61. data/spec/graphql/string_type_spec.rb +33 -6
  62. data/spec/spec_helper.rb +0 -11
  63. data/spec/support/dummy/schema.rb +1 -1
  64. metadata +6 -2
@@ -105,6 +105,8 @@ module GraphQL
105
105
  raise InvalidDocumentError.new('Must provide schema definition with query type or a type named Query.') unless query_root_type
106
106
 
107
107
  Schema.define do
108
+ raise_definition_error true
109
+
108
110
  query query_root_type
109
111
  mutation mutation_root_type
110
112
  subscription subscription_root_type
@@ -119,7 +121,7 @@ module GraphQL
119
121
  raise(NotImplementedError, "Generated Schema cannot use Interface or Union types for execution.")
120
122
  }
121
123
 
122
- NullScalarCoerce = ->(val) { val }
124
+ NullScalarCoerce = ->(val, _ctx) { val }
123
125
 
124
126
  def build_enum_type(enum_type_definition, type_resolver)
125
127
  GraphQL::EnumType.define(
@@ -27,7 +27,7 @@ module GraphQL
27
27
  # whose message is {MESSAGE}
28
28
  def self.call(parent_type, parent_object, field_definition, field_args, query_context)
29
29
  yield
30
- rescue StandardError => err
30
+ rescue StandardError
31
31
  GraphQL::ExecutionError.new(MESSAGE)
32
32
  end
33
33
  end
@@ -6,7 +6,7 @@ module GraphQL
6
6
  case type_error
7
7
  when GraphQL::InvalidNullError
8
8
  ctx.errors << type_error
9
- when GraphQL::UnresolvedTypeError
9
+ when GraphQL::UnresolvedTypeError, GraphQL::StringEncodingError
10
10
  raise type_error
11
11
  end
12
12
  end
@@ -30,14 +30,14 @@ module GraphQL
30
30
  kargs[root] = types.fetch(type.fetch("name")) if type
31
31
  end
32
32
 
33
- Schema.define(**kargs)
33
+ Schema.define(**kargs, raise_definition_error: true)
34
34
  end
35
35
 
36
36
  NullResolveType = ->(obj, ctx) {
37
37
  raise(NotImplementedError, "This schema was loaded from string, so it can't resolve types for objects")
38
38
  }
39
39
 
40
- NullScalarCoerce = ->(val) { val }
40
+ NullScalarCoerce = ->(val, _ctx) { val }
41
41
 
42
42
  class << self
43
43
  private
@@ -218,7 +218,7 @@ module GraphQL
218
218
  value.to_s.inspect
219
219
  when EnumType
220
220
  return 'null' if value.nil?
221
- type.coerce_result(value)
221
+ type.coerce_isolated_result(value)
222
222
  when InputObjectType
223
223
  return 'null' if value.nil?
224
224
  fields = value.to_h.map{ |field_name, field_value|
@@ -39,7 +39,6 @@ module GraphQL
39
39
  def self.assert_property_mapping(property_name, from_class, to_class)
40
40
  ->(obj) {
41
41
  property_value = obj.public_send(property_name)
42
- error_message = nil
43
42
  if !property_value.is_a?(Hash)
44
43
  "#{property_name} must be a hash of {#{from_class.name} => #{to_class.name}}, not a #{property_value.class.name} (#{property_value.inspect})"
45
44
  else
@@ -105,7 +104,7 @@ module GraphQL
105
104
 
106
105
  if !type.default_value.nil?
107
106
  coerced_value = begin
108
- type.type.coerce_result(type.default_value)
107
+ type.type.coerce_isolated_result(type.default_value)
109
108
  rescue => ex
110
109
  ex
111
110
  end
@@ -33,7 +33,7 @@ module GraphQL
33
33
  private
34
34
 
35
35
  def parent_name(parent, type_defn)
36
- field_name = if parent.is_a?(GraphQL::Language::Nodes::Field)
36
+ if parent.is_a?(GraphQL::Language::Nodes::Field)
37
37
  parent.alias || parent.name
38
38
  elsif parent.is_a?(GraphQL::Language::Nodes::InputObject)
39
39
  type_defn.name
@@ -3,8 +3,9 @@ module GraphQL
3
3
  module StaticValidation
4
4
  # Test whether `ast_value` is a valid input for `type`
5
5
  class LiteralValidator
6
- def initialize(warden:)
7
- @warden = warden
6
+ def initialize(context:)
7
+ @context = context
8
+ @warden = context.warden
8
9
  end
9
10
 
10
11
  def validate(ast_value, type)
@@ -16,9 +17,9 @@ module GraphQL
16
17
  item_type = type.of_type
17
18
  ensure_array(ast_value).all? { |val| validate(val, item_type) }
18
19
  elsif type.kind.scalar? && !ast_value.is_a?(GraphQL::Language::Nodes::AbstractNode) && !ast_value.is_a?(Array)
19
- type.valid_input?(ast_value, @warden)
20
+ type.valid_input?(ast_value, @context)
20
21
  elsif type.kind.enum? && ast_value.is_a?(GraphQL::Language::Nodes::Enum)
21
- type.valid_input?(ast_value.name, @warden)
22
+ type.valid_input?(ast_value.name, @context)
22
23
  elsif type.kind.input_object? && ast_value.is_a?(GraphQL::Language::Nodes::InputObject)
23
24
  required_input_fields_are_present(type, ast_value) &&
24
25
  present_input_field_values_are_valid(type, ast_value)
@@ -12,7 +12,7 @@ module GraphQL
12
12
  }
13
13
 
14
14
  context.visitor[GraphQL::Language::Nodes::Document].leave << ->(node, _parent) {
15
- op_count = op_names.values.inject(0) { |m, v| m += v.size }
15
+ op_count = op_names.values.inject(0) { |m, v| m + v.size }
16
16
 
17
17
  op_names.each do |name, nodes|
18
18
  if name.nil? && op_count > 1
@@ -22,7 +22,7 @@ module GraphQL
22
22
 
23
23
  def initialize(query)
24
24
  @query = query
25
- @literal_validator = LiteralValidator.new(warden: warden)
25
+ @literal_validator = LiteralValidator.new(context: query.context)
26
26
  @errors = []
27
27
  @visitor = GraphQL::Language::Visitor.new(document)
28
28
  @type_stack = GraphQL::StaticValidation::TypeStack.new(schema, visitor)
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+ module GraphQL
3
+ class StringEncodingError < GraphQL::RuntimeTypeError
4
+ attr_reader :string
5
+ def initialize(str)
6
+ @string = str
7
+ super("String \"#{str}\" was encoded as #{str.encoding}! GraphQL requires UTF-8 encoding.")
8
+ end
9
+ end
10
+ end
@@ -3,11 +3,16 @@ GraphQL::STRING_TYPE = GraphQL::ScalarType.define do
3
3
  name "String"
4
4
  description "Represents textual data as UTF-8 character sequences. This type is most often used by GraphQL to represent free-form human-readable text."
5
5
 
6
- coerce_result ->(value) {
6
+ coerce_result ->(value, ctx) {
7
7
  str = value.to_s
8
- str.encoding == Encoding::US_ASCII || str.encoding == Encoding::UTF_8 ? str : nil
8
+ if str.encoding == Encoding::US_ASCII || str.encoding == Encoding::UTF_8
9
+ str
10
+ else
11
+ err = GraphQL::StringEncodingError.new(str)
12
+ ctx.schema.type_error(err, ctx)
13
+ end
9
14
  }
10
15
 
11
- coerce_input ->(value) { value.is_a?(String) ? value : nil }
16
+ coerce_input ->(value, _ctx) { value.is_a?(String) ? value : nil }
12
17
  default_scalar true
13
18
  end
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module GraphQL
3
- VERSION = "1.5.5"
3
+ VERSION = "1.5.6"
4
4
  end
@@ -57,4 +57,17 @@ describe GraphQL::Argument do
57
57
  assert_equal arg_3.expose_as, "ff"
58
58
  end
59
59
  end
60
+
61
+ describe "prepare" do
62
+ it "accepts a prepare proc and calls it to generate the prepared value" do
63
+ prepare_proc = Proc.new { |arg| arg + 1 }
64
+ argument = GraphQL::Argument.define(name: :plusOne, type: GraphQL::INT_TYPE, prepare: prepare_proc)
65
+ assert_equal argument.prepare(1), 2
66
+ end
67
+
68
+ it "returns the value itself if no prepare proc is provided" do
69
+ argument = GraphQL::Argument.define(name: :someNumber, type: GraphQL::INT_TYPE)
70
+ assert_equal argument.prepare(1), 1
71
+ end
72
+ end
60
73
  end
@@ -43,7 +43,7 @@ describe GraphQL::BaseType do
43
43
  obj_2 = obj_type.dup
44
44
  obj_2.name = "Cheese2"
45
45
  refute_equal obj_edge, obj_2.edge_type
46
- refute_equal obj_edge, obj_2.connection_type
46
+ refute_equal obj_conn, obj_2.connection_type
47
47
  end
48
48
  end
49
49
 
@@ -4,7 +4,7 @@ require "spec_helper"
4
4
  describe GraphQL::BOOLEAN_TYPE do
5
5
  describe "coerce_input" do
6
6
  def coerce_input(input)
7
- GraphQL::BOOLEAN_TYPE.coerce_input(input)
7
+ GraphQL::BOOLEAN_TYPE.coerce_isolated_input(input)
8
8
  end
9
9
 
10
10
  it "accepts true and false" do
@@ -5,34 +5,34 @@ describe GraphQL::EnumType do
5
5
  let(:enum) { Dummy::DairyAnimalEnum }
6
6
 
7
7
  it "coerces names to underlying values" do
8
- assert_equal("YAK", enum.coerce_input("YAK"))
9
- assert_equal(1, enum.coerce_input("COW"))
8
+ assert_equal("YAK", enum.coerce_isolated_input("YAK"))
9
+ assert_equal(1, enum.coerce_isolated_input("COW"))
10
10
  end
11
11
 
12
12
  it "coerces invalid names to nil" do
13
- assert_equal(nil, enum.coerce_input("YAKKITY"))
13
+ assert_equal(nil, enum.coerce_isolated_input("YAKKITY"))
14
14
  end
15
15
 
16
16
  it "coerces result values to value's value" do
17
- assert_equal("YAK", enum.coerce_result("YAK"))
18
- assert_equal("COW", enum.coerce_result(1))
19
- assert_equal("REINDEER", enum.coerce_result('reindeer'))
20
- assert_equal("DONKEY", enum.coerce_result(:donkey))
17
+ assert_equal("YAK", enum.coerce_isolated_result("YAK"))
18
+ assert_equal("COW", enum.coerce_isolated_result(1))
19
+ assert_equal("REINDEER", enum.coerce_isolated_result('reindeer'))
20
+ assert_equal("DONKEY", enum.coerce_isolated_result(:donkey))
21
21
  end
22
22
 
23
23
  it "raises when a result value can't be coerced" do
24
24
  assert_raises(GraphQL::EnumType::UnresolvedValueError) {
25
- enum.coerce_result(:nonsense)
25
+ enum.coerce_isolated_result(:nonsense)
26
26
  }
27
27
  end
28
28
 
29
29
  describe "resolving with a warden" do
30
30
  it "gets values from the warden" do
31
31
  # OK
32
- assert_equal("YAK", enum.coerce_result("YAK"))
32
+ assert_equal("YAK", enum.coerce_isolated_result("YAK"))
33
33
  # NOT OK
34
34
  assert_raises(GraphQL::EnumType::UnresolvedValueError) {
35
- enum.coerce_result("YAK", NothingWarden)
35
+ enum.coerce_result("YAK", OpenStruct.new(warden: NothingWarden))
36
36
  }
37
37
  end
38
38
  end
@@ -84,7 +84,7 @@ describe GraphQL::EnumType do
84
84
  end
85
85
 
86
86
  describe "validate_input with bad input" do
87
- let(:result) { enum.validate_input("bad enum", PermissiveWarden) }
87
+ let(:result) { enum.validate_isolated_input("bad enum") }
88
88
 
89
89
  it "returns an invalid result" do
90
90
  assert(!result.valid?)
@@ -90,7 +90,7 @@ describe GraphQL::Field do
90
90
  dummy_query.fields["symbol_name"] = invalid_field
91
91
 
92
92
  err = assert_raises(GraphQL::Schema::InvalidTypeError) {
93
- GraphQL::Schema.define(query: dummy_query)
93
+ GraphQL::Schema.define(query: dummy_query, raise_definition_error: true)
94
94
  }
95
95
  assert_equal "QueryType is invalid: field :symbol_name name must return String, not Symbol (:symbol_name)", err.message
96
96
  end
@@ -4,13 +4,13 @@ require "spec_helper"
4
4
  describe GraphQL::FLOAT_TYPE do
5
5
  describe "coerce_input" do
6
6
  it "accepts ints and floats" do
7
- assert_equal 1.0, GraphQL::FLOAT_TYPE.coerce_input(1)
8
- assert_equal 6.1, GraphQL::FLOAT_TYPE.coerce_input(6.1)
7
+ assert_equal 1.0, GraphQL::FLOAT_TYPE.coerce_isolated_input(1)
8
+ assert_equal 6.1, GraphQL::FLOAT_TYPE.coerce_isolated_input(6.1)
9
9
  end
10
10
 
11
11
  it "rejects other types" do
12
- assert_equal nil, GraphQL::FLOAT_TYPE.coerce_input("55")
13
- assert_equal nil, GraphQL::FLOAT_TYPE.coerce_input(true)
12
+ assert_equal nil, GraphQL::FLOAT_TYPE.coerce_isolated_input("55")
13
+ assert_equal nil, GraphQL::FLOAT_TYPE.coerce_isolated_input(true)
14
14
  end
15
15
  end
16
16
  end
@@ -4,6 +4,7 @@ require "spec_helper"
4
4
  describe GraphQL::Function do
5
5
  class TestFunc < GraphQL::Function
6
6
  argument :name, GraphQL::STRING_TYPE
7
+ argument :age, types.Int
7
8
  type do
8
9
  name "TestFuncPayload"
9
10
  field :name, types.String, hash_key: :name
@@ -20,7 +21,7 @@ describe GraphQL::Function do
20
21
  describe "function API" do
21
22
  it "exposes required info" do
22
23
  f = TestFunc.new
23
- assert_equal ["name"], f.arguments.keys
24
+ assert_equal ["name", "age"], f.arguments.keys
24
25
  assert_equal "TestFuncPayload", f.type.name
25
26
  assert_equal "Returns the string you give it", f.description
26
27
  assert_equal "It's useless", f.deprecation_reason
@@ -69,7 +70,7 @@ describe GraphQL::Function do
69
70
 
70
71
  it "gets attributes from the function" do
71
72
  field = schema.query.fields["test"]
72
- assert_equal ["name"], field.arguments.keys
73
+ assert_equal ["name", "age"], field.arguments.keys
73
74
  assert_equal "TestFuncPayload", field.type.name
74
75
  assert_equal "Returns the string you give it", field.description
75
76
  assert_equal "It's useless", field.deprecation_reason
@@ -115,14 +116,14 @@ describe GraphQL::Function do
115
116
  it "can override description" do
116
117
  field = schema.query.fields["blockOverride"]
117
118
  assert_equal "I have altered the description", field.description
118
- assert_equal ["name", "anArg", "oneMoreArg"], field.arguments.keys
119
+ assert_equal ["name", "age", "anArg", "oneMoreArg"], field.arguments.keys
119
120
  end
120
121
 
121
122
  it "can add to arguments" do
122
123
  field = schema.query.fields["argOverride"]
123
124
  assert_equal "New Description", field.description
124
125
  assert_equal GraphQL::STRING_TYPE, field.type
125
- assert_equal ["name"], field.arguments.keys
126
+ assert_equal ["name", "age"], field.arguments.keys
126
127
  end
127
128
  end
128
129
  end
@@ -26,18 +26,18 @@ describe GraphQL::InputObjectType do
26
26
  describe "input validation" do
27
27
  it "Accepts anything that yields key-value pairs to #all?" do
28
28
  values_obj = MinimumInputObject.new({"source" => "COW", "fatContent" => 0.4})
29
- assert input_object.valid_input?(values_obj, PermissiveWarden)
29
+ assert input_object.valid_isolated_input?(values_obj)
30
30
  end
31
31
 
32
32
  describe "validate_input with non-enumerable input" do
33
33
  it "returns a valid result for MinimumInputObject" do
34
- result = input_object.validate_input(MinimumInputObject.new({"source" => "COW", "fatContent" => 0.4}), PermissiveWarden)
34
+ result = input_object.validate_isolated_input(MinimumInputObject.new({"source" => "COW", "fatContent" => 0.4}))
35
35
  assert(result.valid?)
36
36
  end
37
37
 
38
38
  it "returns an invalid result for MinimumInvalidInputObject" do
39
39
  invalid_input = MinimumInputObject.new({"source" => "KOALA", "fatContent" => 0.4})
40
- result = input_object.validate_input(invalid_input, PermissiveWarden)
40
+ result = input_object.validate_isolated_input(invalid_input)
41
41
  assert(!result.valid?)
42
42
  end
43
43
  end
@@ -57,13 +57,13 @@ describe GraphQL::InputObjectType do
57
57
 
58
58
  it "returns an invalid result when value is null for non-null argument" do
59
59
  invalid_input = MinimumInputObject.new({"a" => "Test", "b" => nil})
60
- result = input_type.validate_input(invalid_input, PermissiveWarden)
60
+ result = input_type.validate_isolated_input(invalid_input)
61
61
  assert(!result.valid?)
62
62
  end
63
63
 
64
64
  it "returns valid result when value is null for nullable argument" do
65
65
  invalid_input = MinimumInputObject.new({"a" => nil, "b" => 1})
66
- result = input_type.validate_input(invalid_input, PermissiveWarden)
66
+ result = input_type.validate_isolated_input(invalid_input)
67
67
  assert(result.valid?)
68
68
  end
69
69
  end
@@ -76,7 +76,7 @@ describe GraphQL::InputObjectType do
76
76
  "fatContent" => 0.4
77
77
  }
78
78
  end
79
- let(:result) { input_object.validate_input(input, PermissiveWarden) }
79
+ let(:result) { input_object.validate_isolated_input(input) }
80
80
 
81
81
  it "returns a valid result" do
82
82
  assert(result.valid?)
@@ -91,7 +91,7 @@ describe GraphQL::InputObjectType do
91
91
  "fatContent" => 0.4,
92
92
  )
93
93
  end
94
- let(:result) { input_object.validate_input(input, PermissiveWarden) }
94
+ let(:result) { input_object.validate_isolated_input(input) }
95
95
 
96
96
  it "returns a valid result" do
97
97
  assert(result.valid?)
@@ -100,7 +100,7 @@ describe GraphQL::InputObjectType do
100
100
  end
101
101
 
102
102
  describe "with bad enum and float" do
103
- let(:result) { input_object.validate_input({"source" => "KOALA", "fatContent" => "bad_num"}, PermissiveWarden) }
103
+ let(:result) { input_object.validate_isolated_input({"source" => "KOALA", "fatContent" => "bad_num"}) }
104
104
 
105
105
  it "returns an invalid result" do
106
106
  assert(!result.valid?)
@@ -113,7 +113,7 @@ describe GraphQL::InputObjectType do
113
113
  end
114
114
 
115
115
  it "has correct problem explanation" do
116
- expected = Dummy::DairyAnimalEnum.validate_input("KOALA", PermissiveWarden).problems[0]["explanation"]
116
+ expected = Dummy::DairyAnimalEnum.validate_isolated_input("KOALA").problems[0]["explanation"]
117
117
 
118
118
  source_problem = result.problems.detect { |p| p["path"] == ["source"] }
119
119
  actual = source_problem["explanation"]
@@ -123,7 +123,7 @@ describe GraphQL::InputObjectType do
123
123
  end
124
124
 
125
125
  describe 'with a string as input' do
126
- let(:result) { input_object.validate_input("just a string", PermissiveWarden) }
126
+ let(:result) { input_object.validate_isolated_input("just a string") }
127
127
 
128
128
  it "returns an invalid result" do
129
129
  assert(!result.valid?)
@@ -140,7 +140,7 @@ describe GraphQL::InputObjectType do
140
140
  end
141
141
 
142
142
  describe 'with an array as input' do
143
- let(:result) { input_object.validate_input(["string array"], PermissiveWarden) }
143
+ let(:result) { input_object.validate_isolated_input(["string array"]) }
144
144
 
145
145
  it "returns an invalid result" do
146
146
  assert(!result.valid?)
@@ -157,7 +157,7 @@ describe GraphQL::InputObjectType do
157
157
  end
158
158
 
159
159
  describe 'with a int as input' do
160
- let(:result) { input_object.validate_input(10, PermissiveWarden) }
160
+ let(:result) { input_object.validate_isolated_input(10) }
161
161
 
162
162
  it "returns an invalid result" do
163
163
  assert(!result.valid?)
@@ -174,7 +174,7 @@ describe GraphQL::InputObjectType do
174
174
  end
175
175
 
176
176
  describe "with extra argument" do
177
- let(:result) { input_object.validate_input({"source" => "COW", "fatContent" => 0.4, "isDelicious" => false}, PermissiveWarden) }
177
+ let(:result) { input_object.validate_isolated_input({"source" => "COW", "fatContent" => 0.4, "isDelicious" => false}) }
178
178
 
179
179
  it "returns an invalid result" do
180
180
  assert(!result.valid?)
@@ -193,10 +193,10 @@ describe GraphQL::InputObjectType do
193
193
  describe "list with one invalid element" do
194
194
  let(:list_type) { GraphQL::ListType.new(of_type: Dummy::DairyProductInputType) }
195
195
  let(:result) do
196
- list_type.validate_input([
196
+ list_type.validate_isolated_input([
197
197
  { "source" => "COW", "fatContent" => 0.4 },
198
198
  { "source" => "KOALA", "fatContent" => 0.4 }
199
- ], PermissiveWarden)
199
+ ])
200
200
  end
201
201
 
202
202
  it "returns an invalid result" do
@@ -213,7 +213,7 @@ describe GraphQL::InputObjectType do
213
213
  end
214
214
 
215
215
  it "has problem with correct explanation" do
216
- expected = Dummy::DairyAnimalEnum.validate_input("KOALA", PermissiveWarden).problems[0]["explanation"]
216
+ expected = Dummy::DairyAnimalEnum.validate_isolated_input("KOALA").problems[0]["explanation"]
217
217
  actual = result.problems[0]["explanation"]
218
218
  assert_equal(expected, actual)
219
219
  end
@@ -223,7 +223,7 @@ describe GraphQL::InputObjectType do
223
223
 
224
224
  describe "coerce_result" do
225
225
  it "omits unspecified arguments" do
226
- result = input_object.coerce_result(fatContent: 0.3)
226
+ result = input_object.coerce_isolated_result({fatContent: 0.3})
227
227
  assert_equal ["fatContent"], result.keys
228
228
  assert_equal 0.3, result["fatContent"]
229
229
  end
@@ -239,13 +239,14 @@ describe GraphQL::InputObjectType do
239
239
  a: String
240
240
  b: Int!
241
241
  c: String = "Default"
242
+ d: Boolean = false
242
243
  }
243
244
  |) }
244
245
  let(:input_type) { schema.types['ExampleInputObject'] }
245
246
 
246
247
  it "null values are returned in coerced input" do
247
248
  input = MinimumInputObject.new({"a" => "Test", "b" => nil,"c" => "Test"})
248
- result = input_type.coerce_input(input)
249
+ result = input_type.coerce_isolated_input(input)
249
250
 
250
251
  assert_equal 'Test', result['a']
251
252
 
@@ -257,7 +258,7 @@ describe GraphQL::InputObjectType do
257
258
 
258
259
  it "null values are preserved when argument has a default value" do
259
260
  input = MinimumInputObject.new({"a" => "Test", "b" => 1, "c" => nil})
260
- result = input_type.coerce_input(input)
261
+ result = input_type.coerce_isolated_input(input)
261
262
 
262
263
  assert_equal 'Test', result['a']
263
264
  assert_equal 1, result['b']
@@ -268,12 +269,19 @@ describe GraphQL::InputObjectType do
268
269
 
269
270
  it "omitted arguments are not returned" do
270
271
  input = MinimumInputObject.new({"b" => 1, "c" => "Test"})
271
- result = input_type.coerce_input(input)
272
+ result = input_type.coerce_isolated_input(input)
272
273
 
273
274
  assert !result.key?('a')
274
275
  assert_equal 1, result['b']
275
276
  assert_equal 'Test', result['c']
276
277
  end
278
+
279
+ it "false default values are returned" do
280
+ input = MinimumInputObject.new({"b" => 1})
281
+ result = input_type.coerce_isolated_input(input)
282
+
283
+ assert_equal false, result['d']
284
+ end
277
285
  end
278
286
 
279
287
  describe "when sent into a query" do