From 0195b30c89b7b259741ee845276db01db0bb27ef Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Sat, 21 Apr 2018 17:30:35 +0300 Subject: [PATCH 1/3] Execute: use consistent name for execution context --- src/execution/execute.js | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/execution/execute.js b/src/execution/execute.js index b8e958bc10..76284634d6 100644 --- a/src/execution/execute.js +++ b/src/execution/execute.js @@ -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, @@ -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 @@ -217,8 +217,8 @@ 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, rootValue); + return buildResponse(exeContext, data); } /** @@ -226,15 +226,15 @@ function executeImpl( * response defined by the "Response" section of the GraphQL specification. */ function buildResponse( - context: ExecutionContext, + exeContext: ExecutionContext, data: MaybePromise | 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 }; } /** @@ -378,9 +378,9 @@ export function buildExecutionContext( */ function executeOperation( exeContext: ExecutionContext, - operation: OperationDefinitionNode, rootValue: mixed, ): MaybePromise | null> { + const operation = exeContext.operation; const type = getOperationRootType(exeContext.schema, operation); const fields = collectFields( exeContext, From 571f2bc97f2671f21483fdec1949e9ca7946a3b2 Mon Sep 17 00:00:00 2001 From: Lee Byron Date: Mon, 23 Apr 2018 13:42:41 -0700 Subject: [PATCH 2/3] Address review --- src/execution/execute.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/execution/execute.js b/src/execution/execute.js index 76284634d6..439ef80a5a 100644 --- a/src/execution/execute.js +++ b/src/execution/execute.js @@ -217,7 +217,7 @@ 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(exeContext, rootValue); + const data = executeOperation(exeContext, context.operation, rootValue); return buildResponse(exeContext, data); } @@ -378,6 +378,7 @@ export function buildExecutionContext( */ function executeOperation( exeContext: ExecutionContext, + operation: OperationDefinitionNode, rootValue: mixed, ): MaybePromise | null> { const operation = exeContext.operation; From 4db01f3febb495cd28ca7300d76da8118efd8b4b Mon Sep 17 00:00:00 2001 From: Lee Byron Date: Mon, 23 Apr 2018 13:43:20 -0700 Subject: [PATCH 3/3] Addendum --- src/execution/execute.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/execution/execute.js b/src/execution/execute.js index 439ef80a5a..88ace527c0 100644 --- a/src/execution/execute.js +++ b/src/execution/execute.js @@ -381,7 +381,6 @@ function executeOperation( operation: OperationDefinitionNode, rootValue: mixed, ): MaybePromise | null> { - const operation = exeContext.operation; const type = getOperationRootType(exeContext.schema, operation); const fields = collectFields( exeContext,