Skip to content

Move call site for assertValidExecutionArguments #3

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions src/execution/execute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,6 @@ export interface ExecutionArgs {
* a GraphQLError will be thrown immediately explaining the invalid input.
*/
export function execute(args: ExecutionArgs): PromiseOrValue<ExecutionResult> {
const { schema, document, variableValues } = 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.
const exeContext = buildExecutionContext(args);
Expand Down Expand Up @@ -212,10 +207,8 @@ function buildResponse(
/**
* Essential assertions before executing to provide developer feedback for
* improper use of the GraphQL library.
*
* @internal
*/
export function assertValidExecutionArguments(
function assertValidExecutionArguments(
schema: GraphQLSchema,
document: DocumentNode,
rawVariableValues: Maybe<{ readonly [variable: string]: unknown }>,
Expand Down Expand Up @@ -255,6 +248,10 @@ export function buildExecutionContext(
subscribeFieldResolver,
} = args;

// If arguments are missing or incorrectly typed, this is an internal
// developer mistake which should 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
11 changes: 0 additions & 11 deletions src/execution/subscribe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import type { ExecutionArgs, ExecutionContext } from './execute';
import { collectFields } from './collectFields';
import { getArgumentValues } from './values';
import {
assertValidExecutionArguments,
buildExecutionContext,
buildResolveInfo,
executeQueryOrMutation,
Expand Down Expand Up @@ -49,12 +48,6 @@ import { mapAsyncIterator } from './mapAsyncIterator';
export async function subscribe(
args: ExecutionArgs,
): Promise<AsyncGenerator<ExecutionResult, void, void> | ExecutionResult> {
const { schema, document, variableValues } = args;

// If arguments are missing or incorrectly typed, this is an internal
// developer mistake which should throw an early error.
assertValidExecutionArguments(schema, document, variableValues);

// If a valid execution context cannot be created due to incorrect arguments,
// a "Response" with only errors is returned.
const exeContext = buildExecutionContext(args);
Expand Down Expand Up @@ -130,10 +123,6 @@ export async function createSourceEventStream(
operationName?: Maybe<string>,
subscribeFieldResolver?: Maybe<GraphQLFieldResolver<any, any>>,
): Promise<AsyncIterable<unknown> | ExecutionResult> {
// If arguments are missing or incorrectly typed, this is an internal
// developer mistake which should throw an early error.
assertValidExecutionArguments(schema, document, variableValues);

// If a valid execution context cannot be created due to incorrect arguments,
// a "Response" with only errors is returned.
const exeContext = buildExecutionContext({
Expand Down