Skip to content

Commit

Permalink
refactor: move assertValidExecutionArguments
Browse files Browse the repository at this point in the history
only called by buildExecutionContext
  • Loading branch information
yaacovCR committed Oct 4, 2021
1 parent 2b54f3c commit 3b5983f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 14 deletions.
9 changes: 4 additions & 5 deletions src/execution/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -182,10 +182,6 @@ export function execute(args: ExecutionArgs): PromiseOrValue<ExecutionResult> {
fieldResolver,
typeResolver,
} = args;

// If arguments are missing or incorrect, throw an error.
assertValidExecutionArguments(schema, document, variableValues);

// If a valid execution context cannot be created due to incorrect arguments,
// a "Response" with only errors is returned.
let exeContext: ExecutionContext;
Expand Down Expand Up @@ -263,7 +259,7 @@ function buildResponse(
*
* @internal
*/
export function assertValidExecutionArguments(
function assertValidExecutionArguments(
schema: GraphQLSchema,
document: DocumentNode,
rawVariableValues: Maybe<{ readonly [variable: string]: unknown }>,
Expand Down Expand Up @@ -299,6 +295,9 @@ export function buildExecutionContext(
typeResolver?: Maybe<GraphQLTypeResolver<unknown, unknown>>,
subscribeFieldResolver?: Maybe<GraphQLFieldResolver<unknown, unknown>>,
): ExecutionContext {
// If arguments are missing or incorrect, throw an error.
assertValidExecutionArguments(schema, document, rawVariableValues);

let operation: OperationDefinitionNode | undefined;
const fragments: ObjMap<FragmentDefinitionNode> = Object.create(null);
for (const definition of document.definitions) {
Expand Down
10 changes: 1 addition & 9 deletions src/execution/subscribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,7 @@ import type {
} from '../type/definition';

import type { ExecutionContext, ExecutionResult } from './execute';
import {
assertValidExecutionArguments,
buildExecutionContext,
executeSubscription,
} from './execute';
import { buildExecutionContext, executeSubscription } from './execute';

export interface SubscriptionArgs {
schema: GraphQLSchema;
Expand Down Expand Up @@ -64,10 +60,6 @@ export async function subscribe(
typeResolver,
subscribeFieldResolver,
} = args;

// If arguments are missing or incorrect, throw an error.
assertValidExecutionArguments(schema, document, variableValues);

// If a valid execution context cannot be created due to incorrect arguments,
// a "Response" with only errors is returned.
let exeContext: ExecutionContext;
Expand Down

0 comments on commit 3b5983f

Please sign in to comment.