UNPKG

607 BTypeScriptView Raw
1import { Path } from '../jsutils/Path';
2import { GraphQLError } from '../error/GraphQLError';
3import { ASTNode } from '../language/ast';
4import { GraphQLInputType } from '../type/definition';
5
6interface CoercedValue {
7 readonly errors: ReadonlyArray<GraphQLError> | undefined;
8 readonly value: any;
9}
10
11/**
12 * Coerces a JavaScript value given a GraphQL Type.
13 *
14 * Returns either a value which is valid for the provided type or a list of
15 * encountered coercion errors.
16 *
17 */
18export function coerceValue(
19 inputValue: any,
20 type: GraphQLInputType,
21 blameNode?: ASTNode,
22 path?: Path,
23): CoercedValue;