graphql 0.19.3 → 0.19.4

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 (103) hide show
  1. checksums.yaml +4 -4
  2. data/lib/graphql/analysis/max_query_complexity.rb +1 -1
  3. data/lib/graphql/analysis/max_query_depth.rb +1 -1
  4. data/lib/graphql/boolean_type.rb +2 -2
  5. data/lib/graphql/define/instance_definable.rb +2 -2
  6. data/lib/graphql/enum_type.rb +3 -3
  7. data/lib/graphql/field.rb +6 -6
  8. data/lib/graphql/float_type.rb +2 -2
  9. data/lib/graphql/id_type.rb +2 -2
  10. data/lib/graphql/input_object_type.rb +1 -1
  11. data/lib/graphql/int_type.rb +2 -2
  12. data/lib/graphql/internal_representation/rewrite.rb +12 -12
  13. data/lib/graphql/introspection/arguments_field.rb +1 -1
  14. data/lib/graphql/introspection/enum_value_type.rb +1 -1
  15. data/lib/graphql/introspection/enum_values_field.rb +1 -1
  16. data/lib/graphql/introspection/field_type.rb +1 -1
  17. data/lib/graphql/introspection/fields_field.rb +1 -1
  18. data/lib/graphql/introspection/input_fields_field.rb +1 -1
  19. data/lib/graphql/introspection/input_value_type.rb +2 -2
  20. data/lib/graphql/introspection/interfaces_field.rb +1 -1
  21. data/lib/graphql/introspection/of_type_field.rb +1 -1
  22. data/lib/graphql/introspection/possible_types_field.rb +1 -1
  23. data/lib/graphql/introspection/schema_field.rb +1 -1
  24. data/lib/graphql/introspection/schema_type.rb +5 -5
  25. data/lib/graphql/introspection/type_by_name_field.rb +1 -1
  26. data/lib/graphql/introspection/type_type.rb +6 -6
  27. data/lib/graphql/introspection/typename_field.rb +1 -1
  28. data/lib/graphql/language.rb +1 -0
  29. data/lib/graphql/language/comments.rb +44 -0
  30. data/lib/graphql/language/definition_slice.rb +1 -1
  31. data/lib/graphql/language/generation.rb +35 -12
  32. data/lib/graphql/language/lexer.rb +29 -10
  33. data/lib/graphql/language/lexer.rl +25 -6
  34. data/lib/graphql/language/nodes.rb +30 -23
  35. data/lib/graphql/language/parser.rb +33 -14
  36. data/lib/graphql/language/parser.y +33 -14
  37. data/lib/graphql/language/parser_tests.rb +86 -2
  38. data/lib/graphql/language/token.rb +3 -2
  39. data/lib/graphql/language/visitor.rb +3 -3
  40. data/lib/graphql/object_type.rb +1 -1
  41. data/lib/graphql/query/arguments.rb +23 -2
  42. data/lib/graphql/query/serial_execution/field_resolution.rb +31 -14
  43. data/lib/graphql/relay/base_connection.rb +1 -3
  44. data/lib/graphql/relay/connection_type.rb +1 -1
  45. data/lib/graphql/relay/mutation.rb +1 -1
  46. data/lib/graphql/relay/relation_connection.rb +7 -3
  47. data/lib/graphql/scalar_type.rb +1 -1
  48. data/lib/graphql/schema.rb +19 -8
  49. data/lib/graphql/schema/loader.rb +2 -2
  50. data/lib/graphql/schema/printer.rb +63 -8
  51. data/lib/graphql/schema/timeout_middleware.rb +11 -11
  52. data/lib/graphql/schema/validation.rb +12 -12
  53. data/lib/graphql/static_validation/arguments_validator.rb +1 -1
  54. data/lib/graphql/static_validation/rules/directives_are_defined.rb +1 -1
  55. data/lib/graphql/static_validation/rules/directives_are_in_valid_locations.rb +1 -1
  56. data/lib/graphql/static_validation/rules/fields_are_defined_on_type.rb +1 -1
  57. data/lib/graphql/static_validation/rules/fields_have_appropriate_selections.rb +1 -1
  58. data/lib/graphql/static_validation/rules/fields_will_merge.rb +3 -2
  59. data/lib/graphql/static_validation/rules/fragment_spreads_are_possible.rb +3 -3
  60. data/lib/graphql/static_validation/rules/fragment_types_exist.rb +1 -1
  61. data/lib/graphql/static_validation/rules/fragments_are_finite.rb +9 -4
  62. data/lib/graphql/static_validation/rules/fragments_are_named.rb +1 -1
  63. data/lib/graphql/static_validation/rules/fragments_are_on_composite_types.rb +1 -1
  64. data/lib/graphql/static_validation/rules/fragments_are_used.rb +3 -3
  65. data/lib/graphql/static_validation/rules/mutation_root_exists.rb +1 -1
  66. data/lib/graphql/static_validation/rules/required_arguments_are_present.rb +2 -2
  67. data/lib/graphql/static_validation/rules/subscription_root_exists.rb +1 -1
  68. data/lib/graphql/static_validation/rules/variable_default_values_are_correctly_typed.rb +1 -1
  69. data/lib/graphql/static_validation/rules/variable_usages_are_allowed.rb +2 -2
  70. data/lib/graphql/static_validation/rules/variables_are_input_types.rb +1 -1
  71. data/lib/graphql/static_validation/rules/variables_are_used_and_defined.rb +6 -6
  72. data/lib/graphql/static_validation/type_stack.rb +2 -2
  73. data/lib/graphql/string_type.rb +2 -2
  74. data/lib/graphql/version.rb +1 -1
  75. data/readme.md +1 -1
  76. data/spec/graphql/analysis/analyze_query_spec.rb +3 -3
  77. data/spec/graphql/analysis/query_complexity_spec.rb +7 -7
  78. data/spec/graphql/introspection/directive_type_spec.rb +2 -2
  79. data/spec/graphql/introspection/introspection_query_spec.rb +26 -26
  80. data/spec/graphql/language/generation_spec.rb +137 -53
  81. data/spec/graphql/language/lexer_spec.rb +22 -0
  82. data/spec/graphql/language/visitor_spec.rb +6 -6
  83. data/spec/graphql/query/arguments_spec.rb +45 -1
  84. data/spec/graphql/query/context_spec.rb +4 -4
  85. data/spec/graphql/query/executor_spec.rb +1 -1
  86. data/spec/graphql/query/serial_execution/value_resolution_spec.rb +1 -1
  87. data/spec/graphql/relay/mutation_spec.rb +2 -2
  88. data/spec/graphql/relay/node_spec.rb +2 -2
  89. data/spec/graphql/relay/relation_connection_spec.rb +16 -0
  90. data/spec/graphql/schema/loader_spec.rb +2 -2
  91. data/spec/graphql/schema/middleware_chain_spec.rb +6 -6
  92. data/spec/graphql/schema/printer_spec.rb +268 -18
  93. data/spec/graphql/schema/rescue_middleware_spec.rb +1 -1
  94. data/spec/graphql/schema/timeout_middleware_spec.rb +2 -2
  95. data/spec/graphql/schema_spec.rb +2 -2
  96. data/spec/graphql/static_validation/rules/fragments_are_finite_spec.rb +13 -0
  97. data/spec/graphql/static_validation/rules/fragments_are_used_spec.rb +1 -1
  98. data/spec/graphql/static_validation/type_stack_spec.rb +1 -1
  99. data/spec/support/dairy_app.rb +25 -25
  100. data/spec/support/dairy_data.rb +2 -0
  101. data/spec/support/star_wars_data.rb +2 -1
  102. data/spec/support/star_wars_schema.rb +18 -18
  103. metadata +19 -2
@@ -41,74 +41,158 @@ describe GraphQL::Language::Generation do
41
41
  end
42
42
 
43
43
  describe "schema" do
44
- # From: https://github.com/graphql/graphql-js/blob/a725499b155285c2e33647a93393c82689b20b0f/src/language/__tests__/schema-kitchen-sink.graphql
45
- let(:query_string) {<<-schema
46
- schema {
47
- query: QueryType
48
- mutation: MutationType
44
+ describe "schema with convention names for root types" do
45
+ let(:query_string) {<<-schema
46
+ schema {
47
+ query: Query
48
+ mutation: Mutation
49
+ subscription: Subscription
50
+ }
51
+ schema
49
52
  }
50
53
 
51
- type Foo implements Bar {
52
- one: Type
53
- two(argument: InputType!): Type
54
- three(argument: InputType, other: String): Int
55
- four(argument: String = "string"): String
56
- five(argument: [String] = ["string", "string"]): String
57
- six(argument: InputType = {key: "value"}): Type
58
- }
54
+ it 'omits schema definition' do
55
+ refute document.to_query_string =~ /schema/
56
+ end
57
+ end
59
58
 
60
- type AnnotatedObject @onObject(arg: "value") {
61
- annotatedField(arg: Type = "default" @onArg): Type @onField
59
+ describe "schema with custom query root name" do
60
+ let(:query_string) {<<-schema
61
+ schema {
62
+ query: MyQuery
63
+ mutation: Mutation
64
+ subscription: Subscription
65
+ }
66
+ schema
62
67
  }
63
68
 
64
- interface Bar {
65
- one: Type
66
- four(argument: String = "string"): String
67
- }
69
+ it 'includes schema definition' do
70
+ assert_equal query_string.gsub(/^ /, "").strip, document.to_query_string
71
+ end
72
+ end
68
73
 
69
- interface AnnotatedInterface @onInterface {
70
- annotatedField(arg: Type @onArg): Type @onField
74
+ describe "schema with custom mutation root name" do
75
+ let(:query_string) {<<-schema
76
+ schema {
77
+ query: Query
78
+ mutation: MyMutation
79
+ subscription: Subscription
80
+ }
81
+ schema
71
82
  }
72
83
 
73
- union Feed = Story | Article | Advert
74
-
75
- union AnnotatedUnion @onUnion = A | B
76
-
77
- scalar CustomScalar
78
-
79
- scalar AnnotatedScalar @onScalar
80
-
81
- enum Site {
82
- DESKTOP
83
- MOBILE
84
- }
84
+ it 'includes schema definition' do
85
+ assert_equal query_string.gsub(/^ /, "").strip, document.to_query_string
86
+ end
87
+ end
85
88
 
86
- enum AnnotatedEnum @onEnum {
87
- ANNOTATED_VALUE @onEnumValue
88
- OTHER_VALUE
89
+ describe "schema with custom subscription root name" do
90
+ let(:query_string) {<<-schema
91
+ schema {
92
+ query: Query
93
+ mutation: Mutation
94
+ subscription: MySubscription
95
+ }
96
+ schema
89
97
  }
90
98
 
91
- input InputType {
92
- key: String!
93
- answer: Int = 42
94
- }
99
+ it 'includes schema definition' do
100
+ assert_equal query_string.gsub(/^ /, "").strip, document.to_query_string
101
+ end
102
+ end
95
103
 
96
- input AnnotatedInput @onInputObjectType {
97
- annotatedField: Type @onField
104
+ describe "full featured schema" do
105
+ # From: https://github.com/graphql/graphql-js/blob/a725499b155285c2e33647a93393c82689b20b0f/src/language/__tests__/schema-kitchen-sink.graphql
106
+ let(:query_string) {<<-schema
107
+ schema {
108
+ query: QueryType
109
+ mutation: MutationType
110
+ }
111
+
112
+ # Union description
113
+ union AnnotatedUnion @onUnion = A | B
114
+
115
+ type Foo implements Bar {
116
+ one: Type
117
+ two(argument: InputType!): Type
118
+ three(argument: InputType, other: String): Int
119
+ four(argument: String = "string"): String
120
+ five(argument: [String] = ["string", "string"]): String
121
+ six(argument: InputType = {key: "value"}): Type
122
+ }
123
+
124
+ # Scalar description
125
+ scalar CustomScalar
126
+
127
+ type AnnotatedObject @onObject(arg: "value") {
128
+ annotatedField(arg: Type = "default" @onArg): Type @onField
129
+ }
130
+
131
+ interface Bar {
132
+ one: Type
133
+ four(argument: String = "string"): String
134
+ }
135
+
136
+ # Enum description
137
+ enum Site {
138
+ # Enum value description
139
+ DESKTOP
140
+ MOBILE
141
+ }
142
+
143
+ interface AnnotatedInterface @onInterface {
144
+ annotatedField(arg: Type @onArg): Type @onField
145
+ }
146
+
147
+ union Feed = Story | Article | Advert
148
+
149
+ # Input description
150
+ input InputType {
151
+ key: String!
152
+ answer: Int = 42
153
+ }
154
+
155
+ union AnnotatedUnion @onUnion = A | B
156
+
157
+ scalar CustomScalar
158
+
159
+ # Directive description
160
+ directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
161
+
162
+ scalar AnnotatedScalar @onScalar
163
+
164
+ enum Site {
165
+ DESKTOP
166
+ MOBILE
167
+ }
168
+
169
+ enum AnnotatedEnum @onEnum {
170
+ ANNOTATED_VALUE @onEnumValue
171
+ OTHER_VALUE
172
+ }
173
+
174
+ input InputType {
175
+ key: String!
176
+ answer: Int = 42
177
+ }
178
+
179
+ input AnnotatedInput @onInputObjectType {
180
+ annotatedField: Type @onField
181
+ }
182
+
183
+ directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
184
+
185
+ directive @include(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
186
+ schema
98
187
  }
99
188
 
100
- directive @skip(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
101
-
102
- directive @include(if: Boolean!) on FIELD | FRAGMENT_SPREAD | INLINE_FRAGMENT
103
- schema
104
- }
105
-
106
- it "generate" do
107
- assert_equal query_string.gsub(/^ /, "").strip, document.to_query_string
108
- end
189
+ it "generate" do
190
+ assert_equal query_string.gsub(/^ /, "").strip, document.to_query_string
191
+ end
109
192
 
110
- it "doesn't mutate the document" do
111
- assert_equal document.to_query_string, document.to_query_string
193
+ it "doesn't mutate the document" do
194
+ assert_equal document.to_query_string, document.to_query_string
195
+ end
112
196
  end
113
197
  end
114
198
  end
@@ -0,0 +1,22 @@
1
+ require "spec_helper"
2
+
3
+ describe GraphQL::Language::Lexer do
4
+ subject { GraphQL::Language::Lexer }
5
+
6
+ describe ".tokenize" do
7
+ let(:query_string) {%|
8
+ {
9
+ query getCheese {
10
+ cheese(id: 1) {
11
+ ... cheeseFields
12
+ }
13
+ }
14
+ }
15
+ |}
16
+ let(:tokens) { subject.tokenize(query_string) }
17
+
18
+ it "keeps track of previous_token" do
19
+ assert_equal tokens[0], tokens[1].prev_token
20
+ end
21
+ end
22
+ end
@@ -19,13 +19,13 @@ describe GraphQL::Language::Visitor do
19
19
 
20
20
  let(:visitor) do
21
21
  v = GraphQL::Language::Visitor.new(document)
22
- v[GraphQL::Language::Nodes::Field] << -> (node, parent) { counts[:fields_entered] += 1 }
22
+ v[GraphQL::Language::Nodes::Field] << ->(node, parent) { counts[:fields_entered] += 1 }
23
23
  # two ways to set up enter hooks:
24
- v[GraphQL::Language::Nodes::Argument] << -> (node, parent) { counts[:argument_names] << node.name }
25
- v[GraphQL::Language::Nodes::Argument].enter << -> (node, parent) { counts[:arguments_entered] += 1}
26
- v[GraphQL::Language::Nodes::Argument].leave << -> (node, parent) { counts[:arguments_left] += 1 }
24
+ v[GraphQL::Language::Nodes::Argument] << ->(node, parent) { counts[:argument_names] << node.name }
25
+ v[GraphQL::Language::Nodes::Argument].enter << ->(node, parent) { counts[:arguments_entered] += 1}
26
+ v[GraphQL::Language::Nodes::Argument].leave << ->(node, parent) { counts[:arguments_left] += 1 }
27
27
 
28
- v[GraphQL::Language::Nodes::Document].leave << -> (node, parent) { counts[:finished] = true }
28
+ v[GraphQL::Language::Nodes::Document].leave << ->(node, parent) { counts[:finished] = true }
29
29
  v
30
30
  end
31
31
 
@@ -41,7 +41,7 @@ describe GraphQL::Language::Visitor do
41
41
 
42
42
  describe "Visitor::SKIP" do
43
43
  it "skips the rest of the node" do
44
- visitor[GraphQL::Language::Nodes::Document] << -> (node, parent) { GraphQL::Language::Visitor::SKIP }
44
+ visitor[GraphQL::Language::Nodes::Document] << ->(node, parent) { GraphQL::Language::Visitor::SKIP }
45
45
  visitor.visit
46
46
  assert_equal(0, counts[:fields_entered])
47
47
  end
@@ -45,6 +45,37 @@ describe GraphQL::Query::Arguments do
45
45
  assert_equal({ a: 1, b: 2, c: { d: 3, e: 4 } }, arguments.to_h)
46
46
  end
47
47
 
48
+ it "yields key, value, and arg_defnition" do
49
+ type_info = []
50
+ arguments.each_value do |arg_value|
51
+ value = arg_value.value.is_a?(GraphQL::Query::Arguments) ? arg_value.value.to_h : arg_value.value
52
+ type_info << [arg_value.key, value, arg_value.definition.type.unwrap.name]
53
+ end
54
+ expected_type_info =[
55
+ ["a", 1, "Int"],
56
+ ["b", 2, "Int"],
57
+ ["c", { d: 3, e: 4 }, "TestInput1"],
58
+ ]
59
+ assert_equal expected_type_info, type_info
60
+ end
61
+
62
+ it "can be copied to a new Arguments instance" do
63
+ transformed_args = {}
64
+ types = {}
65
+ arguments.each_value do |arg_value|
66
+ transformed_args[arg_value.key.upcase] = arg_value.value
67
+ types[arg_value.key.upcase] = arg_value.definition
68
+ end
69
+
70
+ new_arguments = GraphQL::Query::Arguments.new(transformed_args, argument_definitions: types)
71
+ expected_hash = {
72
+ "A" => 1,
73
+ "B" => 2,
74
+ "C" => { d: 3 , e: 4 },
75
+ }
76
+ assert_equal expected_hash, new_arguments.to_h
77
+ end
78
+
48
79
  describe "nested hashes" do
49
80
  let(:input_type) {
50
81
  test_input_type = GraphQL::InputObjectType.define do
@@ -64,6 +95,19 @@ describe GraphQL::Query::Arguments do
64
95
  end
65
96
  end
66
97
 
98
+ describe "#[]" do
99
+ it "returns the value at that key" do
100
+ assert_equal 1, arguments["a"]
101
+ assert_equal 1, arguments[:a]
102
+ assert arguments["c"].is_a?(GraphQL::Query::Arguments)
103
+ end
104
+
105
+ it "returns nil for missing keys" do
106
+ assert_equal nil, arguments["z"]
107
+ assert_equal nil, arguments[7]
108
+ end
109
+ end
110
+
67
111
  describe "#key?" do
68
112
  let(:arg_values) { [] }
69
113
  let(:schema) {
@@ -84,7 +128,7 @@ describe GraphQL::Query::Arguments do
84
128
  argument :b, types.Int, default_value: 2
85
129
  argument :c, types.Int
86
130
  argument :d, test_input_type
87
- resolve -> (obj, args, ctx) {
131
+ resolve ->(obj, args, ctx) {
88
132
  arg_values_array << args
89
133
  1
90
134
  }
@@ -5,16 +5,16 @@ describe GraphQL::Query::Context do
5
5
  name "Query"
6
6
  field :context, types.String do
7
7
  argument :key, !types.String
8
- resolve -> (target, args, ctx) { ctx[args[:key]] }
8
+ resolve ->(target, args, ctx) { ctx[args[:key]] }
9
9
  end
10
10
  field :contextAstNodeName, types.String do
11
- resolve -> (target, args, ctx) { ctx.ast_node.class.name }
11
+ resolve ->(target, args, ctx) { ctx.ast_node.class.name }
12
12
  end
13
13
  field :contextIrepNodeName, types.String do
14
- resolve -> (target, args, ctx) { ctx.irep_node.class.name }
14
+ resolve ->(target, args, ctx) { ctx.irep_node.class.name }
15
15
  end
16
16
  field :queryName, types.String do
17
- resolve -> (target, args, ctx) { ctx.query.class.name }
17
+ resolve ->(target, args, ctx) { ctx.query.class.name }
18
18
  end
19
19
  }}
20
20
  let(:schema) { GraphQL::Schema.define(query: query_type, mutation: nil)}
@@ -77,7 +77,7 @@ describe GraphQL::Query::Executor do
77
77
  name "Query"
78
78
  field :dairy do
79
79
  type DairyType
80
- resolve -> (t, a, c) {
80
+ resolve ->(t, a, c) {
81
81
  raise if resolved
82
82
  resolved = true
83
83
  DAIRY
@@ -46,7 +46,7 @@ describe GraphQL::Query::SerialExecution::ValueResolution do
46
46
  GraphQL::Schema.define do
47
47
  query(query_root)
48
48
  orphan_types [some_object]
49
- resolve_type -> (obj, ctx) do
49
+ resolve_type ->(obj, ctx) do
50
50
  if obj.is_a?(OtherObject)
51
51
  other_object
52
52
  else
@@ -22,7 +22,7 @@ describe GraphQL::Relay::Mutation do
22
22
 
23
23
  after do
24
24
  STAR_WARS_DATA["Ship"].delete("9")
25
- STAR_WARS_DATA["Faction"]["1"]["ships"].delete("9")
25
+ STAR_WARS_DATA["Faction"]["1"].ships.delete("9")
26
26
  end
27
27
 
28
28
  it "returns the result & clientMutationId" do
@@ -72,7 +72,7 @@ describe GraphQL::Relay::Mutation do
72
72
  GraphQL::Relay::Mutation.define do
73
73
  name "CustomReturnTypeTest"
74
74
  return_type custom_type
75
- resolve -> (input, ctx) {
75
+ resolve ->(input, ctx) {
76
76
  OpenStruct.new(name: "Custom Return Type Test")
77
77
  }
78
78
  end
@@ -11,11 +11,11 @@ describe GraphQL::Relay::Node do
11
11
  @previous_id_from_object_proc = StarWarsSchema.id_from_object_proc
12
12
  @previous_object_from_id_proc = StarWarsSchema.object_from_id_proc
13
13
 
14
- StarWarsSchema.id_from_object = -> (obj, type_name, ctx) {
14
+ StarWarsSchema.id_from_object = ->(obj, type_name, ctx) {
15
15
  "#{type_name}/#{obj.id}"
16
16
  }
17
17
 
18
- StarWarsSchema.object_from_id = -> (global_id, ctx) {
18
+ StarWarsSchema.object_from_id = ->(global_id, ctx) {
19
19
  type_name, id = global_id.split("/")
20
20
  STAR_WARS_DATA[type_name][id]
21
21
  }
@@ -345,4 +345,20 @@ describe GraphQL::Relay::RelationConnection do
345
345
  end
346
346
  end
347
347
  end
348
+
349
+ describe "#cursor_from_node" do
350
+ let(:connection) { GraphQL::Relay::RelationConnection.new(Base.where(faction_id: 1), {}) }
351
+
352
+ it "returns the cursor for a node in the connection" do
353
+ assert_equal "MQ==", connection.cursor_from_node(Base.all[0])
354
+ assert_equal "Mg==", connection.cursor_from_node(Base.all[1])
355
+ end
356
+
357
+ it "raises when the node isn't found" do
358
+ err = assert_raises(RuntimeError) {
359
+ connection.cursor_from_node(:not_found)
360
+ }
361
+ assert_includes err.message, "item not found"
362
+ end
363
+ end
348
364
  end
@@ -22,8 +22,8 @@ describe GraphQL::Schema::Loader do
22
22
 
23
23
  big_int_type = GraphQL::ScalarType.define do
24
24
  name "BigInt"
25
- coerce_input -> (value) { value =~ /\d+/ ? Integer(value) : nil }
26
- coerce_result -> (value) { value.to_s }
25
+ coerce_input ->(value) { value =~ /\d+/ ? Integer(value) : nil }
26
+ coerce_result ->(value) { value.to_s }
27
27
  end
28
28
 
29
29
  variant_input_type = GraphQL::InputObjectType.define do
@@ -1,9 +1,9 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe GraphQL::Schema::MiddlewareChain do
4
- let(:step_1) { -> (step_values, next_step) { step_values << 1; next_step.call } }
5
- let(:step_2) { -> (step_values, next_step) { step_values << 2; next_step.call } }
6
- let(:step_3) { -> (step_values, next_step) { step_values << 3; :return_value } }
4
+ let(:step_1) { ->(step_values, next_step) { step_values << 1; next_step.call } }
5
+ let(:step_2) { ->(step_values, next_step) { step_values << 2; next_step.call } }
6
+ let(:step_3) { ->(step_values, next_step) { step_values << 3; :return_value } }
7
7
  let(:steps) { [step_1, step_2, step_3] }
8
8
  let(:step_values) { [] }
9
9
  let(:arguments) { [step_values] }
@@ -20,7 +20,7 @@ describe GraphQL::Schema::MiddlewareChain do
20
20
  end
21
21
 
22
22
  describe "when a step returns early" do
23
- let(:early_return_step) { -> (step_values, next_step) { :early_return } }
23
+ let(:early_return_step) { ->(step_values, next_step) { :early_return } }
24
24
  it "doesn't continue the chain" do
25
25
  steps.insert(2, early_return_step)
26
26
  assert_equal(:early_return, middleware_chain.call)
@@ -30,8 +30,8 @@ describe GraphQL::Schema::MiddlewareChain do
30
30
 
31
31
  describe "when a step provides alternate arguments" do
32
32
  it "passes the new arguments to the next step" do
33
- step_1 = -> (test_arg, next_step) { assert_equal(test_arg, 'HELLO'); next_step.call(['WORLD']) }
34
- step_2 = -> (test_arg, next_step) { assert_equal(test_arg, 'WORLD'); test_arg }
33
+ step_1 = ->(test_arg, next_step) { assert_equal(test_arg, 'HELLO'); next_step.call(['WORLD']) }
34
+ step_2 = ->(test_arg, next_step) { assert_equal(test_arg, 'WORLD'); test_arg }
35
35
 
36
36
  chain = GraphQL::Schema::MiddlewareChain.new(steps: [step_1, step_2], arguments: ['HELLO'])
37
37
  result = chain.call