Skip to content
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

Align calls of buildExecutionContext #3293

Merged
merged 1 commit into from Oct 9, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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.
IvanGoncharov marked this conversation as resolved.
Show resolved Hide resolved
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