File tree Expand file tree Collapse file tree 3 files changed +24
-2
lines changed
Expand file tree Collapse file tree 3 files changed +24
-2
lines changed Original file line number Diff line number Diff line change @@ -28,5 +28,23 @@ def to_h
2828 def parent_error?
2929 false
3030 end
31+
32+ class << self
33+ attr_accessor :parent_class
34+
35+ def subclass_for ( parent_class )
36+ subclass = Class . new ( self )
37+ subclass . parent_class = parent_class
38+ subclass
39+ end
40+
41+ def inspect
42+ if name . nil? && parent_class . respond_to? ( :mutation ) && ( mutation = parent_class . mutation )
43+ "#{ mutation . inspect } ::#{ parent_class . graphql_name } ::InvalidNullError"
44+ else
45+ super
46+ end
47+ end
48+ end
3149 end
3250end
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ class << self
7474 # Set up a type-specific invalid null error to use when this object's non-null fields wrongly return `nil`.
7575 # It should help with debugging and bug tracker integrations.
7676 def inherited ( child_class )
77- child_class . const_set ( :InvalidNullError , Class . new ( GraphQL ::InvalidNullError ) )
77+ child_class . const_set ( :InvalidNullError , GraphQL ::InvalidNullError . subclass_for ( child_class ) )
7878 super
7979 end
8080
Original file line number Diff line number Diff line change 118118 query_str = "mutation { returnInvalidNull { int } }"
119119 response = Jazz ::Schema . execute ( query_str )
120120 assert_equal [ "Cannot return null for non-nullable field ReturnInvalidNullPayload.int" ] , response [ "errors" ] . map { |e | e [ "message" ] }
121- assert_instance_of Jazz ::ReturnInvalidNull . payload_type ::InvalidNullError , response . query . context . errors . first
121+ if TESTING_INTERPRETER
122+ error = response . query . context . errors . first
123+ assert_instance_of Jazz ::ReturnInvalidNull . payload_type ::InvalidNullError , error
124+ assert_equal "Jazz::ReturnInvalidNull::ReturnInvalidNullPayload::InvalidNullError" , error . class . inspect
125+ end
122126 end
123127 end
124128
You can’t perform that action at this time.
0 commit comments