Skip to content

Commit

Permalink
Align calls of buildExecutionContext (#3293)
Browse files Browse the repository at this point in the history
  • Loading branch information
yaacovCR committed Oct 9, 2021
1 parent 588d096 commit 239aa33
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions src/execution/subscribe.ts
Expand Up @@ -147,23 +147,24 @@ export async function createSourceEventStream(
// developer mistake which should throw an early error.
assertValidExecutionArguments(schema, document, variableValues);

try {
// If a valid context cannot be created due to incorrect arguments, this will throw an error.
const exeContext = buildExecutionContext(
schema,
document,
rootValue,
contextValue,
variableValues,
operationName,
fieldResolver,
);
// If a valid execution context cannot be created due to incorrect arguments,
// a "Response" with only errors is returned.
const exeContext = buildExecutionContext(
schema,
document,
rootValue,
contextValue,
variableValues,
operationName,
fieldResolver,
);

// Return early errors if execution context failed.
if (!('schema' in exeContext)) {
return { errors: exeContext };
}
// Return early errors if execution context failed.
if (!('schema' in exeContext)) {
return { errors: exeContext };
}

try {
const eventStream = await executeSubscription(exeContext);

// Assert field returned an event stream, otherwise yield an error.
Expand Down

0 comments on commit 239aa33

Please sign in to comment.