@@ -14,7 +14,8 @@ module GraphQLResult
1414 # ... but the value is only needed for lists with skippable items.
1515 # Maybe we can set to `nil` unless we know this object is a skippable list item
1616 # (i.e. a direct child of a list with `skip_items_on_raise: true`)
17- def initialize ( result_name , parent_result , represented_value )
17+ # FIXME: likewise for `field`.
18+ def initialize ( result_name , parent_result , represented_value , field )
1819 @graphql_parent = parent_result
1920 if parent_result && parent_result . graphql_dead
2021 @graphql_dead = true
@@ -23,10 +24,11 @@ def initialize(result_name, parent_result, represented_value)
2324 # Jump through some hoops to avoid creating this duplicate storage if at all possible.
2425 @graphql_metadata = nil
2526 @represented_value = represented_value
27+ @field = field
2628 end
2729
2830 attr_accessor :graphql_dead
29- attr_reader :graphql_parent , :graphql_result_name , :represented_value
31+ attr_reader :graphql_parent , :graphql_result_name , :represented_value , :field
3032
3133 # Although these are used by only one of the Result classes,
3234 # it's handy to have the methods implemented on both (even though they just return `nil`)
@@ -53,7 +55,7 @@ def can_be_skipped?
5355 end
5456
5557 class GraphQLResultHash
56- def initialize ( _result_name , _parent_result , _represented_value )
58+ def initialize ( _result_name , _parent_result , _represented_value , _field )
5759 super
5860 @graphql_result_data = { }
5961 end
@@ -114,7 +116,7 @@ def [](k)
114116 class GraphQLResultArray
115117 include GraphQLResult
116118
117- def initialize ( _result_name , _parent_result , _represented_value )
119+ def initialize ( _result_name , _parent_result , _represented_value , _field )
118120 super
119121 @graphql_result_data = [ ]
120122 end
@@ -182,7 +184,7 @@ def initialize(query:)
182184 @multiplex_context = query . multiplex . context
183185 # Start this off empty:
184186 Thread . current [ :__graphql_runtime_info ] = nil
185- @response = GraphQLResultHash . new ( nil , nil , query . root_value )
187+ @response = GraphQLResultHash . new ( nil , nil , query . root_value , nil )
186188 # Identify runtime directives by checking which of this schema's directives have overridden `def self.resolve`
187189 @runtime_directive_names = [ ]
188190 noop_resolve_owner = GraphQL ::Schema ::Directive . singleton_class
@@ -245,7 +247,7 @@ def run_eager
245247 # directly evaluated and the results can be written right into the main response hash.
246248 tap_or_each ( gathered_selections ) do |selections , is_selection_array |
247249 if is_selection_array
248- selection_response = GraphQLResultHash . new ( nil , nil , query . root_value )
250+ selection_response = GraphQLResultHash . new ( nil , nil , query . root_value , nil )
249251 final_response = @response
250252 else
251253 selection_response = @response
@@ -778,7 +780,7 @@ def continue_field(path, value, owner_type, field, current_type, ast_node, next_
778780 after_lazy ( object_proxy , owner : current_type , path : path , ast_node : ast_node , field : field , owner_object : owner_object , arguments : arguments , trace : false , result_name : result_name , result : selection_result ) do |inner_object |
779781 continue_value = continue_value ( path , inner_object , owner_type , field , is_non_null , ast_node , result_name , selection_result )
780782 if HALT != continue_value
781- response_hash = GraphQLResultHash . new ( result_name , selection_result , continue_value )
783+ response_hash = GraphQLResultHash . new ( result_name , selection_result , continue_value , field )
782784 set_result ( selection_result , result_name , response_hash )
783785 gathered_selections = gather_selections ( continue_value , current_type , next_selections )
784786 # There are two possibilities for `gathered_selections`:
@@ -791,7 +793,7 @@ def continue_field(path, value, owner_type, field, current_type, ast_node, next_
791793 # (Technically, it's possible that one of those entries _doesn't_ require isolation.)
792794 tap_or_each ( gathered_selections ) do |selections , is_selection_array |
793795 if is_selection_array
794- this_result = GraphQLResultHash . new ( result_name , selection_result , continue_value )
796+ this_result = GraphQLResultHash . new ( result_name , selection_result , continue_value , nil )
795797 final_result = response_hash
796798 else
797799 this_result = response_hash
@@ -818,7 +820,7 @@ def continue_field(path, value, owner_type, field, current_type, ast_node, next_
818820 inner_type = current_type . of_type
819821 # This is true for objects, unions, and interfaces
820822 use_dataloader_job = !inner_type . unwrap . kind . input?
821- response_list = GraphQLResultArray . new ( result_name , selection_result , value )
823+ response_list = GraphQLResultArray . new ( result_name , selection_result , value , field )
822824 response_list . graphql_non_null_list_items = inner_type . non_null?
823825 response_list . graphql_skip_list_items_that_raise = current_type . skip_nodes_on_raise?
824826 set_result ( selection_result , result_name , response_list )
0 commit comments