1 | import Maybe from '../tsutils/Maybe';
|
2 | import { PromiseOrValue } from '../jsutils/PromiseOrValue';
|
3 | import { Path, addPath, pathToArray } from '../jsutils/Path';
|
4 |
|
5 | import { GraphQLError } from '../error/GraphQLError';
|
6 | import { locatedError } from '../error/locatedError';
|
7 |
|
8 | import {
|
9 | DirectiveNode,
|
10 | DocumentNode,
|
11 | OperationDefinitionNode,
|
12 | SelectionSetNode,
|
13 | FieldNode,
|
14 | InlineFragmentNode,
|
15 | FragmentDefinitionNode,
|
16 | } from '../language/ast';
|
17 | import { GraphQLSchema } from '../type/schema';
|
18 | import {
|
19 | GraphQLField,
|
20 | GraphQLFieldResolver,
|
21 | GraphQLResolveInfo,
|
22 | GraphQLTypeResolver,
|
23 | GraphQLObjectType,
|
24 | } from '../type/definition';
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 | export interface ExecutionContext {
|
33 | schema: GraphQLSchema;
|
34 | fragments: { [key: string]: FragmentDefinitionNode };
|
35 | rootValue: any;
|
36 | contextValue: any;
|
37 | operation: OperationDefinitionNode;
|
38 | variableValues: { [key: string]: any };
|
39 | fieldResolver: GraphQLFieldResolver<any, any>;
|
40 | errors: GraphQLError[];
|
41 | }
|
42 |
|
43 | export interface ExecutionResultDataDefault {
|
44 | [key: string]: any;
|
45 | }
|
46 |
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 | export interface ExecutionResult<TData = ExecutionResultDataDefault> {
|
55 | errors?: ReadonlyArray<GraphQLError>;
|
56 | data?: TData | null;
|
57 | }
|
58 |
|
59 | export type ExecutionArgs = {
|
60 | schema: GraphQLSchema;
|
61 | document: DocumentNode;
|
62 | rootValue?: any;
|
63 | contextValue?: any;
|
64 | variableValues?: Maybe<{ [key: string]: any }>;
|
65 | operationName?: Maybe<string>;
|
66 | fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>;
|
67 | typeResolver?: Maybe<GraphQLTypeResolver<any, any>>;
|
68 | };
|
69 |
|
70 |
|
71 |
|
72 |
|
73 |
|
74 |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 | export function execute<TData = ExecutionResultDataDefault>(
|
83 | args: ExecutionArgs,
|
84 | ): PromiseOrValue<ExecutionResult<TData>>;
|
85 | export function execute<TData = ExecutionResultDataDefault>(
|
86 | schema: GraphQLSchema,
|
87 | document: DocumentNode,
|
88 | rootValue?: any,
|
89 | contextValue?: any,
|
90 | variableValues?: Maybe<{ [key: string]: any }>,
|
91 | operationName?: Maybe<string>,
|
92 | fieldResolver?: Maybe<GraphQLFieldResolver<any, any>>,
|
93 | typeResolver?: Maybe<GraphQLTypeResolver<any, any>>,
|
94 | ): PromiseOrValue<ExecutionResult<TData>>;
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 | export function assertValidExecutionArguments(
|
101 | schema: GraphQLSchema,
|
102 | document: DocumentNode,
|
103 | rawVariableValues: Maybe<{ [key: string]: any }>,
|
104 | ): void;
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 | export function buildExecutionContext(
|
113 | schema: GraphQLSchema,
|
114 | document: DocumentNode,
|
115 | rootValue: any,
|
116 | contextValue: any,
|
117 | rawVariableValues: Maybe<{ [key: string]: any }>,
|
118 | operationName: Maybe<string>,
|
119 | fieldResolver: Maybe<GraphQLFieldResolver<any, any>>,
|
120 | typeResolver?: Maybe<GraphQLTypeResolver<any, any>>,
|
121 | ): ReadonlyArray<GraphQLError> | ExecutionContext;
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 | export function collectFields(
|
132 | exeContext: ExecutionContext,
|
133 | runtimeType: GraphQLObjectType,
|
134 | selectionSet: SelectionSetNode,
|
135 | fields: { [key: string]: Array<FieldNode> },
|
136 | visitedFragmentNames: { [key: string]: boolean },
|
137 | ): { [key: string]: Array<FieldNode> };
|
138 |
|
139 | export function buildResolveInfo(
|
140 | exeContext: ExecutionContext,
|
141 | fieldDef: GraphQLField<any, any>,
|
142 | fieldNodes: ReadonlyArray<FieldNode>,
|
143 | parentType: GraphQLObjectType,
|
144 | path: Path,
|
145 | ): GraphQLResolveInfo;
|
146 |
|
147 |
|
148 |
|
149 |
|
150 | export function resolveFieldValueOrError<TSource>(
|
151 | exeContext: ExecutionContext,
|
152 | fieldDef: GraphQLField<TSource, any>,
|
153 | fieldNodes: ReadonlyArray<FieldNode>,
|
154 | resolveFn: GraphQLFieldResolver<TSource, any>,
|
155 | source: TSource,
|
156 | info: GraphQLResolveInfo,
|
157 | ): Error | any;
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 |
|
165 |
|
166 |
|
167 |
|
168 |
|
169 | export const defaultTypeResolver: GraphQLTypeResolver<any, any>;
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 | export const defaultFieldResolver: GraphQLFieldResolver<any, any>;
|
178 |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 | export function getFieldDef(
|
189 | schema: GraphQLSchema,
|
190 | parentType: GraphQLObjectType,
|
191 | fieldName: string,
|
192 | ): Maybe<GraphQLField<any, any>>;
|