UNPKG

960 BTypeScriptView Raw
1import Maybe from '../tsutils/Maybe';
2import { ValueNode } from '../language/ast';
3import { GraphQLInputType } from '../type/definition';
4
5/**
6 * Produces a JavaScript value given a GraphQL Value AST.
7 *
8 * A GraphQL type must be provided, which will be used to interpret different
9 * GraphQL Value literals.
10 *
11 * Returns `undefined` when the value could not be validly coerced according to
12 * the provided type.
13 *
14 * | GraphQL Value | JSON Value |
15 * | -------------------- | ------------- |
16 * | Input Object | Object |
17 * | List | Array |
18 * | Boolean | Boolean |
19 * | String | String |
20 * | Int / Float | Number |
21 * | Enum Value | Mixed |
22 * | NullValue | null |
23 *
24 */
25export function valueFromAST(
26 valueNode: Maybe<ValueNode>,
27 type: GraphQLInputType,
28 variables?: Maybe<{ [key: string]: any }>,
29): any;