UNPKG

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