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

change 'CoercedVariableValues' to disjoint union #2061

Merged
merged 1 commit into from
Jul 29, 2019
Merged
Show file tree
Hide file tree
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
5 changes: 1 addition & 4 deletions src/execution/execute.js
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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