UNPKG

1.01 kBTypeScriptView Raw
1import type { Maybe } from '../jsutils/Maybe';
2import type { ValueNode } from '../language/ast';
3import type { GraphQLInputType } from '../type/definition';
4/**
5 * Produces a GraphQL Value AST given a JavaScript object.
6 * Function will match JavaScript/JSON values to GraphQL AST schema format
7 * by using suggested GraphQLInputType. For example:
8 *
9 * astFromValue("value", GraphQLString)
10 *
11 * A GraphQL type must be provided, which will be used to interpret different
12 * JavaScript values.
13 *
14 * | JSON Value | GraphQL Value |
15 * | ------------- | -------------------- |
16 * | Object | Input Object |
17 * | Array | List |
18 * | Boolean | Boolean |
19 * | String | String / Enum Value |
20 * | Number | Int / Float |
21 * | Unknown | Enum Value |
22 * | null | NullValue |
23 *
24 */
25export declare function astFromValue(
26 value: unknown,
27 type: GraphQLInputType,
28): Maybe<ValueNode>;