File tree Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Expand file tree Collapse file tree 2 files changed +33
-3
lines changed Original file line number Diff line number Diff line change @@ -46,9 +46,6 @@ def resolver
46
46
47
47
alias :mutation :resolver
48
48
49
- # @return [Array<Symbol>]
50
- attr_reader :extras
51
-
52
49
# @return [Boolean] Apply tracing to this field? (Default: skip scalars, this is the override value)
53
50
attr_reader :trace
54
51
@@ -318,6 +315,21 @@ def extension(extension, options = nil)
318
315
extensions ( [ { extension => options } ] )
319
316
end
320
317
318
+ # Read extras (as symbols) from this field,
319
+ # or add new extras to be opted into by this field's resolver.
320
+ #
321
+ # @param new_extras [Array<Symbol>] Add extras to this field
322
+ # @return [Array<Symbol>]
323
+ def extras ( new_extras = nil )
324
+ if new_extras . nil?
325
+ # Read the value
326
+ @extras
327
+ else
328
+ # Append to the set of extras on this field
329
+ @extras . concat ( new_extras )
330
+ end
331
+ end
332
+
321
333
def complexity ( new_complexity )
322
334
case new_complexity
323
335
when Proc
Original file line number Diff line number Diff line change 129
129
assert_equal "TRUE" , res [ "data" ] [ "upcaseCheck3" ]
130
130
assert_equal "\" WHY NOT?\" " , res [ "data" ] [ "upcaseCheck4" ]
131
131
end
132
+
133
+ it "can be read via #extras" do
134
+ field = Jazz ::Musician . fields [ "addError" ]
135
+ assert_equal [ :execution_errors ] , field . extras
136
+ end
137
+
138
+ it "can be added by passing an array of symbols to #extras" do
139
+ object = Class . new ( Jazz ::BaseObject ) do
140
+ graphql_name "JustAName"
141
+
142
+ field :test , String , null : true , extras : [ :lookahead ]
143
+ end
144
+
145
+ field = object . fields [ 'test' ]
146
+
147
+ field . extras ( [ :ast_node ] )
148
+ assert_equal [ :lookahead , :ast_node ] , field . extras
149
+ end
132
150
end
133
151
134
152
it "is the #owner of its arguments" do
You can’t perform that action at this time.
0 commit comments