Skip to content

Commit 0ad1579

Browse files
committed
use concat, improve test
1 parent 1456da2 commit 0ad1579

File tree

2 files changed

+4
-6
lines changed

2 files changed

+4
-6
lines changed

lib/graphql/schema/field.rb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ def extensions(new_extensions = nil)
298298
# Add `extension` to this field, initialized with `options` if provided.
299299
# @param extension [Class] subclass of {Schema::Fieldextension}
300300
# @param options [Object] if provided, given as `options:` when initializing `extension`.
301-
def extension(extension, options = nil) # TODO: Do we want a single extra setter, like this too?
301+
def extension(extension, options = nil)
302302
extensions([{extension => options}])
303303
end
304304

@@ -313,9 +313,7 @@ def extras(new_extras = nil)
313313
@extras
314314
else
315315
# Append to the set of extras on this field
316-
new_extras.each do |new_extra|
317-
@extras << new_extra
318-
end
316+
@extras.concat(new_extras)
319317
end
320318
end
321319

spec/graphql/schema/field_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,13 +139,13 @@
139139
object = Class.new(Jazz::BaseObject) do
140140
graphql_name "JustAName"
141141

142-
field :test, String, null: true
142+
field :test, String, null: true, extras: [:lookahead]
143143
end
144144

145145
field = object.fields['test']
146146

147147
field.extras([:ast_node])
148-
assert_equal [:ast_node], field.extras
148+
assert_equal [:lookahead, :ast_node], field.extras
149149
end
150150
end
151151

0 commit comments

Comments
 (0)