1 | import { DefinitionNode, DocumentNode, EnumTypeDefinitionNode, EnumTypeExtensionNode, FieldDefinitionNode, FieldNode, FragmentDefinitionNode, GraphQLArgument, GraphQLArgumentConfig, GraphQLDirective, GraphQLEnumType, GraphQLEnumValue, GraphQLEnumValueConfig, GraphQLError, GraphQLField, GraphQLFieldConfig, GraphQLInputField, GraphQLInputFieldConfig, GraphQLInputObjectType, GraphQLInputType, GraphQLInterfaceType, GraphQLIsTypeOfFn, GraphQLNamedType, GraphQLObjectType, GraphQLOutputType, GraphQLResolveInfo, GraphQLScalarLiteralParser, GraphQLScalarSerializer, GraphQLScalarType, GraphQLScalarValueParser, GraphQLSchema, GraphQLType, GraphQLTypeResolver, GraphQLUnionType, InputObjectTypeDefinitionNode, InputObjectTypeExtensionNode, InterfaceTypeDefinitionNode, InterfaceTypeExtensionNode, ObjectTypeDefinitionNode, ObjectTypeExtensionNode, OperationTypeNode, ScalarTypeDefinitionNode, ScalarTypeExtensionNode, SelectionNode, Source, UnionTypeDefinitionNode, UnionTypeExtensionNode } from 'graphql';
|
2 | import { TypedDocumentNode } from '@graphql-typed-document-node/core';
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 | export interface ExecutionResult<TData = any, TExtensions = any> {
|
12 | incremental?: ReadonlyArray<ExecutionResult<TData, TExtensions>>;
|
13 | data?: TData | null;
|
14 | errors?: ReadonlyArray<GraphQLError>;
|
15 | hasNext?: boolean;
|
16 | extensions?: TExtensions;
|
17 | label?: string;
|
18 | path?: ReadonlyArray<string | number>;
|
19 | items?: TData | null;
|
20 | }
|
21 | export interface ExecutionRequest<TVariables extends Record<string, any> = any, TContext = any, TRootValue = any, TExtensions = Record<string, any>, TReturn = any> {
|
22 | document: TypedDocumentNode<TReturn, TVariables>;
|
23 | variables?: TVariables;
|
24 | operationType?: OperationTypeNode;
|
25 | operationName?: string;
|
26 | extensions?: TExtensions;
|
27 | rootValue?: TRootValue;
|
28 | context?: TContext;
|
29 | info?: GraphQLResolveInfo;
|
30 | }
|
31 | export interface GraphQLParseOptions {
|
32 | noLocation?: boolean;
|
33 | allowLegacySDLEmptyFields?: boolean;
|
34 | allowLegacySDLImplementsInterfaces?: boolean;
|
35 | experimentalFragmentVariables?: boolean;
|
36 | |
37 |
|
38 |
|
39 |
|
40 |
|
41 | commentDescriptions?: boolean;
|
42 | }
|
43 | export type ValidatorBehavior = 'error' | 'warn' | 'ignore';
|
44 |
|
45 |
|
46 |
|
47 | export interface IResolverValidationOptions {
|
48 | |
49 |
|
50 |
|
51 |
|
52 | requireResolversForArgs?: ValidatorBehavior;
|
53 | |
54 |
|
55 |
|
56 |
|
57 | requireResolversForNonScalar?: ValidatorBehavior;
|
58 | |
59 |
|
60 |
|
61 |
|
62 | requireResolversForAllFields?: ValidatorBehavior;
|
63 | |
64 |
|
65 |
|
66 |
|
67 | requireResolversForResolveType?: ValidatorBehavior;
|
68 | |
69 |
|
70 |
|
71 |
|
72 | requireResolversToMatchSchema?: ValidatorBehavior;
|
73 | }
|
74 |
|
75 |
|
76 |
|
77 | export interface IAddResolversToSchemaOptions {
|
78 | |
79 |
|
80 |
|
81 | schema: GraphQLSchema;
|
82 | |
83 |
|
84 |
|
85 | resolvers: IResolvers;
|
86 | |
87 |
|
88 |
|
89 | defaultFieldResolver?: IFieldResolver<any, any>;
|
90 | |
91 |
|
92 |
|
93 | resolverValidationOptions?: IResolverValidationOptions;
|
94 | |
95 |
|
96 |
|
97 |
|
98 | inheritResolversFromInterfaces?: boolean;
|
99 | |
100 |
|
101 |
|
102 | updateResolversInPlace?: boolean;
|
103 | }
|
104 | export type IScalarTypeResolver = GraphQLScalarType & {
|
105 | __name?: string;
|
106 | __description?: string;
|
107 | __serialize?: GraphQLScalarSerializer<any>;
|
108 | __parseValue?: GraphQLScalarValueParser<any>;
|
109 | __parseLiteral?: GraphQLScalarLiteralParser<any>;
|
110 | __extensions?: Record<string, any>;
|
111 | __astNode?: ScalarTypeDefinitionNode;
|
112 | __extensionASTNodes?: Array<ScalarTypeExtensionNode>;
|
113 | };
|
114 | export type IEnumTypeResolver = Record<string, any> & {
|
115 | __name?: string;
|
116 | __description?: string;
|
117 | __extensions?: Record<string, any>;
|
118 | __astNode?: EnumTypeDefinitionNode;
|
119 | __extensionASTNodes?: Array<EnumTypeExtensionNode>;
|
120 | };
|
121 | export interface IFieldResolverOptions<TSource = any, TContext = any, TArgs = any> {
|
122 | name?: string;
|
123 | description?: string;
|
124 | type?: GraphQLOutputType;
|
125 | args?: Array<GraphQLArgument>;
|
126 | resolve?: IFieldResolver<TSource, TContext, TArgs>;
|
127 | subscribe?: IFieldResolver<TSource, TContext, TArgs>;
|
128 | isDeprecated?: boolean;
|
129 | deprecationReason?: string;
|
130 | extensions?: Record<string, any>;
|
131 | astNode?: FieldDefinitionNode;
|
132 | }
|
133 | export type FieldNodeMapper = (fieldNode: FieldNode, fragments: Record<string, FragmentDefinitionNode>, transformationContext: Record<string, any>) => SelectionNode | Array<SelectionNode>;
|
134 | export type FieldNodeMappers = Record<string, Record<string, FieldNodeMapper>>;
|
135 | export type InputFieldFilter = (typeName?: string, fieldName?: string, inputFieldConfig?: GraphQLInputFieldConfig) => boolean;
|
136 | export type FieldFilter = (typeName: string, fieldName: string, fieldConfig: GraphQLFieldConfig<any, any> | GraphQLInputFieldConfig) => boolean;
|
137 | export type ObjectFieldFilter = (typeName: string, fieldName: string, fieldConfig: GraphQLFieldConfig<any, any>) => boolean;
|
138 | export type RootFieldFilter = (operation: 'Query' | 'Mutation' | 'Subscription', rootFieldName: string, fieldConfig: GraphQLFieldConfig<any, any>) => boolean;
|
139 | export type TypeFilter = (typeName: string, type: GraphQLType) => boolean;
|
140 | export type ArgumentFilter = (typeName?: string, fieldName?: string, argName?: string, argConfig?: GraphQLArgumentConfig) => boolean;
|
141 | export type DirectiveFilter = (directiveName: string, directive: GraphQLDirective) => boolean;
|
142 | export type EnumValueFilter = (typeName: string, valueName: string, valueConfig: GraphQLEnumValueConfig) => boolean;
|
143 | export type RenameTypesOptions = {
|
144 | renameBuiltins: boolean;
|
145 | renameScalars: boolean;
|
146 | };
|
147 | export type IFieldResolver<TSource, TContext, TArgs = Record<string, any>, TReturn = any> = (source: TSource, args: TArgs, context: TContext, info: GraphQLResolveInfo) => TReturn;
|
148 | export type TypeSource = string | Source | DocumentNode | GraphQLSchema | DefinitionNode | Array<TypeSource> | (() => TypeSource);
|
149 | export type IObjectTypeResolver<TSource = any, TContext = any, TArgs = any> = {
|
150 | [key: string]: IFieldResolver<TSource, TContext, TArgs> | IFieldResolverOptions<TSource, TContext>;
|
151 | } & {
|
152 | __name?: string;
|
153 | __description?: string;
|
154 | __isTypeOf?: GraphQLIsTypeOfFn<TSource, TContext>;
|
155 | __extensions?: Record<string, any>;
|
156 | __astNode?: ObjectTypeDefinitionNode;
|
157 | __extensionASTNodes?: ObjectTypeExtensionNode;
|
158 | };
|
159 | export type IInterfaceTypeResolver<TSource = any, TContext = any, TArgs = any> = {
|
160 | [key: string]: IFieldResolver<TSource, TContext, TArgs> | IFieldResolverOptions<TSource, TContext>;
|
161 | } & {
|
162 | __name?: string;
|
163 | __description?: string;
|
164 | __resolveType?: GraphQLTypeResolver<any, any>;
|
165 | __extensions?: Record<string, any>;
|
166 | __astNode?: InterfaceTypeDefinitionNode;
|
167 | __extensionASTNodes?: Array<InterfaceTypeExtensionNode>;
|
168 | };
|
169 | export type IUnionTypeResolver = {
|
170 | __name?: string;
|
171 | __description?: string;
|
172 | __resolveType?: GraphQLTypeResolver<any, any>;
|
173 | __extensions?: Record<string, any>;
|
174 | __astNode?: UnionTypeDefinitionNode;
|
175 | __extensionASTNodes?: Array<UnionTypeExtensionNode>;
|
176 | };
|
177 | export type IInputObjectTypeResolver = {
|
178 | __name?: string;
|
179 | __description?: string;
|
180 | __extensions?: Record<string, any>;
|
181 | __astNode?: InputObjectTypeDefinitionNode;
|
182 | __extensionASTNodes?: Array<InputObjectTypeExtensionNode>;
|
183 | };
|
184 | export type ISchemaLevelResolver<TSource, TContext, TArgs = Record<string, any>, TReturn = any> = IFieldResolver<TSource, TContext, TArgs, TReturn>;
|
185 | export 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>;
|
186 | export type IFieldIteratorFn = (fieldDef: GraphQLField<any, any>, typeName: string, fieldName: string) => void;
|
187 | export type IDefaultValueIteratorFn = (type: GraphQLInputType, value: any) => void;
|
188 | export type NextResolverFn = () => Promise<any>;
|
189 | export type VisitableSchemaType = GraphQLSchema | GraphQLObjectType | GraphQLInterfaceType | GraphQLInputObjectType | GraphQLNamedType | GraphQLScalarType | GraphQLField<any, any> | GraphQLInputField | GraphQLArgument | GraphQLUnionType | GraphQLEnumType | GraphQLEnumValue;
|
190 | export declare enum MapperKind {
|
191 | TYPE = "MapperKind.TYPE",
|
192 | SCALAR_TYPE = "MapperKind.SCALAR_TYPE",
|
193 | ENUM_TYPE = "MapperKind.ENUM_TYPE",
|
194 | COMPOSITE_TYPE = "MapperKind.COMPOSITE_TYPE",
|
195 | OBJECT_TYPE = "MapperKind.OBJECT_TYPE",
|
196 | INPUT_OBJECT_TYPE = "MapperKind.INPUT_OBJECT_TYPE",
|
197 | ABSTRACT_TYPE = "MapperKind.ABSTRACT_TYPE",
|
198 | UNION_TYPE = "MapperKind.UNION_TYPE",
|
199 | INTERFACE_TYPE = "MapperKind.INTERFACE_TYPE",
|
200 | ROOT_OBJECT = "MapperKind.ROOT_OBJECT",
|
201 | QUERY = "MapperKind.QUERY",
|
202 | MUTATION = "MapperKind.MUTATION",
|
203 | SUBSCRIPTION = "MapperKind.SUBSCRIPTION",
|
204 | DIRECTIVE = "MapperKind.DIRECTIVE",
|
205 | FIELD = "MapperKind.FIELD",
|
206 | COMPOSITE_FIELD = "MapperKind.COMPOSITE_FIELD",
|
207 | OBJECT_FIELD = "MapperKind.OBJECT_FIELD",
|
208 | ROOT_FIELD = "MapperKind.ROOT_FIELD",
|
209 | QUERY_ROOT_FIELD = "MapperKind.QUERY_ROOT_FIELD",
|
210 | MUTATION_ROOT_FIELD = "MapperKind.MUTATION_ROOT_FIELD",
|
211 | SUBSCRIPTION_ROOT_FIELD = "MapperKind.SUBSCRIPTION_ROOT_FIELD",
|
212 | INTERFACE_FIELD = "MapperKind.INTERFACE_FIELD",
|
213 | INPUT_OBJECT_FIELD = "MapperKind.INPUT_OBJECT_FIELD",
|
214 | ARGUMENT = "MapperKind.ARGUMENT",
|
215 | ENUM_VALUE = "MapperKind.ENUM_VALUE"
|
216 | }
|
217 | export interface SchemaMapper {
|
218 | [MapperKind.TYPE]?: NamedTypeMapper;
|
219 | [MapperKind.SCALAR_TYPE]?: ScalarTypeMapper;
|
220 | [MapperKind.ENUM_TYPE]?: EnumTypeMapper;
|
221 | [MapperKind.COMPOSITE_TYPE]?: CompositeTypeMapper;
|
222 | [MapperKind.OBJECT_TYPE]?: ObjectTypeMapper;
|
223 | [MapperKind.INPUT_OBJECT_TYPE]?: InputObjectTypeMapper;
|
224 | [MapperKind.ABSTRACT_TYPE]?: AbstractTypeMapper;
|
225 | [MapperKind.UNION_TYPE]?: UnionTypeMapper;
|
226 | [MapperKind.INTERFACE_TYPE]?: InterfaceTypeMapper;
|
227 | [MapperKind.ROOT_OBJECT]?: ObjectTypeMapper;
|
228 | [MapperKind.QUERY]?: ObjectTypeMapper;
|
229 | [MapperKind.MUTATION]?: ObjectTypeMapper;
|
230 | [MapperKind.SUBSCRIPTION]?: ObjectTypeMapper;
|
231 | [MapperKind.ENUM_VALUE]?: EnumValueMapper;
|
232 | [MapperKind.FIELD]?: GenericFieldMapper<GraphQLFieldConfig<any, any> | GraphQLInputFieldConfig>;
|
233 | [MapperKind.OBJECT_FIELD]?: FieldMapper;
|
234 | [MapperKind.ROOT_FIELD]?: FieldMapper;
|
235 | [MapperKind.QUERY_ROOT_FIELD]?: FieldMapper;
|
236 | [MapperKind.MUTATION_ROOT_FIELD]?: FieldMapper;
|
237 | [MapperKind.SUBSCRIPTION_ROOT_FIELD]?: FieldMapper;
|
238 | [MapperKind.INTERFACE_FIELD]?: FieldMapper;
|
239 | [MapperKind.COMPOSITE_FIELD]?: FieldMapper;
|
240 | [MapperKind.ARGUMENT]?: ArgumentMapper;
|
241 | [MapperKind.INPUT_OBJECT_FIELD]?: InputFieldMapper;
|
242 | [MapperKind.DIRECTIVE]?: DirectiveMapper;
|
243 | }
|
244 | export type SchemaFieldMapperTypes = Array<MapperKind.FIELD | MapperKind.COMPOSITE_FIELD | MapperKind.OBJECT_FIELD | MapperKind.ROOT_FIELD | MapperKind.QUERY_ROOT_FIELD | MapperKind.MUTATION_ROOT_FIELD | MapperKind.SUBSCRIPTION_ROOT_FIELD | MapperKind.INTERFACE_FIELD | MapperKind.INPUT_OBJECT_FIELD>;
|
245 | export type NamedTypeMapper = (type: GraphQLNamedType, schema: GraphQLSchema) => GraphQLNamedType | null | undefined;
|
246 | export type ScalarTypeMapper = (type: GraphQLScalarType, schema: GraphQLSchema) => GraphQLScalarType | null | undefined;
|
247 | export type EnumTypeMapper = (type: GraphQLEnumType, schema: GraphQLSchema) => GraphQLEnumType | null | undefined;
|
248 | export type EnumValueMapper = (valueConfig: GraphQLEnumValueConfig, typeName: string, schema: GraphQLSchema, externalValue: string) => GraphQLEnumValueConfig | [string, GraphQLEnumValueConfig] | null | undefined;
|
249 | export type CompositeTypeMapper = (type: GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType, schema: GraphQLSchema) => GraphQLObjectType | GraphQLInterfaceType | GraphQLUnionType | null | undefined;
|
250 | export type ObjectTypeMapper = (type: GraphQLObjectType, schema: GraphQLSchema) => GraphQLObjectType | null | undefined;
|
251 | export type InputObjectTypeMapper = (type: GraphQLInputObjectType, schema: GraphQLSchema) => GraphQLInputObjectType | null | undefined;
|
252 | export type AbstractTypeMapper = (type: GraphQLInterfaceType | GraphQLUnionType, schema: GraphQLSchema) => GraphQLInterfaceType | GraphQLUnionType | null | undefined;
|
253 | export type UnionTypeMapper = (type: GraphQLUnionType, schema: GraphQLSchema) => GraphQLUnionType | null | undefined;
|
254 | export type InterfaceTypeMapper = (type: GraphQLInterfaceType, schema: GraphQLSchema) => GraphQLInterfaceType | null | undefined;
|
255 | export type DirectiveMapper = (directive: GraphQLDirective, schema: GraphQLSchema) => GraphQLDirective | null | undefined;
|
256 | export type GenericFieldMapper<F extends GraphQLFieldConfig<any, any> | GraphQLInputFieldConfig> = (fieldConfig: F, fieldName: string, typeName: string, schema: GraphQLSchema) => F | [string, F] | null | undefined;
|
257 | export type FieldMapper = GenericFieldMapper<GraphQLFieldConfig<any, any>>;
|
258 | export type ArgumentMapper = (argumentConfig: GraphQLArgumentConfig, fieldName: string, typeName: string, schema: GraphQLSchema) => GraphQLArgumentConfig | [string, GraphQLArgumentConfig] | null | undefined;
|
259 | export type InputFieldMapper = GenericFieldMapper<GraphQLInputFieldConfig>;
|