Skip to content

Commit 2f91eb8

Browse files
committed
refactor: move assertValidExecutionArguments into buildExecutionContext
`assertValidExecutionArguments` is only called immediately prior to `buildExecutionContext` and `buildExecutionContext` is never called without calling `assertValidExecutionArguments` immediately prior.
1 parent e24f426 commit 2f91eb8

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/execution/execute.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -162,10 +162,7 @@ export interface ExecutionArgs {
162162
* a GraphQLError will be thrown immediately explaining the invalid input.
163163
*/
164164
export function execute(args: ExecutionArgs): PromiseOrValue<ExecutionResult> {
165-
const { schema, document, variableValues, rootValue } = args;
166-
167-
// If arguments are missing or incorrect, throw an error.
168-
assertValidExecutionArguments(schema, document, variableValues);
165+
const { rootValue } = args;
169166

170167
// If a valid execution context cannot be created due to incorrect arguments,
171168
// a "Response" with only errors is returned.
@@ -281,6 +278,9 @@ export function buildExecutionContext(
281278
subscribeFieldResolver,
282279
} = args;
283280

281+
// If arguments are missing or incorrect, throw an error.
282+
assertValidExecutionArguments(schema, document, rawVariableValues);
283+
284284
let operation: OperationDefinitionNode | undefined;
285285
const fragments: ObjMap<FragmentDefinitionNode> = Object.create(null);
286286
for (const definition of document.definitions) {
@@ -1117,10 +1117,6 @@ export function createSourceEventStream(
11171117
subscribeFieldResolver,
11181118
} = args;
11191119

1120-
// If arguments are missing or incorrectly typed, this is an internal
1121-
// developer mistake which should throw an early error.
1122-
assertValidExecutionArguments(schema, document, variableValues);
1123-
11241120
// If a valid execution context cannot be created due to incorrect arguments,
11251121
// a "Response" with only errors is returned.
11261122
const exeContext = buildExecutionContext({

0 commit comments

Comments
 (0)