@@ -890,7 +890,6 @@ def minimal_after_lazy(value, &block)
890890 # @return [GraphQL::Execution::Lazy, Object] If loading `object` will be deferred, it's a wrapper over it.
891891 def after_lazy ( lazy_obj , field :, owner_object :, arguments :, ast_node :, result :, result_name :, eager : false , runtime_state :, trace : true , &block )
892892 if lazy? ( lazy_obj )
893- orig_result = result
894893 was_authorized_by_scope_items = runtime_state . was_authorized_by_scope_items
895894 lazy = GraphQL ::Execution ::Lazy . new ( field : field ) do
896895 # This block might be called in a new fiber;
@@ -900,13 +899,13 @@ def after_lazy(lazy_obj, field:, owner_object:, arguments:, ast_node:, result:,
900899 runtime_state . current_field = field
901900 runtime_state . current_arguments = arguments
902901 runtime_state . current_result_name = result_name
903- runtime_state . current_result = orig_result
902+ runtime_state . current_result = result
904903 runtime_state . was_authorized_by_scope_items = was_authorized_by_scope_items
905904 # Wrap the execution of _this_ method with tracing,
906905 # but don't wrap the continuation below
907- result = nil
906+ sync_result = nil
908907 inner_obj = begin
909- result = if trace
908+ sync_result = if trace
910909 @current_trace . begin_execute_field ( field , owner_object , arguments , query )
911910 @current_trace . execute_field_lazy ( field : field , query : query , object : owner_object , arguments : arguments , ast_node : ast_node ) do
912911 schema . sync_lazy ( lazy_obj )
@@ -924,7 +923,7 @@ def after_lazy(lazy_obj, field:, owner_object:, arguments:, ast_node:, result:,
924923 end
925924 ensure
926925 if trace
927- @current_trace . end_execute_field ( field , owner_object , arguments , query , result )
926+ @current_trace . end_execute_field ( field , owner_object , arguments , query , sync_result )
928927 end
929928 end
930929 yield ( inner_obj , runtime_state )
@@ -934,12 +933,7 @@ def after_lazy(lazy_obj, field:, owner_object:, arguments:, ast_node:, result:,
934933 lazy . value
935934 else
936935 set_result ( result , result_name , lazy , false , false ) # is_non_null is irrelevant here
937- current_depth = 0
938- while result
939- current_depth += 1
940- result = result . graphql_parent
941- end
942- @dataloader . lazy_at_depth ( current_depth , lazy )
936+ @dataloader . lazy_at_depth ( result . depth , lazy )
943937 lazy
944938 end
945939 else
0 commit comments