@@ -343,12 +343,8 @@ def gather_selections(owner_object, owner_type, selections, selections_to_run =
343343 if node . type
344344 type_defn = schema . get_type ( node . type . name , context )
345345
346- # Faster than .map{}.include?()
347- query . warden . possible_types ( type_defn ) . each do |t |
348- if t == owner_type
349- gather_selections ( owner_object , owner_type , node . selections , selections_to_run , next_selections )
350- break
351- end
346+ if query . warden . possible_types ( type_defn ) . include? ( owner_type )
347+ gather_selections ( owner_object , owner_type , node . selections , selections_to_run , next_selections )
352348 end
353349 else
354350 # it's an untyped fragment, definitely continue
@@ -357,12 +353,8 @@ def gather_selections(owner_object, owner_type, selections, selections_to_run =
357353 when GraphQL ::Language ::Nodes ::FragmentSpread
358354 fragment_def = query . fragments [ node . name ]
359355 type_defn = query . get_type ( fragment_def . type . name )
360- possible_types = query . warden . possible_types ( type_defn )
361- possible_types . each do |t |
362- if t == owner_type
363- gather_selections ( owner_object , owner_type , fragment_def . selections , selections_to_run , next_selections )
364- break
365- end
356+ if query . warden . possible_types ( type_defn ) . include? ( owner_type )
357+ gather_selections ( owner_object , owner_type , fragment_def . selections , selections_to_run , next_selections )
366358 end
367359 else
368360 raise "Invariant: unexpected selection class: #{ node . class } "
0 commit comments