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

Execute: use consistent name for execution context #1318

Closed
wants to merge 3 commits into from
Closed
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
18 changes: 9 additions & 9 deletions src/execution/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ function executeImpl(

// If a valid context cannot be created due to incorrect arguments,
// a "Response" with only errors is returned.
const context = buildExecutionContext(
const exeContext = buildExecutionContext(
schema,
document,
rootValue,
Expand All @@ -206,8 +206,8 @@ function executeImpl(
);

// Return early errors if execution context failed.
if (Array.isArray(context)) {
return { errors: context };
if (Array.isArray(exeContext)) {
return { errors: exeContext };
}

// Return a Promise that will eventually resolve to the data described by
Expand All @@ -217,24 +217,24 @@ function executeImpl(
// field and its descendants will be omitted, and sibling fields will still
// be executed. An execution which encounters errors will still result in a
// resolved Promise.
const data = executeOperation(context, context.operation, rootValue);
return buildResponse(context, data);
const data = executeOperation(exeContext, context.operation, rootValue);
return buildResponse(exeContext, data);
}

/**
* Given a completed execution context and data, build the { errors, data }
* response defined by the "Response" section of the GraphQL specification.
*/
function buildResponse(
context: ExecutionContext,
exeContext: ExecutionContext,
data: MaybePromise<ObjMap<mixed> | null>,
) {
if (isPromise(data)) {
return data.then(resolved => buildResponse(context, resolved));
return data.then(resolved => buildResponse(exeContext, resolved));
}
return context.errors.length === 0
return exeContext.errors.length === 0
? { data }
: { errors: context.errors, data };
: { errors: exeContext.errors, data };
}

/**
Expand Down