1
1
using System ;
2
2
using System . Collections . Generic ;
3
+ using System . Diagnostics ;
3
4
using System . Threading . Tasks ;
4
5
using Microsoft . AspNetCore . Builder ;
5
6
using Microsoft . AspNetCore . Hosting ;
6
7
using Microsoft . EntityFrameworkCore ;
7
8
using Microsoft . Extensions . DependencyInjection ;
8
9
using Microsoft . Extensions . Hosting ;
10
+ using Microsoft . Extensions . Logging ;
9
11
using ConferencePlanner . GraphQL . Attendees ;
10
12
using ConferencePlanner . GraphQL . Data ;
11
13
using ConferencePlanner . GraphQL . DataLoader ;
14
16
using ConferencePlanner . GraphQL . Speakers ;
15
17
using ConferencePlanner . GraphQL . Tracks ;
16
18
using ConferencePlanner . GraphQL . Types ;
19
+ using GreenDonut ;
17
20
using HotChocolate ;
18
- using HotChocolate . Types ;
19
- using HotChocolate . Resolvers ;
20
21
using HotChocolate . AspNetCore ;
21
- using System . Diagnostics ;
22
- using GreenDonut ;
23
22
using HotChocolate . Execution ;
24
23
using HotChocolate . Execution . Instrumentation ;
24
+ using HotChocolate . Resolvers ;
25
+ using HotChocolate . Types ;
25
26
using HotChocolate . Types . Pagination ;
26
- using Microsoft . Extensions . Logging ;
27
+
27
28
using IActivityScope = GreenDonut . IActivityScope ;
28
29
29
30
namespace ConferencePlanner . GraphQL
@@ -47,13 +48,9 @@ public void ConfigureServices(IServiceCollection services)
47
48
( s , o ) => o
48
49
. UseSqlite ( "Data Source=conferences.db" )
49
50
. UseLoggerFactory ( s . GetRequiredService < ILoggerFactory > ( ) ) )
50
-
51
- . AddSingleton < IDataLoaderDiagnosticEvents , DataLoaderDiagnostics > ( )
52
51
53
52
// This adds the GraphQL server core service and declares a schema.
54
53
. AddGraphQLServer ( )
55
-
56
- . AddDiagnosticEventListener < HotChocolateDiagnostics > ( )
57
54
58
55
// Next we add the types to our schema.
59
56
. AddQueryType ( )
@@ -137,25 +134,4 @@ public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
137
134
} ) ;
138
135
}
139
136
}
140
-
141
- public class DataLoaderDiagnostics : DataLoaderDiagnosticEventListener
142
- {
143
- public override IActivityScope ExecuteBatch < TKey > ( IDataLoader dataLoader , IReadOnlyList < TKey > keys )
144
- {
145
- Console . WriteLine ( $ "{ dataLoader . GetType ( ) . Name } :{ keys . Count } ") ;
146
- return EmptyScope ;
147
- }
148
- }
149
-
150
- public class HotChocolateDiagnostics : DiagnosticEventListener
151
- {
152
- public override HotChocolate . Execution . Instrumentation . IActivityScope ExecuteRequest ( IRequestContext context )
153
- {
154
- Console . Clear ( ) ;
155
- Console . WriteLine ( "REQUEST_START" ) ;
156
- Console . WriteLine ( ) ;
157
- Console . WriteLine ( ) ;
158
- return base . ExecuteRequest ( context ) ;
159
- }
160
- }
161
137
}
0 commit comments