@@ -10,18 +10,19 @@ class Interpreter
10
10
class Runtime
11
11
12
12
module GraphQLResult
13
- def initialize ( result_name , parent_result )
13
+ def initialize ( result_name , parent_result , represented_value )
14
14
@graphql_parent = parent_result
15
15
if parent_result && parent_result . graphql_dead
16
16
@graphql_dead = true
17
17
end
18
18
@graphql_result_name = result_name
19
19
# Jump through some hoops to avoid creating this duplicate storage if at all possible.
20
20
@graphql_metadata = nil
21
+ @represented_value
21
22
end
22
23
23
24
attr_accessor :graphql_dead
24
- attr_reader :graphql_parent , :graphql_result_name
25
+ attr_reader :graphql_parent , :graphql_result_name , :represented_value
25
26
26
27
# Although these are used by only one of the Result classes,
27
28
# it's handy to have the methods implemented on both (even though they just return `nil`)
@@ -41,14 +42,23 @@ def has_graphql_graph_parent_that_skips_list_items_that_raise
41
42
!!graphql_parent &.has_graphql_graph_parent_that_skips_list_items_that_raise
42
43
end
43
44
45
+ def find_first_skippable_object
46
+ @first_skippable_object ||= if graphql_parent &.graphql_skip_list_items_that_raise
47
+ self
48
+ else
49
+ graphql_parent &.find_first_skippable_parent
50
+ end
51
+ end
52
+
44
53
# @return [Hash] Plain-Ruby result data (`@graphql_metadata` contains Result wrapper objects)
45
54
attr_accessor :graphql_result_data
46
55
end
47
56
48
57
class GraphQLResultHash
49
- def initialize ( _result_name , _parent_result )
58
+ def initialize ( result_name , parent_result , represented_value )
50
59
super
51
60
@graphql_result_data = { }
61
+ @represented_value = represented_value
52
62
end
53
63
54
64
include GraphQLResult
@@ -107,7 +117,7 @@ def [](k)
107
117
class GraphQLResultArray
108
118
include GraphQLResult
109
119
110
- def initialize ( _result_name , _parent_result )
120
+ def initialize ( _result_name , _parent_result , represented_value )
111
121
super
112
122
@graphql_result_data = [ ]
113
123
end
@@ -175,7 +185,7 @@ def initialize(query:)
175
185
@multiplex_context = query . multiplex . context
176
186
# Start this off empty:
177
187
Thread . current [ :__graphql_runtime_info ] = nil
178
- @response = GraphQLResultHash . new ( nil , nil )
188
+ @response = GraphQLResultHash . new ( nil , nil , nil )
179
189
# Identify runtime directives by checking which of this schema's directives have overridden `def self.resolve`
180
190
@runtime_directive_names = [ ]
181
191
noop_resolve_owner = GraphQL ::Schema ::Directive . singleton_class
@@ -786,7 +796,7 @@ def continue_field(path, value, owner_type, field, current_type, ast_node, next_
786
796
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 |
787
797
continue_value = continue_value ( path , inner_object , owner_type , field , is_non_null , ast_node , result_name , selection_result )
788
798
if HALT != continue_value
789
- response_hash = GraphQLResultHash . new ( result_name , selection_result )
799
+ response_hash = GraphQLResultHash . new ( result_name , selection_result , continue_value )
790
800
set_result ( selection_result , result_name , response_hash )
791
801
gathered_selections = gather_selections ( continue_value , current_type , next_selections )
792
802
# There are two possibilities for `gathered_selections`:
@@ -828,7 +838,7 @@ def continue_field(path, value, owner_type, field, current_type, ast_node, next_
828
838
# puts("Item type: #{inner_type}, #{inner_type.skip_nodes_on_raise?.inspect}")
829
839
# This is true for objects, unions, and interfaces
830
840
use_dataloader_job = !inner_type . unwrap . kind . input?
831
- response_list = GraphQLResultArray . new ( result_name , selection_result )
841
+ response_list = GraphQLResultArray . new ( result_name , selection_result , value )
832
842
response_list . graphql_non_null_list_items = inner_type . non_null?
833
843
response_list . graphql_skip_list_items_that_raise = current_type . skip_nodes_on_raise?
834
844
set_result ( selection_result , result_name , response_list )
0 commit comments