UNPKG

3.23 kBTypeScriptView Raw
1import { GraphQLSchema, GraphQLField, GraphQLFieldResolver, GraphQLResolveInfo, ExecutionArgs, DocumentNode, GraphQLError } from 'graphql';
2import { Request } from 'apollo-server-env';
3import { GraphQLResponse, GraphQLRequestContext } from 'apollo-server-types';
4export { GraphQLResponse };
5export declare type EndHandler = (...errors: Array<Error>) => void;
6export declare class GraphQLExtension<TContext = any> {
7 requestDidStart?(o: {
8 request: Pick<Request, 'url' | 'method' | 'headers'>;
9 queryString?: string;
10 parsedQuery?: DocumentNode;
11 operationName?: string;
12 variables?: {
13 [key: string]: any;
14 };
15 persistedQueryHit?: boolean;
16 persistedQueryRegister?: boolean;
17 context: TContext;
18 requestContext: GraphQLRequestContext<TContext>;
19 }): EndHandler | void;
20 parsingDidStart?(o: {
21 queryString: string;
22 }): EndHandler | void;
23 validationDidStart?(): EndHandler | void;
24 executionDidStart?(o: {
25 executionArgs: ExecutionArgs;
26 }): EndHandler | void;
27 didEncounterErrors?(errors: ReadonlyArray<GraphQLError>): void;
28 willSendResponse?(o: {
29 graphqlResponse: GraphQLResponse;
30 context: TContext;
31 }): void | {
32 graphqlResponse: GraphQLResponse;
33 context: TContext;
34 };
35 willResolveField?(source: any, args: {
36 [argName: string]: any;
37 }, context: TContext, info: GraphQLResolveInfo): ((error: Error | null, result?: any) => void) | void;
38 format?(): [string, any] | undefined;
39}
40export declare class GraphQLExtensionStack<TContext = any> {
41 fieldResolver?: GraphQLFieldResolver<any, any>;
42 private extensions;
43 constructor(extensions: GraphQLExtension<TContext>[]);
44 requestDidStart(o: {
45 request: Pick<Request, 'url' | 'method' | 'headers'>;
46 queryString?: string;
47 parsedQuery?: DocumentNode;
48 operationName?: string;
49 variables?: {
50 [key: string]: any;
51 };
52 persistedQueryHit?: boolean;
53 persistedQueryRegister?: boolean;
54 context: TContext;
55 extensions?: Record<string, any>;
56 requestContext: GraphQLRequestContext<TContext>;
57 }): EndHandler;
58 parsingDidStart(o: {
59 queryString: string;
60 }): EndHandler;
61 validationDidStart(): EndHandler;
62 executionDidStart(o: {
63 executionArgs: ExecutionArgs;
64 }): EndHandler;
65 didEncounterErrors(errors: ReadonlyArray<GraphQLError>): void;
66 willSendResponse(o: {
67 graphqlResponse: GraphQLResponse;
68 context: TContext;
69 }): {
70 graphqlResponse: GraphQLResponse;
71 context: TContext;
72 };
73 willResolveField(source: any, args: {
74 [argName: string]: any;
75 }, context: TContext, info: GraphQLResolveInfo): (error: Error | null, result?: any) => void;
76 format(): {};
77 private handleDidStart;
78}
79export declare function enableGraphQLExtensions(schema: GraphQLSchema & {
80 _extensionsEnabled?: boolean;
81}): GraphQLSchema & {
82 _extensionsEnabled?: boolean | undefined;
83};
84export declare type FieldIteratorFn = (fieldDef: GraphQLField<any, any>, typeName: string, fieldName: string) => void;
85//# sourceMappingURL=index.d.ts.map
\No newline at end of file