1 | import { GraphQLSchema, GraphQLField, GraphQLInputType, GraphQLNamedType, GraphQLFieldResolver, GraphQLResolveInfo, GraphQLScalarType, DocumentNode, FieldNode, GraphQLEnumValue, GraphQLEnumType, GraphQLUnionType, GraphQLArgument, GraphQLInputField, GraphQLInputObjectType, GraphQLInterfaceType, GraphQLObjectType, GraphQLDirective, FragmentDefinitionNode, SelectionNode, OperationDefinitionNode, GraphQLError, ExecutionResult as GraphQLExecutionResult, GraphQLOutputType, FieldDefinitionNode, GraphQLFieldConfig, GraphQLInputFieldConfig, GraphQLArgumentConfig, GraphQLEnumValueConfig, GraphQLScalarSerializer, GraphQLScalarValueParser, GraphQLScalarLiteralParser, ScalarTypeDefinitionNode, ScalarTypeExtensionNode, EnumTypeDefinitionNode, EnumTypeExtensionNode, GraphQLIsTypeOfFn, ObjectTypeDefinitionNode, ObjectTypeExtensionNode, InterfaceTypeExtensionNode, InterfaceTypeDefinitionNode, GraphQLTypeResolver, UnionTypeDefinitionNode, UnionTypeExtensionNode, InputObjectTypeExtensionNode, InputObjectTypeDefinitionNode } from 'graphql';
|
2 | import { SchemaVisitor } from './SchemaVisitor';
|
3 | export interface ExecutionResult<TData = Record<string, any>> extends GraphQLExecutionResult {
|
4 | data?: TData | null;
|
5 | extensions?: Record<string, any>;
|
6 | }
|
7 | export declare type Result = ExecutionResult;
|
8 | export declare type TypeMap = Record<string, GraphQLNamedType>;
|
9 | export interface GraphQLExecutionContext {
|
10 | schema: GraphQLSchema;
|
11 | fragments: Record<string, FragmentDefinitionNode>;
|
12 | rootValue: any;
|
13 | contextValue: any;
|
14 | operation: OperationDefinitionNode;
|
15 | variableValues: Record<string, any>;
|
16 | fieldResolver: GraphQLFieldResolver<any, any>;
|
17 | errors: Array<GraphQLError>;
|
18 | }
|
19 | export interface GraphQLParseOptions {
|
20 | noLocation?: boolean;
|
21 | allowLegacySDLEmptyFields?: boolean;
|
22 | allowLegacySDLImplementsInterfaces?: boolean;
|
23 | experimentalFragmentVariables?: boolean;
|
24 | }
|
25 |
|
26 |
|
27 |
|
28 | export interface IResolverValidationOptions {
|
29 | |
30 |
|
31 |
|
32 |
|
33 | requireResolversForArgs?: boolean;
|
34 | |
35 |
|
36 |
|
37 |
|
38 | requireResolversForNonScalar?: boolean;
|
39 | |
40 |
|
41 |
|
42 |
|
43 | requireResolversForAllFields?: boolean;
|
44 | |
45 |
|
46 |
|
47 |
|
48 | requireResolversForResolveType?: boolean;
|
49 | |
50 |
|
51 |
|
52 |
|
53 | allowResolversNotInSchema?: boolean;
|
54 | }
|
55 |
|
56 |
|
57 |
|
58 | export interface IAddResolversToSchemaOptions {
|
59 | |
60 |
|
61 |
|
62 | schema: GraphQLSchema;
|
63 | |
64 |
|
65 |
|
66 | resolvers: IResolvers;
|
67 | |
68 |
|
69 |
|
70 | defaultFieldResolver?: IFieldResolver<any, any>;
|
71 | |
72 |
|
73 |
|
74 | resolverValidationOptions?: IResolverValidationOptions;
|
75 | |
76 |
|
77 |
|
78 |
|
79 | inheritResolversFromInterfaces?: boolean;
|
80 | |
81 |
|
82 |
|
83 | updateResolversInPlace?: boolean;
|
84 | }
|
85 | export declare type IScalarTypeResolver = GraphQLScalarType & {
|
86 | __name?: string;
|
87 | __description?: string;
|
88 | __serialize?: GraphQLScalarSerializer<any>;
|
89 | __parseValue?: GraphQLScalarValueParser<any>;
|
90 | __parseLiteral?: GraphQLScalarLiteralParser<any>;
|
91 | __extensions?: Record<string, any>;
|
92 | __astNode?: ScalarTypeDefinitionNode;
|
93 | __extensionASTNodes?: Array<ScalarTypeExtensionNode>;
|
94 | };
|
95 | export declare type IEnumTypeResolver = Record<string, any> & {
|
96 | __name?: string;
|
97 | __description?: string;
|
98 | __extensions?: Record<string, any>;
|
99 | __astNode?: EnumTypeDefinitionNode;
|
100 | __extensionASTNodes?: Array<EnumTypeExtensionNode>;
|
101 | };
|
102 | export interface IFieldResolverOptions<TSource = any, TContext = any, TArgs = any> {
|
103 | name?: string;
|
104 | description?: string;
|
105 | type?: GraphQLOutputType;
|
106 | args?: Array<GraphQLArgument>;
|
107 | resolve?: IFieldResolver<TSource, TContext, TArgs>;
|
108 | subscribe?: IFieldResolver<TSource, TContext, TArgs>;
|
109 | isDeprecated?: boolean;
|
110 | deprecationReason?: string;
|
111 | extensions?: Record<string, any>;
|
112 | astNode?: FieldDefinitionNode;
|
113 | }
|
114 | export declare type SchemaTransform = (originalSchema: GraphQLSchema) => GraphQLSchema;
|
115 | export declare type RequestTransform<T = Record<string, any>> = (originalRequest: Request, delegationContext?: Record<string, any>, transformationContext?: T) => Request;
|
116 | export declare type ResultTransform<T = Record<string, any>> = (originalResult: ExecutionResult, delegationContext?: Record<string, any>, transformationContext?: T) => ExecutionResult;
|
117 | export interface Transform<T = Record<string, any>> {
|
118 | transformSchema?: SchemaTransform;
|
119 | transformRequest?: RequestTransform<T>;
|
120 | transformResult?: ResultTransform<T>;
|
121 | }
|
122 | export declare type FieldNodeMapper = (fieldNode: FieldNode, fragments: Record<string, FragmentDefinitionNode>, transformationContext: Record<string, any>) => SelectionNode | Array<SelectionNode>;
|
123 | export declare type FieldNodeMappers = Record<string, Record<string, FieldNodeMapper>>;
|
124 | export declare type InputFieldFilter = (typeName?: string, fieldName?: string, inputFieldConfig?: GraphQLInputFieldConfig) => boolean;
|
125 | export declare type FieldFilter = (typeName?: string, fieldName?: string, fieldConfig?: GraphQLFieldConfig<any, any>) => boolean;
|
126 | export declare type RootFieldFilter = (operation?: 'Query' | 'Mutation' | 'Subscription', rootFieldName?: string, fieldConfig?: GraphQLFieldConfig<any, any>) => boolean;
|
127 | export declare type RenameTypesOptions = {
|
128 | renameBuiltins: boolean;
|
129 | renameScalars: boolean;
|
130 | };
|
131 | export declare type IFieldResolver<TSource, TContext, TArgs = Record<string, any>, TReturn = any> = (source: TSource, args: TArgs, context: TContext, info: GraphQLResolveInfo) => TReturn;
|
132 | export declare type ITypedef = (() => Array<ITypedef>) | string | DocumentNode;
|
133 | export declare type ITypeDefinitions = ITypedef | Array<ITypedef>;
|
134 | export declare type IObjectTypeResolver<TSource = any, TContext = any, TArgs = any> = {
|
135 | [key: string]: IFieldResolver<TSource, TContext, TArgs> | IFieldResolverOptions<TSource, TContext>;
|
136 | } & {
|
137 | __name?: string;
|
138 | __description?: string;
|
139 | __isTypeOf?: GraphQLIsTypeOfFn<TSource, TContext>;
|
140 | __extensions?: Record<string, any>;
|
141 | __astNode?: ObjectTypeDefinitionNode;
|
142 | __extensionASTNodes?: ObjectTypeExtensionNode;
|
143 | };
|
144 | export declare type IInterfaceTypeResolver<TSource = any, TContext = any, TArgs = any> = {
|
145 | [key: string]: IFieldResolver<TSource, TContext, TArgs> | IFieldResolverOptions<TSource, TContext>;
|
146 | } & {
|
147 | __name?: string;
|
148 | __description?: string;
|
149 | __resolveType?: GraphQLTypeResolver<any, any>;
|
150 | __extensions?: Record<string, any>;
|
151 | __astNode?: InterfaceTypeDefinitionNode;
|
152 | __extensionASTNodes?: Array<InterfaceTypeExtensionNode>;
|
153 | };
|
154 | export declare type IUnionTypeResolver = {
|
155 | __name?: string;
|
156 | __description?: string;
|
157 | __resolveType?: GraphQLTypeResolver<any, any>;
|
158 | __extensions?: Record<string, any>;
|
159 | __astNode?: UnionTypeDefinitionNode;
|
160 | __extensionASTNodes?: Array<UnionTypeExtensionNode>;
|
161 | };
|
162 | export declare type IInputObjectTypeResolver = {
|
163 | __name?: string;
|
164 | __description?: string;
|
165 | __extensions?: Record<string, any>;
|
166 | __astNode?: InputObjectTypeDefinitionNode;
|
167 | __extensionASTNodes?: Array<InputObjectTypeExtensionNode>;
|
168 | };
|
169 | export declare type ISchemaLevelResolver<TSource, TContext, TArgs = Record<string, any>, TReturn = any> = IFieldResolver<TSource, TContext, TArgs, TReturn>;
|
170 | export declare type IResolvers<TSource = any, TContext = any, TArgs = Record<string, any>, TReturn = any> = Record<string, ISchemaLevelResolver<TSource, TContext, TArgs, TReturn> | IObjectTypeResolver<TSource, TContext> | IInterfaceTypeResolver<TSource, TContext> | IUnionTypeResolver | IScalarTypeResolver | IEnumTypeResolver | IInputObjectTypeResolver>;
|
171 | export declare type IFieldIteratorFn = (fieldDef: GraphQLField<any, any>, typeName: string, fieldName: string) => void;
|
172 | export declare type IDefaultValueIteratorFn = (type: GraphQLInputType, value: any) => void;
|
173 | export declare type NextResolverFn = () => Promise<any>;
|
174 | export declare type DirectiveResolverFn<TSource = any, TContext = any> = (next: NextResolverFn, source: TSource, args: {
|
175 | [argName: string]: any;
|
176 | }, context: TContext, info: GraphQLResolveInfo) => any;
|
177 | export interface IDirectiveResolvers<TSource = any, TContext = any> {
|
178 | [directiveName: string]: DirectiveResolverFn<TSource, TContext>;
|
179 | }
|
180 | export declare type Operation = 'query' | 'mutation' | 'subscription';
|
181 | export interface Request {
|
182 | document: DocumentNode;
|
183 | variables: Record<string, any>;
|
184 | extensions?: Record<string, any>;
|
185 | }
|
186 | export declare type VisitableSchemaType = GraphQLSchema | GraphQLObjectType | GraphQLInterfaceType | GraphQLInputObjectType | GraphQLNamedType | GraphQLScalarType | GraphQLField<any, any> | GraphQLInputField | GraphQLArgument | GraphQLUnionType | GraphQLEnumType | GraphQLEnumValue;
|
187 | export declare type VisitorSelector = (type: VisitableSchemaType, methodName: string) => Array<SchemaVisitor | SchemaVisitorMap>;
|
188 | export declare enum VisitSchemaKind {
|
189 | TYPE = "VisitSchemaKind.TYPE",
|
190 | SCALAR_TYPE = "VisitSchemaKind.SCALAR_TYPE",
|
191 | ENUM_TYPE = "VisitSchemaKind.ENUM_TYPE",
|
192 | COMPOSITE_TYPE = "VisitSchemaKind.COMPOSITE_TYPE",
|
193 | OBJECT_TYPE = "VisitSchemaKind.OBJECT_TYPE",
|
194 | INPUT_OBJECT_TYPE = "VisitSchemaKind.INPUT_OBJECT_TYPE",
|
195 | ABSTRACT_TYPE = "VisitSchemaKind.ABSTRACT_TYPE",
|
196 | UNION_TYPE = "VisitSchemaKind.UNION_TYPE",
|
197 | INTERFACE_TYPE = "VisitSchemaKind.INTERFACE_TYPE",
|
198 | ROOT_OBJECT = "VisitSchemaKind.ROOT_OBJECT",
|
199 | QUERY = "VisitSchemaKind.QUERY",
|
200 | MUTATION = "VisitSchemaKind.MUTATION",
|
201 | SUBSCRIPTION = "VisitSchemaKind.SUBSCRIPTION"
|
202 | }
|
203 | export interface SchemaVisitorMap {
|
204 | [VisitSchemaKind.TYPE]?: NamedTypeVisitor;
|
205 | [VisitSchemaKind.SCALAR_TYPE]?: ScalarTypeVisitor;
|
206 | [VisitSchemaKind.ENUM_TYPE]?: EnumTypeVisitor;
|
207 | [VisitSchemaKind.COMPOSITE_TYPE]?: CompositeTypeVisitor;
|
208 | [VisitSchemaKind.OBJECT_TYPE]?: ObjectTypeVisitor;
|
209 | [VisitSchemaKind.INPUT_OBJECT_TYPE]?: InputObjectTypeVisitor;
|
210 | [VisitSchemaKind.ABSTRACT_TYPE]?: AbstractTypeVisitor;
|
211 | [VisitSchemaKind.UNION_TYPE]?: UnionTypeVisitor;
|
212 | [VisitSchemaKind.INTERFACE_TYPE]?: InterfaceTypeVisitor;
|
213 | [VisitSchemaKind.ROOT_OBJECT]?: ObjectTypeVisitor;
|
214 | [VisitSchemaKind.QUERY]?: ObjectTypeVisitor;
|
215 | [VisitSchemaKind.MUTATION]?: ObjectTypeVisitor;
|
216 | [VisitSchemaKind.SUBSCRIPTION]?: ObjectTypeVisitor;
|
217 | }
|
218 | export declare type NamedTypeVisitor = (type: GraphQLNamedType, schema: GraphQLSchema) => GraphQLNamedType | null | undefined;
|
219 | export declare type ScalarTypeVisitor = (type: GraphQLScalarType, schema: GraphQLSchema) => GraphQLScalarType | null | undefined;
|
220 | export declare type EnumTypeVisitor = (type: GraphQLEnumType, schema: GraphQLSchema) => GraphQLEnumType | null | undefined;
|
221 | export declare type CompositeTypeVisitor = (type: GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType, schema: GraphQLSchema) => GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType | null | undefined;
|
222 | export declare type ObjectTypeVisitor = (type: GraphQLObjectType, schema: GraphQLSchema) => GraphQLObjectType | null | undefined;
|
223 | export declare type InputObjectTypeVisitor = (type: GraphQLInputObjectType, schema: GraphQLSchema) => GraphQLInputObjectType | null | undefined;
|
224 | export declare type AbstractTypeVisitor = (type: GraphQLInterfaceType | GraphQLUnionType, schema: GraphQLSchema) => GraphQLInterfaceType | GraphQLUnionType | null | undefined;
|
225 | export declare type UnionTypeVisitor = (type: GraphQLUnionType, schema: GraphQLSchema) => GraphQLUnionType | null | undefined;
|
226 | export declare type InterfaceTypeVisitor = (type: GraphQLInterfaceType, schema: GraphQLSchema) => GraphQLInterfaceType | null | undefined;
|
227 | export declare enum MapperKind {
|
228 | TYPE = "MapperKind.TYPE",
|
229 | SCALAR_TYPE = "MapperKind.SCALAR_TYPE",
|
230 | ENUM_TYPE = "MapperKind.ENUM_TYPE",
|
231 | COMPOSITE_TYPE = "MapperKind.COMPOSITE_TYPE",
|
232 | OBJECT_TYPE = "MapperKind.OBJECT_TYPE",
|
233 | INPUT_OBJECT_TYPE = "MapperKind.INPUT_OBJECT_TYPE",
|
234 | ABSTRACT_TYPE = "MapperKind.ABSTRACT_TYPE",
|
235 | UNION_TYPE = "MapperKind.UNION_TYPE",
|
236 | INTERFACE_TYPE = "MapperKind.INTERFACE_TYPE",
|
237 | ROOT_OBJECT = "MapperKind.ROOT_OBJECT",
|
238 | QUERY = "MapperKind.QUERY",
|
239 | MUTATION = "MapperKind.MUTATION",
|
240 | SUBSCRIPTION = "MapperKind.SUBSCRIPTION",
|
241 | DIRECTIVE = "MapperKind.DIRECTIVE",
|
242 | FIELD = "MapperKind.FIELD",
|
243 | COMPOSITE_FIELD = "MapperKind.COMPOSITE_FIELD",
|
244 | OBJECT_FIELD = "MapperKind.OBJECT_FIELD",
|
245 | ROOT_FIELD = "MapperKind.ROOT_FIELD",
|
246 | QUERY_ROOT_FIELD = "MapperKind.QUERY_ROOT_FIELD",
|
247 | MUTATION_ROOT_FIELD = "MapperKind.MUTATION_ROOT_FIELD",
|
248 | SUBSCRIPTION_ROOT_FIELD = "MapperKind.SUBSCRIPTION_ROOT_FIELD",
|
249 | INTERFACE_FIELD = "MapperKind.INTERFACE_FIELD",
|
250 | INPUT_OBJECT_FIELD = "MapperKind.INPUT_OBJECT_FIELD",
|
251 | ARGUMENT = "MapperKind.ARGUMENT",
|
252 | ENUM_VALUE = "MapperKind.ENUM_VALUE"
|
253 | }
|
254 | export interface SchemaMapper {
|
255 | [MapperKind.TYPE]?: NamedTypeMapper;
|
256 | [MapperKind.SCALAR_TYPE]?: ScalarTypeMapper;
|
257 | [MapperKind.ENUM_TYPE]?: EnumTypeMapper;
|
258 | [MapperKind.COMPOSITE_TYPE]?: CompositeTypeMapper;
|
259 | [MapperKind.OBJECT_TYPE]?: ObjectTypeMapper;
|
260 | [MapperKind.INPUT_OBJECT_TYPE]?: InputObjectTypeMapper;
|
261 | [MapperKind.ABSTRACT_TYPE]?: AbstractTypeMapper;
|
262 | [MapperKind.UNION_TYPE]?: UnionTypeMapper;
|
263 | [MapperKind.INTERFACE_TYPE]?: InterfaceTypeMapper;
|
264 | [MapperKind.ROOT_OBJECT]?: ObjectTypeMapper;
|
265 | [MapperKind.QUERY]?: ObjectTypeMapper;
|
266 | [MapperKind.MUTATION]?: ObjectTypeMapper;
|
267 | [MapperKind.SUBSCRIPTION]?: ObjectTypeMapper;
|
268 | [MapperKind.ENUM_VALUE]?: EnumValueMapper;
|
269 | [MapperKind.FIELD]?: GenericFieldMapper<GraphQLFieldConfig<any, any> | GraphQLInputFieldConfig>;
|
270 | [MapperKind.OBJECT_FIELD]?: FieldMapper;
|
271 | [MapperKind.ROOT_FIELD]?: FieldMapper;
|
272 | [MapperKind.QUERY_ROOT_FIELD]?: FieldMapper;
|
273 | [MapperKind.MUTATION_ROOT_FIELD]?: FieldMapper;
|
274 | [MapperKind.SUBSCRIPTION_ROOT_FIELD]?: FieldMapper;
|
275 | [MapperKind.INTERFACE_FIELD]?: FieldMapper;
|
276 | [MapperKind.COMPOSITE_FIELD]?: FieldMapper;
|
277 | [MapperKind.ARGUMENT]?: ArgumentMapper;
|
278 | [MapperKind.INPUT_OBJECT_FIELD]?: InputFieldMapper;
|
279 | [MapperKind.DIRECTIVE]?: DirectiveMapper;
|
280 | }
|
281 | export declare type NamedTypeMapper = (type: GraphQLNamedType, schema: GraphQLSchema) => GraphQLNamedType | null | undefined;
|
282 | export declare type ScalarTypeMapper = (type: GraphQLScalarType, schema: GraphQLSchema) => GraphQLScalarType | null | undefined;
|
283 | export declare type EnumTypeMapper = (type: GraphQLEnumType, schema: GraphQLSchema) => GraphQLEnumType | null | undefined;
|
284 | export declare type EnumValueMapper = (valueConfig: GraphQLEnumValueConfig, typeName: string, schema: GraphQLSchema, externalValue: string) => GraphQLEnumValueConfig | [string, GraphQLEnumValueConfig] | null | undefined;
|
285 | export declare type CompositeTypeMapper = (type: GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType, schema: GraphQLSchema) => GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType | null | undefined;
|
286 | export declare type ObjectTypeMapper = (type: GraphQLObjectType, schema: GraphQLSchema) => GraphQLObjectType | null | undefined;
|
287 | export declare type InputObjectTypeMapper = (type: GraphQLInputObjectType, schema: GraphQLSchema) => GraphQLInputObjectType | null | undefined;
|
288 | export declare type AbstractTypeMapper = (type: GraphQLInterfaceType | GraphQLUnionType, schema: GraphQLSchema) => GraphQLInterfaceType | GraphQLUnionType | null | undefined;
|
289 | export declare type UnionTypeMapper = (type: GraphQLUnionType, schema: GraphQLSchema) => GraphQLUnionType | null | undefined;
|
290 | export declare type InterfaceTypeMapper = (type: GraphQLInterfaceType, schema: GraphQLSchema) => GraphQLInterfaceType | null | undefined;
|
291 | export declare type DirectiveMapper = (directive: GraphQLDirective, schema: GraphQLSchema) => GraphQLDirective | null | undefined;
|
292 | export declare type GenericFieldMapper<F extends GraphQLFieldConfig<any, any> | GraphQLInputFieldConfig> = (fieldConfig: F, fieldName: string, typeName: string, schema: GraphQLSchema) => F | [string, F] | null | undefined;
|
293 | export declare type FieldMapper = GenericFieldMapper<GraphQLFieldConfig<any, any>>;
|
294 | export declare type ArgumentMapper = (argumentConfig: GraphQLArgumentConfig, fieldName: string, typeName: string, schema: GraphQLSchema) => GraphQLArgumentConfig | [string, GraphQLArgumentConfig] | null | undefined;
|
295 | export declare type InputFieldMapper = GenericFieldMapper<GraphQLInputFieldConfig>;
|