Skip to content

Commit

Permalink
zap context.errors
Browse files Browse the repository at this point in the history
  • Loading branch information
mohawk2 committed Dec 17, 2017
1 parent d68d506 commit 20d2089
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions src/execution/execute.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ export type ExecutionContext = {
operation: OperationDefinitionNode,
variableValues: { [variable: string]: mixed },
fieldResolver: GraphQLFieldResolver<any, any>,
errors: Array<GraphQLError>,
};

/**
Expand Down Expand Up @@ -235,21 +234,17 @@ 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 result = executeOperation(context, context.operation, rootValue);
return buildResponse(context, result);
const data = executeOperation(context, context.operation, rootValue);
return buildResponse(data);
}

/**
* Given a completed execution context and data, build the { errors, data }
* response defined by the "Response" section of the GraphQL specification.
* Strip out `errors` if empty.
*/
function buildResponse(
context: ExecutionContext,
result: ExecutionPartialResult<mixed>,
) {
function buildResponse(result: ExecutionPartialResult<mixed>) {
const promise = getPromise(result);
if (promise) {
return promise.then(resolved => buildResponse(context, resolved));
return promise.then(resolved => buildResponse(resolved));
}
if (result.data && (!result.errors || !result.errors.length)) {
return { data: result.data };
Expand Down Expand Up @@ -389,7 +384,6 @@ export function buildExecutionContext(
operation,
variableValues,
fieldResolver: fieldResolver || defaultFieldResolver,
errors,
};
}

Expand Down

0 comments on commit 20d2089

Please sign in to comment.