File tree Expand file tree Collapse file tree 2 files changed +25
-9
lines changed
lib/absinthe/phase/document
test/absinthe/integration/execution Expand file tree Collapse file tree 2 files changed +25
-9
lines changed Original file line number Diff line number Diff line change @@ -54,15 +54,18 @@ defmodule Absinthe.Phase.Document.Result do
54
54
try do
55
55
Type.Scalar . serialize ( schema_node , value )
56
56
rescue
57
- Absinthe.SerializationError ->
58
- raise ( Absinthe.SerializationError , """
59
- Could not serialize term #{ inspect ( value ) } as type #{ schema_node . name }
60
-
61
- When serializing the field:
62
- #{ emitter . parent_type . name } .#{ emitter . schema_node . name } (#{
63
- emitter . schema_node . __reference__ . location . file
64
- } :#{ emitter . schema_node . __reference__ . location . line } )
65
- """ )
57
+ _e in [ Absinthe.SerializationError , Protocol.UndefinedError ] ->
58
+ raise (
59
+ Absinthe.SerializationError ,
60
+ """
61
+ Could not serialize term #{ inspect ( value ) } as type #{ schema_node . name }
62
+
63
+ When serializing the field:
64
+ #{ emitter . parent_type . name } .#{ emitter . schema_node . name } (#{
65
+ emitter . schema_node . __reference__ . location . file
66
+ } :#{ emitter . schema_node . __reference__ . location . line } )
67
+ """
68
+ )
66
69
end
67
70
68
71
% Type.Enum { } = schema_node ->
Original file line number Diff line number Diff line change @@ -16,6 +16,10 @@ defmodule Absinthe.Integration.Execution.SerializationTest do
16
16
field :bad_boolean , :boolean do
17
17
resolve fn _ , _ , _ -> { :ok , "true" } end
18
18
end
19
+
20
+ field :bad_string , :string do
21
+ resolve fn _ , _ , _ -> { :ok , % { } } end
22
+ end
19
23
end
20
24
end
21
25
@@ -45,4 +49,13 @@ defmodule Absinthe.Integration.Execution.SerializationTest do
45
49
Absinthe . run ( @ query , Schema )
46
50
end )
47
51
end
52
+
53
+ @ query """
54
+ query { badString }
55
+ """
56
+ test "returning a type that can't `to_string` for a string raises" do
57
+ assert_raise ( Absinthe.SerializationError , fn ->
58
+ Absinthe . run ( @ query , Schema )
59
+ end )
60
+ end
48
61
end
You can’t perform that action at this time.
0 commit comments