Skip to content

Commit 6a06782

Browse files
committed
fix leaf response building.
1 parent d942fa0 commit 6a06782

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

lib/graphql/cardinal/executor.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -209,13 +209,7 @@ def resolve_execution_field(exec_field, resolved_sources)
209209
# build leaf results
210210
resolved_sources.each_with_index do |val, i|
211211
# DANGER: HOT PATH!
212-
parent_responses[i][field_key] = if val.nil? || val.is_a?(StandardError)
213-
build_missing_value(exec_field, field_type, val)
214-
elsif return_type.kind.leaf?
215-
coerce_leaf_value(exec_field, field_type, val)
216-
else
217-
val
218-
end
212+
parent_responses[i][field_key] = coerce_leaf_value(exec_field, field_type, val)
219213
end
220214
end
221215
end

lib/graphql/cardinal/executor/hot_paths.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,9 @@ def build_missing_value(exec_field, current_type, val)
5050
# DANGER: HOT PATH!
5151
# Overhead added here scales dramatically...
5252
def coerce_leaf_value(exec_field, current_type, val)
53-
if current_type.list?
53+
if val.nil? || val.is_a?(StandardError)
54+
build_missing_value(exec_field, current_type, val)
55+
elsif current_type.list?
5456
unless val.is_a?(Array)
5557
report_exception("#{INCORRECT_LIST_VALUE}#{val.class}", field: exec_field)
5658
return build_missing_value(exec_field, current_type, nil)

0 commit comments

Comments
 (0)