@@ -182,10 +182,6 @@ def values
182
182
end
183
183
end
184
184
185
- class GraphQLSelectionSet < Hash
186
- attr_accessor :graphql_directives
187
- end
188
-
189
185
# @return [GraphQL::Query]
190
186
attr_reader :query
191
187
@@ -280,7 +276,10 @@ def run_eager
280
276
st = get_current_runtime_state
281
277
st . current_object = query . root_value
282
278
st . current_result = selection_response
283
- directives = selections . respond_to? ( :graphql_directives ) ? selections . graphql_directives : nil
279
+ # This is a less-frequent case; use a fast check since it's often not there.
280
+ if ( directives = selections [ :graphql_directives ] )
281
+ selections . delete ( :graphql_directives )
282
+ end
284
283
call_method_on_directives ( :resolve , object_proxy , directives ) do
285
284
evaluate_selections (
286
285
object_proxy ,
@@ -326,8 +325,8 @@ def gather_selections(owner_object, owner_type, selections, selections_to_run =
326
325
else
327
326
# This is an InlineFragment or a FragmentSpread
328
327
if @runtime_directive_names . any? && node . directives . any? { |d | @runtime_directive_names . include? ( d . name ) }
329
- next_selections = GraphQLSelectionSet . new
330
- next_selections . graphql_directives = node . directives
328
+ next_selections = { }
329
+ next_selections [ : graphql_directives] = node . directives
331
330
if selections_to_run
332
331
selections_to_run << next_selections
333
332
else
@@ -810,7 +809,10 @@ def continue_field(value, owner_type, field, current_type, ast_node, next_select
810
809
st . current_result_name = nil
811
810
st . current_result = this_result
812
811
813
- directives = selections . respond_to? ( :graphql_directives ) ? selections . graphql_directives : nil
812
+ # This is a less-frequent case; use a fast check since it's often not there.
813
+ if ( directives = selections [ :graphql_directives ] )
814
+ selections . delete ( :graphql_directives )
815
+ end
814
816
call_method_on_directives ( :resolve , continue_value , directives ) do
815
817
evaluate_selections (
816
818
continue_value ,
0 commit comments