@@ -14,7 +14,8 @@ module GraphQLResult
14
14
# ... but the value is only needed for lists with skippable items.
15
15
# Maybe we can set to `nil` unless we know this object is a skippable list item
16
16
# (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 )
18
19
@graphql_parent = parent_result
19
20
if parent_result && parent_result . graphql_dead
20
21
@graphql_dead = true
@@ -23,10 +24,11 @@ def initialize(result_name, parent_result, represented_value)
23
24
# Jump through some hoops to avoid creating this duplicate storage if at all possible.
24
25
@graphql_metadata = nil
25
26
@represented_value = represented_value
27
+ @field = field
26
28
end
27
29
28
30
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
30
32
31
33
# Although these are used by only one of the Result classes,
32
34
# it's handy to have the methods implemented on both (even though they just return `nil`)
@@ -53,7 +55,7 @@ def can_be_skipped?
53
55
end
54
56
55
57
class GraphQLResultHash
56
- def initialize ( _result_name , _parent_result , _represented_value )
58
+ def initialize ( _result_name , _parent_result , _represented_value , _field )
57
59
super
58
60
@graphql_result_data = { }
59
61
end
@@ -114,7 +116,7 @@ def [](k)
114
116
class GraphQLResultArray
115
117
include GraphQLResult
116
118
117
- def initialize ( _result_name , _parent_result , _represented_value )
119
+ def initialize ( _result_name , _parent_result , _represented_value , _field )
118
120
super
119
121
@graphql_result_data = [ ]
120
122
end
@@ -182,7 +184,7 @@ def initialize(query:)
182
184
@multiplex_context = query . multiplex . context
183
185
# Start this off empty:
184
186
Thread . current [ :__graphql_runtime_info ] = nil
185
- @response = GraphQLResultHash . new ( nil , nil , nil )
187
+ @response = GraphQLResultHash . new ( nil , nil , nil , nil )
186
188
# Identify runtime directives by checking which of this schema's directives have overridden `def self.resolve`
187
189
@runtime_directive_names = [ ]
188
190
noop_resolve_owner = GraphQL ::Schema ::Directive . singleton_class
@@ -245,7 +247,7 @@ def run_eager
245
247
# directly evaluated and the results can be written right into the main response hash.
246
248
tap_or_each ( gathered_selections ) do |selections , is_selection_array |
247
249
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 )
249
251
final_response = @response
250
252
else
251
253
selection_response = @response
@@ -778,7 +780,7 @@ def continue_field(path, value, owner_type, field, current_type, ast_node, next_
778
780
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 |
779
781
continue_value = continue_value ( path , inner_object , owner_type , field , is_non_null , ast_node , result_name , selection_result )
780
782
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 )
782
784
set_result ( selection_result , result_name , response_hash )
783
785
gathered_selections = gather_selections ( continue_value , current_type , next_selections )
784
786
# There are two possibilities for `gathered_selections`:
@@ -791,7 +793,7 @@ def continue_field(path, value, owner_type, field, current_type, ast_node, next_
791
793
# (Technically, it's possible that one of those entries _doesn't_ require isolation.)
792
794
tap_or_each ( gathered_selections ) do |selections , is_selection_array |
793
795
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 )
795
797
final_result = response_hash
796
798
else
797
799
this_result = response_hash
@@ -818,7 +820,7 @@ def continue_field(path, value, owner_type, field, current_type, ast_node, next_
818
820
inner_type = current_type . of_type
819
821
# This is true for objects, unions, and interfaces
820
822
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 )
822
824
response_list . graphql_non_null_list_items = inner_type . non_null?
823
825
response_list . graphql_skip_list_items_that_raise = current_type . skip_nodes_on_raise?
824
826
set_result ( selection_result , result_name , response_list )
0 commit comments