@@ -34,7 +34,7 @@ func TestSchemaSubscribe(t *testing.T) {
34
34
},
35
35
}),
36
36
Query : `
37
- subscription onHelloSaid {
37
+ subscription {
38
38
sub_without_resolver
39
39
}
40
40
` ,
@@ -59,7 +59,7 @@ func TestSchemaSubscribe(t *testing.T) {
59
59
},
60
60
}),
61
61
Query : `
62
- subscription onHelloSaid {
62
+ subscription {
63
63
sub_with_resolver
64
64
}
65
65
` ,
@@ -81,7 +81,7 @@ func TestSchemaSubscribe(t *testing.T) {
81
81
},
82
82
}),
83
83
Query : `
84
- subscription onHelloSaid {
84
+ subscription {
85
85
sub_without_resolver
86
86
xxx
87
87
}
@@ -90,6 +90,28 @@ func TestSchemaSubscribe(t *testing.T) {
90
90
{Errors : []string {"Cannot query field \" xxx\" on type \" Subscription\" ." }},
91
91
},
92
92
},
93
+ {
94
+ Name : "panic inside subscribe is recovered" ,
95
+ Schema : makeSubscriptionSchema (t , graphql.ObjectConfig {
96
+ Name : "Subscription" ,
97
+ Fields : graphql.Fields {
98
+ "should_error" : & graphql.Field {
99
+ Type : graphql .String ,
100
+ Subscribe : func (p graphql.ResolveParams ) (interface {}, error ) {
101
+ panic (errors .New ("got a panic error" ))
102
+ },
103
+ },
104
+ },
105
+ }),
106
+ Query : `
107
+ subscription {
108
+ should_error
109
+ }
110
+ ` ,
111
+ ExpectedResults : []testutil.TestResponse {
112
+ {Errors : []string {"got a panic error" }},
113
+ },
114
+ },
93
115
{
94
116
Name : "subscribe with resolver changes output" ,
95
117
Schema : makeSubscriptionSchema (t , graphql.ObjectConfig {
@@ -105,7 +127,7 @@ func TestSchemaSubscribe(t *testing.T) {
105
127
},
106
128
}),
107
129
Query : `
108
- subscription onHelloSaid {
130
+ subscription {
109
131
sub_with_resolver
110
132
}
111
133
` ,
@@ -148,7 +170,7 @@ func TestSchemaSubscribe(t *testing.T) {
148
170
},
149
171
}),
150
172
Query : `
151
- subscription onHelloSaid {
173
+ subscription {
152
174
sub_with_object {
153
175
field
154
176
}
0 commit comments