From 168570ff61cb9b7b7c2fcf6c95848919d9f397cd Mon Sep 17 00:00:00 2001 From: Ivan Goncharov Date: Mon, 29 Jul 2019 17:10:10 +0300 Subject: [PATCH] change 'CoercedVariableValues' to disjoint union (#2061) --- src/execution/execute.js | 5 +---- src/execution/values.js | 11 ++++------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/execution/execute.js b/src/execution/execute.js index 679fa27cba..79a3b77062 100644 --- a/src/execution/execute.js +++ b/src/execution/execute.js @@ -324,16 +324,13 @@ export function buildExecutionContext( return coercedVariableValues.errors; } - const variableValues = coercedVariableValues.coerced; - invariant(variableValues, 'Has variables if no errors.'); - return { schema, fragments, rootValue, contextValue, operation, - variableValues, + variableValues: coercedVariableValues.coerced, fieldResolver: fieldResolver || defaultFieldResolver, typeResolver: typeResolver || defaultTypeResolver, errors: [], diff --git a/src/execution/values.js b/src/execution/values.js index e12b828b8d..d4dd60e9e5 100644 --- a/src/execution/values.js +++ b/src/execution/values.js @@ -28,10 +28,9 @@ import { coerceValue } from '../utilities/coerceValue'; import { typeFromAST } from '../utilities/typeFromAST'; import { valueFromAST } from '../utilities/valueFromAST'; -type CoercedVariableValues = {| - errors: $ReadOnlyArray | void, - coerced: { [variable: string]: mixed, ... } | void, -|}; +type CoercedVariableValues = + | {| errors: $ReadOnlyArray |} + | {| coerced: { [variable: string]: mixed, ... } |}; /** * Prepares an object map of variableValues of the correct type based on the @@ -108,9 +107,7 @@ export function getVariableValues( coercedValues[varName] = coerced.value; } - return errors.length === 0 - ? { errors: undefined, coerced: coercedValues } - : { errors, coerced: undefined }; + return errors.length === 0 ? { coerced: coercedValues } : { errors }; } /**