Skip to content

Commit

Permalink
change 'CoercedVariableValues' to disjoint union (#2061)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov committed Jul 29, 2019
1 parent e67f2e5 commit 168570f
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 11 deletions.
5 changes: 1 addition & 4 deletions src/execution/execute.js
Expand Up @@ -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: [],
Expand Down
11 changes: 4 additions & 7 deletions src/execution/values.js
Expand Up @@ -28,10 +28,9 @@ import { coerceValue } from '../utilities/coerceValue';
import { typeFromAST } from '../utilities/typeFromAST';
import { valueFromAST } from '../utilities/valueFromAST';

type CoercedVariableValues = {|
errors: $ReadOnlyArray<GraphQLError> | void,
coerced: { [variable: string]: mixed, ... } | void,
|};
type CoercedVariableValues =
| {| errors: $ReadOnlyArray<GraphQLError> |}
| {| coerced: { [variable: string]: mixed, ... } |};

/**
* Prepares an object map of variableValues of the correct type based on the
Expand Down Expand Up @@ -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 };
}

/**
Expand Down

0 comments on commit 168570f

Please sign in to comment.