Skip to content

Commit e1be679

Browse files
committed
Add a test
1 parent a322aba commit e1be679

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

spec/graphql/execution/interpreter_spec.rb

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -546,4 +546,36 @@ def self.resolve_type(type, obj, ctx)
546546
assert_equal({ sym: "RAW", name: "Raw expansion", always_cached_value: 42 }, res["data"]["expansionRaw"])
547547
end
548548
end
549+
550+
describe "GraphQL::ExecutionErrors from non-null list fields" do
551+
module ListErrorTest
552+
class BaseField < GraphQL::Schema::Field
553+
def authorized?(*)
554+
raise GraphQL::ExecutionError, "#{name} is not authorized"
555+
end
556+
end
557+
558+
class Thing < GraphQL::Schema::Object
559+
field_class BaseField
560+
field :title, String, null: false
561+
end
562+
563+
class Query < GraphQL::Schema::Object
564+
field :things, [Thing], null: false
565+
566+
def things
567+
[{title: "a"}, {title: "b"}, {title: "c"}]
568+
end
569+
end
570+
571+
class Schema < GraphQL::Schema
572+
query Query
573+
end
574+
end
575+
576+
it "returns only 1 error" do
577+
res = ListErrorTest::Schema.execute("{ things { title } }")
578+
assert_equal 1, res["errors"].size
579+
end
580+
end
549581
end

0 commit comments

Comments
 (0)