-
-
Notifications
You must be signed in to change notification settings - Fork 723
/
IExecutionDiagnosticEvents.cs
404 lines (368 loc) · 14.7 KB
/
IExecutionDiagnosticEvents.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
using System;
using System.Collections.Generic;
using HotChocolate.Execution.Processing;
using HotChocolate.Resolvers;
namespace HotChocolate.Execution.Instrumentation;
/// <summary>
/// Diagnostic events that can be triggered by the execution engine.
/// </summary>
/// <seealso cref="IExecutionDiagnosticEventListener"/>
public interface IExecutionDiagnosticEvents
{
/// <summary>
/// Called when starting to execute a GraphQL request with the <see cref="IRequestExecutor"/>.
/// </summary>
/// <param name="context">
/// The request context encapsulates all GraphQL-specific information about an
/// individual GraphQL request.
/// </param>
/// <returns>
/// A scope that will be disposed when the execution has finished.
/// </returns>
IDisposable ExecuteRequest(IRequestContext context);
/// <summary>
/// Called at the end of the execution if an exception occurred at some point,
/// including unhandled exceptions when resolving fields.
/// </summary>
/// <param name="context">
/// The request context encapsulates all GraphQL-specific information about an
/// individual GraphQL request.
/// </param>
/// <param name="exception">
/// The last exception that occurred.
/// </param>
void RequestError(IRequestContext context, Exception exception);
/// <summary>
/// Called when starting to parse a document.
/// </summary>
/// <param name="context">
/// The request context encapsulates all GraphQL-specific information about an
/// individual GraphQL request.
/// </param>
/// <returns>
/// A scope that will be disposed when parsing has finished.
/// </returns>
IDisposable ParseDocument(IRequestContext context);
/// <summary>
/// Called if a syntax error is detected in a document during parsing.
/// </summary>
/// <param name="context">
/// The request context encapsulates all GraphQL-specific information about an
/// individual GraphQL request.
/// </param>
/// <param name="error">
/// The GraphQL syntax error.
/// </param>
void SyntaxError(IRequestContext context, IError error);
/// <summary>
/// Called when starting to validate a document.
/// </summary>
/// <param name="context">
/// The request context encapsulates all GraphQL-specific information about an
/// individual GraphQL request.
/// </param>
/// <returns>
/// A scope that will be disposed when the validation has finished.
/// </returns>
IDisposable ValidateDocument(IRequestContext context);
/// <summary>
/// Called if there are any document validation errors.
/// </summary>
/// <param name="context">
/// The request context encapsulates all GraphQL-specific information about an
/// individual GraphQL request.
/// </param>
/// <param name="errors">
/// The GraphQL validation errors.
/// </param>
void ValidationErrors(IRequestContext context, IReadOnlyList<IError> errors);
/// <summary>
/// Called when starting to analyze the operation complexity.
/// </summary>
/// <param name="context">
/// The request context encapsulates all GraphQL-specific information about an
/// individual GraphQL request.
/// </param>
/// <returns>
/// A scope that will be disposed when the execution has finished.
/// </returns>
IDisposable AnalyzeOperationComplexity(IRequestContext context);
/// <summary>
/// Called within <seealso cref="AnalyzeOperationComplexity"/> scope and
/// reports that an analyzer was compiled.
/// </summary>
/// <param name="context">
/// The request context encapsulates all GraphQL-specific information about an
/// individual GraphQL request.
/// </param>
void OperationComplexityAnalyzerCompiled(IRequestContext context);
/// <summary>
/// Called within <seealso cref="AnalyzeOperationComplexity"/> scope and
/// reports the outcome of the analyzer.
/// </summary>
/// <param name="context">
/// The request context encapsulates all GraphQL-specific information about an
/// individual GraphQL request.
/// </param>
/// <param name="complexity">
/// The current operation complexity.
/// </param>
/// <param name="allowedComplexity">
/// The maximum allowed operation complexity.
/// </param>
void OperationComplexityResult(IRequestContext context, int complexity, int allowedComplexity);
/// <summary>
/// Called when starting to coerce variables for a request.
/// </summary>
/// <param name="context">
/// The request context encapsulates all GraphQL-specific information about an
/// individual GraphQL request.
/// </param>
/// <returns>
/// A scope that will be disposed when the execution has finished.
/// </returns>
IDisposable CoerceVariables(IRequestContext context);
/// <summary>
/// Called when starting to compile the GraphQL operation from the syntax tree.
/// </summary>
/// <param name="context">
/// The request context encapsulates all GraphQL-specific information about an
/// individual GraphQL request.
/// </param>
/// <returns>
/// A scope that will be disposed when the execution has finished.
/// </returns>
IDisposable CompileOperation(IRequestContext context);
/// <summary>
/// Called when starting to execute the GraphQL operation and its resolvers.
/// </summary>
/// <param name="context">
/// The request context encapsulates all GraphQL-specific information about an
/// individual GraphQL request.
/// </param>
/// <returns>
/// A scope that will be disposed when the execution has finished.
/// </returns>
IDisposable ExecuteOperation(IRequestContext context);
/// <summary>
/// Called within the execute operation scope if the result is a streamed result.
/// The ExecuteStream scope will run longer then the ExecuteOperation scope.
/// The ExecuteOperation scope is completed once the initial operation is executed.
/// All deferred elements will be executed and delivered within the ExecuteStream scope.
/// </summary>
/// <param name="operation">
/// The operation that is being streamed.
/// </param>
/// <returns>
/// A scope that will be disposed when the execution has finished.
/// </returns>
IDisposable ExecuteStream(IOperation operation);
/// <summary>
/// Called when starting to execute a deferred part an operation
/// within the ExecuteStream scope or within the
/// ExecuteSubscription scope.
/// </summary>
/// <returns>
/// A scope that will be disposed when the execution has finished.
/// </returns>
IDisposable ExecuteDeferredTask();
/// <summary>
/// Called when starting to resolve a field value.
/// </summary>
/// <remarks>
/// <see cref="IExecutionDiagnosticEventListener.EnableResolveFieldValue"/> must be true if
/// a listener implements this method to ensure that it is called.
/// </remarks>
/// <param name="context">
/// The middleware context encapsulates all resolver-specific information about the
/// execution of an individual field selection.
/// </param>
/// <returns>
/// A scope that will be disposed when the field resolution has finished.
/// </returns>
IDisposable ResolveFieldValue(IMiddlewareContext context);
/// <summary>
/// Called for any errors during field resolution, including unhandled exceptions.
/// </summary>
/// <param name="context">
/// The middleware context encapsulates all resolver-specific information about the
/// execution of an individual field selection.
/// </param>
/// <param name="error">
/// The error object.
/// </param>
void ResolverError(IMiddlewareContext context, IError error);
/// <summary>
/// Called for field errors that do NOT occur within the resolver task.
/// </summary>
/// <param name="operation">
/// The operation that is being executed.
/// </param>
/// <param name="selection">
/// The selection that is affected by the error.
/// </param>
/// <param name="error">
/// The error object.
/// </param>
void ResolverError(IOperation operation, ISelection selection, IError error);
/// <summary>
/// Called when starting to run an execution engine task.
/// </summary>
/// <remarks>
/// <see cref="IExecutionDiagnosticEventListener.EnableResolveFieldValue"/> must be true if
/// a listener implements this method to ensure that it is called.
/// </remarks>
/// <param name="task">
/// Execution engine tasks are things like executing a DataLoader.
/// </param>
/// <returns>
/// A scope that will be disposed when the task has finished.
/// </returns>
IDisposable RunTask(IExecutionTask task);
/// <summary>
/// Called for any errors reported on a <see cref="IExecutionTaskContext"/>
/// during task execution.
/// </summary>
/// <param name="task">
/// Execution engine tasks are things like executing a DataLoader.
/// </param>
/// <param name="error">
/// The error that occurred while running the execution task.
/// </param>
void TaskError(IExecutionTask task, IError error);
/// <summary>
/// This event is called when the request execution pipeline scales
/// the task processors up or down.
/// </summary>
/// <param name="context">
/// The request that is being executed.
/// </param>
void StartProcessing(IRequestContext context);
/// <summary>
/// This event is called when the request execution pipeline scales
/// the task processors up or down.
/// </summary>
/// <param name="context">
/// The request that is being executed.
/// </param>
void StopProcessing(IRequestContext context);
/// <summary>
/// Called when a subscription was created.
/// </summary>
/// <param name="subscription">
/// The subscription object.
/// </param>
/// <returns>
/// A scope that will be disposed when the subscription has completed.
/// </returns>
IDisposable ExecuteSubscription(ISubscription subscription);
/// <summary>
/// Called when an event was raised and a new subscription result is being produced.
/// </summary>
/// <param name="context">
/// The subscription event context.
/// </param>
/// <returns>
/// A scope that will be disposed when the subscription event execution has completed.
/// </returns>
IDisposable OnSubscriptionEvent(SubscriptionEventContext context);
/// <summary>
/// Called when a result for a specific subscription event was produced.
/// </summary>
/// <param name="context">
/// The subscription event context.
/// </param>
/// <param name="result">
/// The subscription result that is being written to the response stream.
/// </param>
void SubscriptionEventResult(SubscriptionEventContext context, IQueryResult result);
/// <summary>
/// Called when an error occurred while producing the subscription event result.
/// </summary>
/// <param name="context">
/// The subscription event context.
/// </param>
/// <param name="exception">
/// The exception that occurred.
/// </param>
void SubscriptionEventError(SubscriptionEventContext context, Exception exception);
/// <summary>
/// Called when an error occurred while producing the subscription event result.
/// </summary>
/// <param name="subscription">
/// The subscription object.
/// </param>
/// <param name="exception">
/// The exception that occurred.
/// </param>
void SubscriptionEventError(ISubscription subscription, Exception exception);
/// <summary>
/// Called when an error occurred while producing the subscription event result.
/// </summary>
/// <param name="subscription">
/// The subscription object.
/// </param>
/// <param name="exception">
/// The exception that occurred.
/// </param>
void SubscriptionTransportError(ISubscription subscription, Exception exception);
/// <summary>
/// A GraphQL request document was added to the document cache.
/// </summary>
/// <param name="context">
/// The request context encapsulates all GraphQL-specific information about an
/// individual GraphQL request.
/// </param>
void AddedDocumentToCache(IRequestContext context);
/// <summary>
/// A GraphQL request document was retrieved from the document cache.
/// </summary>
/// <param name="context">
/// The request context encapsulates all GraphQL-specific information about an
/// individual GraphQL request.
/// </param>
void RetrievedDocumentFromCache(IRequestContext context);
/// <summary>
/// Called when the document for a persisted query has been read from storage.
/// </summary>
/// <param name="context"></param>
void RetrievedDocumentFromStorage(IRequestContext context);
/// <summary>
/// A compiled operation was added to the operation cache.
/// </summary>
/// <param name="context">
/// The request context encapsulates all GraphQL-specific information about an
/// individual GraphQL request.
/// </param>
void AddedOperationToCache(IRequestContext context);
/// <summary>
/// A compiled operation was retrieved from the operation cache.
/// </summary>
/// <param name="context">
/// The request context encapsulates all GraphQL-specific information about an
/// individual GraphQL request.
/// </param>
void RetrievedOperationFromCache(IRequestContext context);
/// <summary>
/// During execution we allow components like the DataLoader or schema stitching to
/// defer execution of data resolvers to be executed in batches. If the execution engine
/// has nothing to execute anymore these batches will be dispatched for execution.
/// </summary>
/// <param name="context">
/// The request context encapsulates all GraphQL-specific information about an
/// individual GraphQL request.
/// </param>
IDisposable DispatchBatch(IRequestContext context);
/// <summary>
/// A GraphQL request executor was created and is now able to execute GraphQL requests.
/// </summary>
/// <param name="name">The name of the GraphQL schema.</param>
/// <param name="executor">The GraphQL request executor.</param>
void ExecutorCreated(string name, IRequestExecutor executor);
/// <summary>
/// A GraphQL request executor was evicted and will be removed from memory.
/// </summary>
/// <param name="name">The name of the GraphQL schema.</param>
/// <param name="executor">The GraphQL request executor.</param>
void ExecutorEvicted(string name, IRequestExecutor executor);
}