99 * APMs do not need to interact with the graphql API to enable tracing. On
1010 * runtimes that do not expose `node:diagnostics_channel` (e.g., browsers) the
1111 * load silently no-ops and emission sites short-circuit.
12+ * @category Diagnostics
1213 */
1314
1415import { isPromise } from './jsutils/isPromise.ts' ;
@@ -82,45 +83,67 @@ interface DiagnosticsChannelModule {
8283 * Context published on `graphql:parse`.
8384 */
8485export interface GraphQLParseContext {
86+ /** Source text or source object passed to the parser. */
8587 source : string | Source ;
88+ /** Error thrown while parsing, when parsing fails. */
8689 error ?: unknown ;
90+ /** Parsed document, when parsing succeeds. */
8791 result ?: DocumentNode ;
8892}
8993
9094/**
9195 * Context published on `graphql:validate`.
9296 */
9397export interface GraphQLValidateContext {
98+ /** Schema used for validation. */
9499 schema : GraphQLSchema ;
100+ /** Parsed document being validated. */
95101 document : DocumentNode ;
102+ /** Error thrown while validating, when validation fails abruptly. */
96103 error ?: unknown ;
104+ /** Validation errors returned by validation. */
97105 result ?: ReadonlyArray < GraphQLError > ;
98106}
99107
100108/**
101109 * Context published on `graphql:execute`.
102110 */
103111export interface GraphQLExecuteContext {
112+ /** Schema used for execution. */
104113 schema : GraphQLSchema ;
114+ /** Parsed document being executed. */
105115 document : DocumentNode ;
116+ /** Raw variable values provided by the caller before coercion. */
106117 variableValues : Maybe < { readonly [ variable : string ] : unknown } > ;
118+ /** Selected operation name, if one is available. */
107119 operationName : string | undefined ;
120+ /** Selected operation type, if one is available. */
108121 operationType : OperationTypeNode | undefined ;
122+ /** Error thrown while executing, when execution fails abruptly. */
109123 error ?: unknown ;
124+ /** Execution result returned by execution. */
110125 result ?: ExecutionResult | ExperimentalIncrementalExecutionResults ;
111126}
112127
113128/**
114129 * Context published on `graphql:execute:rootSelectionSet`.
115130 */
116131export interface GraphQLExecuteRootSelectionSetContext {
132+ /** Schema used for execution. */
117133 schema : GraphQLSchema ;
134+ /** Parsed document being executed. */
118135 document : DocumentNode ;
136+ /** Operation definition selected for execution. */
119137 operation : OperationDefinitionNode ;
138+ /** Raw variable values provided by the caller before coercion. */
120139 variableValues : Maybe < { readonly [ variable : string ] : unknown } > ;
140+ /** Selected operation name, if one is available. */
121141 operationName : string | undefined ;
142+ /** Selected operation type. */
122143 operationType : OperationTypeNode ;
144+ /** Error thrown while executing the root selection set. */
123145 error ?: unknown ;
146+ /** Execution result returned from the root selection set. */
124147 result ?: ExecutionResult | ExperimentalIncrementalExecutionResults ;
125148}
126149
@@ -133,13 +156,21 @@ export interface GraphQLExecuteRootSelectionSetContext {
133156 * carries the `errors` array, mirroring `graphql:validate`.
134157 */
135158export interface GraphQLExecuteVariableCoercionContext {
159+ /** Schema used for variable coercion. */
136160 schema : GraphQLSchema ;
161+ /** Parsed document being executed. */
137162 document : DocumentNode ;
163+ /** Operation definition whose variables are being coerced. */
138164 operation : OperationDefinitionNode ;
165+ /** Raw variable values provided by the caller before coercion. */
139166 rawVariableValues : Maybe < { readonly [ variable : string ] : unknown } > ;
167+ /** Selected operation name, if one is available. */
140168 operationName : string | undefined ;
169+ /** Selected operation type. */
141170 operationType : OperationTypeNode ;
171+ /** Error thrown while coercing variables, when coercion fails abruptly. */
142172 error ?: unknown ;
173+ /** Coerced variable values or coercion errors returned by coercion. */
143174 result ?:
144175 | { variableValues : VariableValues }
145176 | { errors : ReadonlyArray < GraphQLError > } ;
@@ -149,37 +180,63 @@ export interface GraphQLExecuteVariableCoercionContext {
149180 * Context published on `graphql:subscribe`.
150181 */
151182export interface GraphQLSubscribeContext {
183+ /** Schema used for subscription execution. */
152184 schema : GraphQLSchema ;
185+ /** Parsed subscription document. */
153186 document : DocumentNode ;
187+ /** Raw variable values provided by the caller before coercion. */
154188 variableValues : Maybe < { readonly [ variable : string ] : unknown } > ;
189+ /** Selected operation name, if one is available. */
155190 operationName : string | undefined ;
191+ /** Selected operation type, if one is available. */
156192 operationType : OperationTypeNode | undefined ;
193+ /** Error thrown while subscribing, when subscription setup fails abruptly. */
157194 error ?: unknown ;
195+ /** Subscription response stream or execution result returned by subscribe. */
158196 result ?: AsyncGenerator < ExecutionResult , void , void > | ExecutionResult ;
159197}
160198
161199/**
162200 * Context published on `graphql:resolve`.
163201 */
164202export interface GraphQLResolveContext {
203+ /** Field name being resolved. */
165204 fieldName : string ;
205+ /** Response alias for the field being resolved. */
166206 alias : string ;
207+ /** Parent type name for the field being resolved. */
167208 parentType : string ;
209+ /** Return type string for the field being resolved. */
168210 fieldType : string ;
211+ /** Argument values passed to the resolver. */
169212 args : ObjMap < unknown > ;
213+ /** Whether the field is using the default resolver. */
170214 isDefaultResolver : boolean ;
215+ /** Response path for the field being resolved. */
171216 fieldPath : string ;
217+ /** Error thrown by the resolver, when resolution fails. */
172218 error ?: unknown ;
219+ /** Value returned by the resolver. */
173220 result ?: unknown ;
174221}
175222
223+ /**
224+ * Mapping from tracing channel name to the context type published on it.
225+ */
176226export interface GraphQLChannelContextByName {
227+ /** Context published on `graphql:parse`. */
177228 'graphql:parse' : GraphQLParseContext ;
229+ /** Context published on `graphql:validate`. */
178230 'graphql:validate' : GraphQLValidateContext ;
231+ /** Context published on `graphql:execute`. */
179232 'graphql:execute' : GraphQLExecuteContext ;
233+ /** Context published on `graphql:execute:variableCoercion`. */
180234 'graphql:execute:variableCoercion' : GraphQLExecuteVariableCoercionContext ;
235+ /** Context published on `graphql:execute:rootSelectionSet`. */
181236 'graphql:execute:rootSelectionSet' : GraphQLExecuteRootSelectionSetContext ;
237+ /** Context published on `graphql:subscribe`. */
182238 'graphql:subscribe' : GraphQLSubscribeContext ;
239+ /** Context published on `graphql:resolve`. */
183240 'graphql:resolve' : GraphQLResolveContext ;
184241}
185242
@@ -190,12 +247,19 @@ export interface GraphQLChannelContextByName {
190247 * by name.
191248 */
192249export interface GraphQLChannels {
250+ /** Tracing channel for `graphql:execute`. */
193251 execute : MinimalTracingChannel < GraphQLExecuteContext > ;
252+ /** Tracing channel for `graphql:execute:variableCoercion`. */
194253 executeVariableCoercion : MinimalTracingChannel < GraphQLExecuteVariableCoercionContext > ;
254+ /** Tracing channel for `graphql:execute:rootSelectionSet`. */
195255 executeRootSelectionSet : MinimalTracingChannel < GraphQLExecuteRootSelectionSetContext > ;
256+ /** Tracing channel for `graphql:parse`. */
196257 parse : MinimalTracingChannel < GraphQLParseContext > ;
258+ /** Tracing channel for `graphql:validate`. */
197259 validate : MinimalTracingChannel < GraphQLValidateContext > ;
260+ /** Tracing channel for `graphql:resolve`. */
198261 resolve : MinimalTracingChannel < GraphQLResolveContext > ;
262+ /** Tracing channel for `graphql:subscribe`. */
199263 subscribe : MinimalTracingChannel < GraphQLSubscribeContext > ;
200264}
201265
0 commit comments