MCPcopy
hub / github.com/ardatan/graphql-tools / executeImpl

Function executeImpl

packages/executor/src/execution/execute.ts:294–337  ·  view source on GitHub ↗
(
  exeContext: ExecutionContext<TVariables, TContext>,
)

Source from the content-addressed store, hash-verified

292}
293
294function executeImpl<TData = any, TVariables = any, TContext = any>(
295 exeContext: ExecutionContext<TVariables, TContext>,
296): MaybePromise<SingularExecutionResult<TData> | IncrementalExecutionResults<TData>> {
297 exeContext.signal?.throwIfAborted();
298
299 // Return a Promise that will eventually resolve to the data described by
300 // The "Response" section of the GraphQL specification.
301 //
302 // If errors are encountered while executing a GraphQL field, only that
303 // field and its descendants will be omitted, and sibling fields will still
304 // be executed. An execution which encounters errors will still result in a
305 // resolved Promise.
306 //
307 // Errors from sub-fields of a NonNull type may propagate to the top level,
308 // at which point we still log the error and null the parent field, which
309 // in this case is the entire response.
310 return handleMaybePromise(
311 () => executeOperation<TData, TVariables, TContext>(exeContext),
312 data => {
313 const initialResult = buildResponse(data, exeContext.errors);
314 if (exeContext.subsequentPayloads.size > 0) {
315 return {
316 initialResult: {
317 ...initialResult,
318 hasNext: true,
319 },
320 subsequentResults: yieldSubsequentPayloads(exeContext),
321 };
322 }
323
324 return initialResult;
325 },
326 (error: any) => {
327 exeContext.signal?.throwIfAborted();
328
329 if (error.errors) {
330 exeContext.errors.push(...error.errors);
331 } else {
332 exeContext.errors.push(error);
333 }
334 return buildResponse<TData>(null, exeContext.errors);
335 },
336 );
337}
338
339/**
340 * Also implements the "Executing requests" section of the GraphQL specification.

Callers 2

executeFunction · 0.85
mapSourceToResponseFunction · 0.85

Calls 3

executeOperationFunction · 0.85
buildResponseFunction · 0.85
yieldSubsequentPayloadsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…