Skip to content

Commit b071684

Browse files
committed
Add test for error handlers from schema parent class
1 parent e2d3c9d commit b071684

1 file changed

Lines changed: 10 additions & 5 deletions

File tree

spec/graphql/execution/errors_spec.rb

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@
22
require "spec_helper"
33

44
describe "GraphQL::Execution::Errors" do
5-
class ErrorsTestSchema < GraphQL::Schema
5+
class ParentErrorsTestSchema < GraphQL::Schema
6+
class ErrorD < RuntimeError; end
7+
8+
rescue_from(ErrorD) do |err, obj, args, ctx, field|
9+
raise GraphQL::ExecutionError, "ErrorD on #{obj.inspect} at #{field ? "#{field.path}(#{args})" : "boot"}"
10+
end
11+
end
12+
13+
class ErrorsTestSchema < ParentErrorsTestSchema
14+
ErrorD = ParentErrorsTestSchema::ErrorD
615
class ErrorA < RuntimeError; end
716
class ErrorB < RuntimeError; end
817
class ErrorC < RuntimeError
@@ -12,7 +21,6 @@ def initialize(value:)
1221
super
1322
end
1423
end
15-
class ErrorD < RuntimeError; end
1624

1725
class ErrorASubclass < ErrorA; end
1826
class ErrorBChildClass < ErrorB; end
@@ -42,9 +50,6 @@ class ErrorBGrandchildClass < ErrorBChildClass; end
4250
err.value
4351
end
4452

45-
rescue_from(ErrorD) do |err, obj, args, ctx, field|
46-
raise GraphQL::ExecutionError, "ErrorD on #{obj.inspect} at #{field ? "#{field.path}(#{args})" : "boot"}"
47-
end
4853

4954
class Thing < GraphQL::Schema::Object
5055
def self.authorized?(obj, ctx)

0 commit comments

Comments
 (0)