Skip to content

Commit d942fa0

Browse files
committed
fix leaf coercion loop.
1 parent eedf7ea commit d942fa0

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

lib/graphql/cardinal/executor/hot_paths.rb

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,16 +55,17 @@ def coerce_leaf_value(exec_field, current_type, val)
5555
report_exception("#{INCORRECT_LIST_VALUE}#{val.class}", field: exec_field)
5656
return build_missing_value(exec_field, current_type, nil)
5757
end
58-
58+
5959
current_type = current_type.of_type while current_type.non_null?
6060

61-
val.each { coerce_leaf_value(exec_field, current_type.of_type, _1) }
61+
val.map { coerce_leaf_value(exec_field, current_type.of_type, _1) }
6262
else
6363
begin
6464
current_type.unwrap.coerce_result(val, @context)
6565
rescue StandardError => e
66-
report_exception("Coercion error", field: exec_field)
67-
build_missing_value(exec_field, current_type, val)
66+
report_exception("Error building leaf result", error: e, field: exec_field)
67+
error = InternalError.new(path: exec_field.path, base: false)
68+
build_missing_value(exec_field, current_type, error)
6869
end
6970
end
7071
end

test/graphql/cardinal/executor/introspection_test.rb

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def test_introspect_directive_type
162162
"args" => [{ "name" => "key" }],
163163
"description" => "@stitch description",
164164
"isRepeatable" => true,
165-
"locations" => [:FIELD_DEFINITION],
165+
"locations" => ["FIELD_DEFINITION"],
166166
"name" => "stitch"
167167
}
168168

@@ -171,7 +171,7 @@ def test_introspect_directive_type
171171

172172
def test_introspect_type_access
173173
result = execute_query(%|{
174-
__type(name: "Widget") {
174+
__type(name: "Widget") {
175175
description
176176
kind
177177
name
@@ -279,10 +279,10 @@ def test_introspect_type_possible_types
279279

280280
def test_introspect_type_specified_by_url
281281
result = execute_query(%|{
282-
scalar: __type(name: "String") {
282+
scalar: __type(name: "String") {
283283
specifiedByURL
284284
}
285-
non_scalar: __type(name: "Widget") {
285+
non_scalar: __type(name: "Widget") {
286286
specifiedByURL
287287
}
288288
}|)
@@ -303,7 +303,7 @@ def test_introspect_type_specified_by_url
303303

304304
def test_introspect_type_kind_of_type
305305
result = execute_query(%|{
306-
__type(name: "Mutation") {
306+
__type(name: "Mutation") {
307307
name
308308
kind
309309
ofType { name }
@@ -361,7 +361,7 @@ def test_introspect_type_kind_of_type
361361

362362
def test_introspect_enum_value
363363
result = execute_query(%|{
364-
__type(name: "Status") {
364+
__type(name: "Status") {
365365
enumValues(includeDeprecated: true) {
366366
deprecationReason
367367
description
@@ -399,7 +399,7 @@ def test_introspect_enum_value
399399

400400
def test_introspect_field
401401
result = execute_query(%|{
402-
__type(name: "Query") {
402+
__type(name: "Query") {
403403
fields(includeDeprecated: true) {
404404
args { name }
405405
deprecationReason
@@ -452,7 +452,7 @@ def test_introspect_field
452452

453453
def test_introspect_arguments
454454
result = execute_query(%|{
455-
__type(name: "Mutation") {
455+
__type(name: "Mutation") {
456456
fields {
457457
some: args { name }
458458
all: args(includeDeprecated: true) {
@@ -510,7 +510,7 @@ def test_introspect_argument_default_values
510510
|)
511511

512512
result = execute_query(%|{
513-
__type(name: "Query") {
513+
__type(name: "Query") {
514514
fields {
515515
args { defaultValue }
516516
}

0 commit comments

Comments
 (0)