diff --git a/src/execution/subscribe.ts b/src/execution/subscribe.ts index e0d1a27be6..957724eb7f 100644 --- a/src/execution/subscribe.ts +++ b/src/execution/subscribe.ts @@ -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.