1 | import { Maybe } from '../jsutils/Maybe';
|
2 |
|
3 | import { GraphQLError } from '../error/GraphQLError';
|
4 | import {
|
5 | FieldNode,
|
6 | DirectiveNode,
|
7 | VariableDefinitionNode,
|
8 | } from '../language/ast';
|
9 |
|
10 | import { GraphQLDirective } from '../type/directives';
|
11 | import { GraphQLSchema } from '../type/schema';
|
12 | import { GraphQLField } from '../type/definition';
|
13 |
|
14 | type CoercedVariableValues =
|
15 | | { errors: ReadonlyArray<GraphQLError>; coerced?: never }
|
16 | | { errors?: never; coerced: { [key: string]: any } };
|
17 |
|
18 | /**
|
19 | * Prepares an object map of variableValues of the correct type based on the
|
20 | * provided variable definitions and arbitrary input. If the input cannot be
|
21 | * parsed to match the variable definitions, a GraphQLError will be thrown.
|
22 | *
|
23 | * Note: The returned value is a plain Object with a prototype, since it is
|
24 | * exposed to user code. Care should be taken to not pull values from the
|
25 | * Object prototype.
|
26 | */
|
27 | export function getVariableValues(
|
28 | schema: GraphQLSchema,
|
29 | varDefNodes: ReadonlyArray<VariableDefinitionNode>,
|
30 | inputs: { [key: string]: any },
|
31 | options?: { maxErrors?: number },
|
32 | ): CoercedVariableValues;
|
33 |
|
34 | /**
|
35 | * Prepares an object map of argument values given a list of argument
|
36 | * definitions and list of argument AST nodes.
|
37 | *
|
38 | * Note: The returned value is a plain Object with a prototype, since it is
|
39 | * exposed to user code. Care should be taken to not pull values from the
|
40 | * Object prototype.
|
41 | */
|
42 | export function getArgumentValues(
|
43 | def: GraphQLField<any, any> | GraphQLDirective,
|
44 | node: FieldNode | DirectiveNode,
|
45 | variableValues?: Maybe<{ [key: string]: any }>,
|
46 | ): { [key: string]: any };
|
47 |
|
48 | /**
|
49 | * Prepares an object map of argument values given a directive definition
|
50 | * and a AST node which may contain directives. Optionally also accepts a map
|
51 | * of variable values.
|
52 | *
|
53 | * If the directive does not exist on the node, returns undefined.
|
54 | *
|
55 | * Note: The returned value is a plain Object with a prototype, since it is
|
56 | * exposed to user code. Care should be taken to not pull values from the
|
57 | * Object prototype.
|
58 | */
|
59 | export function getDirectiveValues(
|
60 | directiveDef: GraphQLDirective,
|
61 | node: {
|
62 | readonly directives?: ReadonlyArray<DirectiveNode>;
|
63 | },
|
64 | variableValues?: Maybe<{ [key: string]: any }>,
|
65 | ): undefined | { [key: string]: any };
|