Skip to content

Commit

Permalink
Refactor Executor implementation into class
Browse files Browse the repository at this point in the history
  • Loading branch information
yaacovCR committed Oct 8, 2021
1 parent 2325f66 commit 462ada4
Show file tree
Hide file tree
Showing 3 changed files with 888 additions and 810 deletions.
13 changes: 3 additions & 10 deletions src/execution/execute.ts
Expand Up @@ -2,7 +2,7 @@ import type { PromiseOrValue } from '../jsutils/PromiseOrValue';
import { isPromise } from '../jsutils/isPromise';

import type { ExecutionArgs, ExecutionResult } from './executor';
import { buildExecutionContext, executeQueryOrMutation } from './executor';
import { Executor } from './executor';

/**
* Implements the "Executing requests" section of the GraphQL specification.
Expand All @@ -15,17 +15,10 @@ import { buildExecutionContext, executeQueryOrMutation } from './executor';
* a GraphQLError will be thrown immediately explaining the invalid input.
*/
export function execute(args: ExecutionArgs): PromiseOrValue<ExecutionResult> {
// If a valid execution context cannot be created due to incorrect arguments,
// a "Response" with only errors is returned.
const exeContext = buildExecutionContext(args);

// Return early errors if execution context failed.
if (!('schema' in exeContext)) {
return { errors: exeContext };
}
const executor = new Executor(args);

// Execute the operation.
return executeQueryOrMutation(exeContext);
return executor.executeQueryOrMutation();
}

/**
Expand Down

0 comments on commit 462ada4

Please sign in to comment.