@@ -26,7 +26,8 @@ module GraphQLResult
2626 # ... but the value is only needed for lists with skippable items.
2727 # Maybe we can set to `nil` unless we know this object is a skippable list item
2828 # (i.e. a direct child of a list with `skip_items_on_raise: true`)
29- def initialize ( result_name , parent_result , is_non_null_in_parent , represented_value )
29+ # FIXME: likewise for `field`.
30+ def initialize ( result_name , parent_result , is_non_null_in_parent , represented_value , field )
3031 @graphql_parent = parent_result
3132 if parent_result && parent_result . graphql_dead
3233 @graphql_dead = true
@@ -36,6 +37,7 @@ def initialize(result_name, parent_result, is_non_null_in_parent, represented_va
3637 # Jump through some hoops to avoid creating this duplicate storage if at all possible.
3738 @graphql_metadata = nil
3839 @represented_value = represented_value
40+ @field = field
3941 end
4042
4143 def path
@@ -48,7 +50,7 @@ def build_path(path_array)
4850 end
4951
5052 attr_accessor :graphql_dead
51- attr_reader :graphql_parent , :graphql_result_name , :graphql_is_non_null_in_parent , :represented_value
53+ attr_reader :graphql_parent , :graphql_result_name , :graphql_is_non_null_in_parent , :represented_value , :field
5254
5355 # True when this result is a List that was marked `skip_items_on_raise: true`.
5456 # Descendants of this result will have `can_be_skipped?` be true.
@@ -68,7 +70,7 @@ def can_be_skipped?
6870 end
6971
7072 class GraphQLResultHash
71- def initialize ( _result_name , _parent_result , _is_non_null_in_parent , _represented_value )
73+ def initialize ( _result_name , _parent_result , _is_non_null_in_parent , _represented_value , _field )
7274 super
7375 @graphql_result_data = { }
7476 end
@@ -156,7 +158,7 @@ def merge_into(into_result)
156158 class GraphQLResultArray
157159 include GraphQLResult
158160
159- def initialize ( _result_name , _parent_result , _is_non_null_in_parent , _represented_value )
161+ def initialize ( _result_name , _parent_result , _is_non_null_in_parent , _represented_value , _field )
160162 super
161163 @graphql_result_data = [ ]
162164 end
@@ -216,7 +218,7 @@ def initialize(query:, lazies_at_depth:)
216218 @lazies_at_depth = lazies_at_depth
217219 @schema = query . schema
218220 @context = query . context
219- @response = GraphQLResultHash . new ( nil , nil , false , query . root_value )
221+ @response = GraphQLResultHash . new ( nil , nil , false , query . root_value , nil )
220222 # Identify runtime directives by checking which of this schema's directives have overridden `def self.resolve`
221223 @runtime_directive_names = [ ]
222224 noop_resolve_owner = GraphQL ::Schema ::Directive . singleton_class
@@ -283,7 +285,7 @@ def run_eager
283285 # directly evaluated and the results can be written right into the main response hash.
284286 tap_or_each ( gathered_selections ) do |selections , is_selection_array |
285287 if is_selection_array
286- selection_response = GraphQLResultHash . new ( nil , nil , false , query . root_value )
288+ selection_response = GraphQLResultHash . new ( nil , nil , false , query . root_value , nil )
287289 final_response = @response
288290 else
289291 selection_response = @response
@@ -840,7 +842,7 @@ def continue_field(value, owner_type, field, current_type, ast_node, next_select
840842 after_lazy ( object_proxy , ast_node : ast_node , field : field , owner_object : owner_object , arguments : arguments , trace : false , result_name : result_name , result : selection_result ) do |inner_object |
841843 continue_value = continue_value ( inner_object , owner_type , field , is_non_null , ast_node , result_name , selection_result )
842844 if HALT != continue_value
843- response_hash = GraphQLResultHash . new ( result_name , selection_result , is_non_null , continue_value )
845+ response_hash = GraphQLResultHash . new ( result_name , selection_result , is_non_null , continue_value , field )
844846 set_result ( selection_result , result_name , response_hash , true , is_non_null )
845847 gathered_selections = gather_selections ( continue_value , current_type , next_selections )
846848 # There are two possibilities for `gathered_selections`:
@@ -853,7 +855,7 @@ def continue_field(value, owner_type, field, current_type, ast_node, next_select
853855 # (Technically, it's possible that one of those entries _doesn't_ require isolation.)
854856 tap_or_each ( gathered_selections ) do |selections , is_selection_array |
855857 if is_selection_array
856- this_result = GraphQLResultHash . new ( result_name , selection_result , is_non_null , continue_value )
858+ this_result = GraphQLResultHash . new ( result_name , selection_result , is_non_null , continue_value , nil )
857859 final_result = response_hash
858860 else
859861 this_result = response_hash
@@ -890,7 +892,7 @@ def continue_field(value, owner_type, field, current_type, ast_node, next_select
890892 # This is true for objects, unions, and interfaces
891893 use_dataloader_job = !inner_type . unwrap . kind . input?
892894 inner_type_non_null = inner_type . non_null?
893- response_list = GraphQLResultArray . new ( result_name , selection_result , is_non_null , value )
895+ response_list = GraphQLResultArray . new ( result_name , selection_result , is_non_null , value , field )
894896 response_list . graphql_skip_list_items_that_raise = current_type . skip_nodes_on_raise?
895897 set_result ( selection_result , result_name , response_list , true , is_non_null )
896898 idx = nil
0 commit comments