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
28
28
def parent_error?
29
29
false
30
30
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
31
49
end
32
50
end
Original file line number Diff line number Diff line change @@ -74,7 +74,7 @@ class << self
74
74
# Set up a type-specific invalid null error to use when this object's non-null fields wrongly return `nil`.
75
75
# It should help with debugging and bug tracker integrations.
76
76
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 ) )
78
78
super
79
79
end
80
80
Original file line number Diff line number Diff line change 118
118
query_str = "mutation { returnInvalidNull { int } }"
119
119
response = Jazz ::Schema . execute ( query_str )
120
120
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
122
126
end
123
127
end
124
128
You can’t perform that action at this time.
0 commit comments