@@ -184,16 +184,12 @@ defmodule GraphQL.Execution.Executor do
184184
185185 @ spec complete_value ( % Interface { } , ExecutionContext . t , GraphQL.Document . t , any , any ) :: { ExecutionContext . t , map }
186186 defp complete_value ( % Interface { } = return_type , context , field_asts , info , result ) do
187- runtime_type = AbstractType . get_object_type ( return_type , result , info . schema )
188- { context , sub_field_asts } = collect_sub_fields ( context , runtime_type , field_asts )
189- execute_fields ( context , runtime_type , result , sub_field_asts . fields )
187+ complete_union_or_interface ( return_type , context , field_asts , info , result )
190188 end
191189
192190 @ spec complete_value ( % Union { } , ExecutionContext . t , GraphQL.Document . t , any , any ) :: { ExecutionContext . t , map }
193191 defp complete_value ( % Union { } = return_type , context , field_asts , info , result ) do
194- runtime_type = AbstractType . get_object_type ( return_type , result , info . schema )
195- { context , sub_field_asts } = collect_sub_fields ( context , runtime_type , field_asts )
196- execute_fields ( context , runtime_type , result , sub_field_asts . fields )
192+ complete_union_or_interface ( return_type , context , field_asts , info , result )
197193 end
198194
199195 @ spec complete_value ( % List { } , ExecutionContext . t , GraphQL.Document . t , any , any ) :: map
@@ -345,4 +341,10 @@ defmodule GraphQL.Execution.Executor do
345341
346342 defp unwrap_type ( type ) when is_atom ( type ) , do: type . type
347343 defp unwrap_type ( type ) , do: type
344+
345+ defp complete_union_or_interface ( return_type , context , field_asts , info , result ) do
346+ runtime_type = AbstractType . get_object_type ( return_type , result , info . schema )
347+ { context , sub_field_asts } = collect_sub_fields ( context , runtime_type , field_asts )
348+ execute_fields ( context , runtime_type , result , sub_field_asts . fields )
349+ end
348350end
0 commit comments