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

Function execute

packages/executor/src/execution/execute.ts:266–292  ·  view source on GitHub ↗
(
  args: ExecutionArgs<TData, TVariables, TContext>,
)

Source from the content-addressed store, hash-verified

264 * a GraphQLError will be thrown immediately explaining the invalid input.
265 */
266export function execute<TData = any, TVariables = any, TContext = any>(
267 args: ExecutionArgs<TData, TVariables, TContext>,
268): MaybePromise<SingularExecutionResult<TData> | IncrementalExecutionResults<TData>> {
269 // If a valid execution context cannot be created due to incorrect arguments,
270 // a "Response" with only errors is returned.
271 const exeContext = buildExecutionContext(args);
272
273 // Return early errors if execution context failed.
274 if (!('schema' in exeContext)) {
275 return {
276 errors: exeContext.map(e => {
277 Object.defineProperty(e, 'extensions', {
278 value: {
279 ...e.extensions,
280 http: {
281 ...(e.extensions?.['http'] || {}),
282 status: 400,
283 },
284 },
285 });
286 return e;
287 }),
288 };
289 }
290
291 return executeImpl(exeContext);
292}
293
294function executeImpl<TData = any, TVariables = any, TContext = any>(
295 exeContext: ExecutionContext<TVariables, TContext>,

Callers 15

customFetchFunction · 0.90
url-loader.spec.tsFile · 0.90
envelop.spec.tsFile · 0.85
normalizedExecutorFunction · 0.85
executeSyncFunction · 0.85
completeFunction · 0.85
completeObjectListFunction · 0.85

Calls 2

buildExecutionContextFunction · 0.85
executeImplFunction · 0.85

Tested by 13

customFetchFunction · 0.72
completeFunction · 0.68
completeObjectListFunction · 0.68
executeQueryFunction · 0.68
executeQueryFunction · 0.68
executeQueryFunction · 0.68
executeSyncAndAsyncFunction · 0.68
completeFunction · 0.68
completeAsyncFunction · 0.68
completeFunction · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…