File tree Expand file tree Collapse file tree 2 files changed +47
-2
lines changed Expand file tree Collapse file tree 2 files changed +47
-2
lines changed Original file line number Diff line number Diff line change
1
+ using GraphQL . Types ;
2
+
3
+ namespace GraphQL . Tests . Bugs ;
4
+
5
+ public class Bug3444
6
+ {
7
+ [ Fact ]
8
+ public void Rethrow_Schema_Initialization_Failure ( )
9
+ {
10
+ var queryType = new ObjectGraphType { Name = "Query" } ;
11
+ queryType . Field < TestOneType > ( "test1" ) ;
12
+ queryType . Field < TestTwoType > ( "test2" ) ;
13
+ var schema = new Schema ( ) { Query = queryType } ;
14
+ var msg1 = Should . Throw < InvalidOperationException > ( ( ) => schema . Initialize ( ) ) . Message ;
15
+ var msg2 = Should . Throw < InvalidOperationException > ( ( ) => schema . Initialize ( ) ) . Message ;
16
+ msg1 . ShouldBe ( msg2 ) ;
17
+ }
18
+
19
+ private class TestOneType : EnumerationGraphType < TestEnum >
20
+ {
21
+ }
22
+
23
+ private class TestTwoType : EnumerationGraphType < TestEnum >
24
+ {
25
+ }
26
+
27
+ private enum TestEnum
28
+ {
29
+ One ,
30
+ Two ,
31
+ Three
32
+ }
33
+ }
Original file line number Diff line number Diff line change 1
1
using System . Diagnostics ;
2
+ using System . Runtime . ExceptionServices ;
2
3
using GraphQL . Conversion ;
3
4
using GraphQL . DI ;
4
5
using GraphQL . Instrumentation ;
@@ -74,6 +75,7 @@ public SchemaDebugView(Schema schema)
74
75
private bool _disposed ;
75
76
private IServiceProvider _services ;
76
77
private SchemaTypes ? _allTypes ;
78
+ private ExceptionDispatchInfo ? _initializationException ;
77
79
private readonly object _allTypesInitializationLock = new ( ) ;
78
80
79
81
private List < Type > ? _additionalTypes ;
@@ -201,9 +203,19 @@ public void Initialize()
201
203
if ( Initialized )
202
204
return ;
203
205
204
- CreateAndInitializeSchemaTypes ( ) ;
206
+ _initializationException ? . Throw ( ) ;
205
207
206
- Initialized = true ;
208
+ try
209
+ {
210
+ CreateAndInitializeSchemaTypes ( ) ;
211
+
212
+ Initialized = true ;
213
+ }
214
+ catch ( Exception ex )
215
+ {
216
+ _initializationException = ExceptionDispatchInfo . Capture ( ex ) ;
217
+ throw ;
218
+ }
207
219
}
208
220
}
209
221
You can’t perform that action at this time.
0 commit comments