Skip to content

Commit 168570f

Browse files
change 'CoercedVariableValues' to disjoint union (#2061)
1 parent e67f2e5 commit 168570f

File tree

2 files changed

+5
-11
lines changed

2 files changed

+5
-11
lines changed

src/execution/execute.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -324,16 +324,13 @@ export function buildExecutionContext(
324324
return coercedVariableValues.errors;
325325
}
326326

327-
const variableValues = coercedVariableValues.coerced;
328-
invariant(variableValues, 'Has variables if no errors.');
329-
330327
return {
331328
schema,
332329
fragments,
333330
rootValue,
334331
contextValue,
335332
operation,
336-
variableValues,
333+
variableValues: coercedVariableValues.coerced,
337334
fieldResolver: fieldResolver || defaultFieldResolver,
338335
typeResolver: typeResolver || defaultTypeResolver,
339336
errors: [],

src/execution/values.js

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,9 @@ import { coerceValue } from '../utilities/coerceValue';
2828
import { typeFromAST } from '../utilities/typeFromAST';
2929
import { valueFromAST } from '../utilities/valueFromAST';
3030

31-
type CoercedVariableValues = {|
32-
errors: $ReadOnlyArray<GraphQLError> | void,
33-
coerced: { [variable: string]: mixed, ... } | void,
34-
|};
31+
type CoercedVariableValues =
32+
| {| errors: $ReadOnlyArray<GraphQLError> |}
33+
| {| coerced: { [variable: string]: mixed, ... } |};
3534

3635
/**
3736
* Prepares an object map of variableValues of the correct type based on the
@@ -108,9 +107,7 @@ export function getVariableValues(
108107
coercedValues[varName] = coerced.value;
109108
}
110109

111-
return errors.length === 0
112-
? { errors: undefined, coerced: coercedValues }
113-
: { errors, coerced: undefined };
110+
return errors.length === 0 ? { coerced: coercedValues } : { errors };
114111
}
115112

116113
/**

0 commit comments

Comments
 (0)