1 | import { OperationTypeNode, DocumentNode, GraphQLError } from 'graphql';
|
2 | import { g as RequestHandlerDefaultInfo, D as DefaultBodyType, R as RequestHandler, a as ResponseResolver, c as RequestHandlerOptions } from './HttpResponse-5Sn2vNaJ.js';
|
3 | import { Match, Path } from './utils/matching/matchRequestUrl.js';
|
4 |
|
5 | interface ParsedGraphQLQuery {
|
6 | operationType: OperationTypeNode;
|
7 | operationName?: string;
|
8 | }
|
9 | type ParsedGraphQLRequest<VariablesType extends GraphQLVariables = GraphQLVariables> = (ParsedGraphQLQuery & {
|
10 | query: string;
|
11 | variables?: VariablesType;
|
12 | }) | undefined;
|
13 | declare function parseDocumentNode(node: DocumentNode): ParsedGraphQLQuery;
|
14 | type GraphQLParsedOperationsMap = Record<string, string[]>;
|
15 | type GraphQLMultipartRequestBody = {
|
16 | operations: string;
|
17 | map?: string;
|
18 | } & {
|
19 | [fileName: string]: File;
|
20 | };
|
21 |
|
22 |
|
23 |
|
24 |
|
25 | declare function parseGraphQLRequest(request: Request): Promise<ParsedGraphQLRequest>;
|
26 |
|
27 | type ExpectedOperationTypeNode = OperationTypeNode | 'all';
|
28 | type GraphQLHandlerNameSelector = DocumentNode | RegExp | string;
|
29 | type GraphQLQuery = Record<string, any>;
|
30 | type GraphQLVariables = Record<string, any>;
|
31 | interface GraphQLHandlerInfo extends RequestHandlerDefaultInfo {
|
32 | operationType: ExpectedOperationTypeNode;
|
33 | operationName: GraphQLHandlerNameSelector;
|
34 | }
|
35 | type GraphQLRequestParsedResult = {
|
36 | match: Match;
|
37 | cookies: Record<string, string>;
|
38 | } & (ParsedGraphQLRequest<GraphQLVariables>
|
39 |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 | | {
|
45 | operationType?: undefined;
|
46 | operationName?: undefined;
|
47 | query?: undefined;
|
48 | variables?: undefined;
|
49 | });
|
50 | type GraphQLResolverExtras<Variables extends GraphQLVariables> = {
|
51 | query: string;
|
52 | operationName: string;
|
53 | variables: Variables;
|
54 | cookies: Record<string, string>;
|
55 | };
|
56 | type GraphQLRequestBody<VariablesType extends GraphQLVariables> = GraphQLJsonRequestBody<VariablesType> | GraphQLMultipartRequestBody | Record<string, any> | undefined;
|
57 | interface GraphQLJsonRequestBody<Variables extends GraphQLVariables> {
|
58 | query: string;
|
59 | variables?: Variables;
|
60 | }
|
61 | type GraphQLResponseBody<BodyType extends DefaultBodyType> = {
|
62 | data?: BodyType | null;
|
63 | errors?: readonly Partial<GraphQLError>[] | null;
|
64 | } | null | undefined;
|
65 | declare function isDocumentNode(value: DocumentNode | any): value is DocumentNode;
|
66 | declare class GraphQLHandler extends RequestHandler<GraphQLHandlerInfo, GraphQLRequestParsedResult, GraphQLResolverExtras<any>> {
|
67 | private endpoint;
|
68 | static parsedRequestCache: WeakMap<Request, ParsedGraphQLRequest<GraphQLVariables>>;
|
69 | constructor(operationType: ExpectedOperationTypeNode, operationName: GraphQLHandlerNameSelector, endpoint: Path, resolver: ResponseResolver<GraphQLResolverExtras<any>, any, any>, options?: RequestHandlerOptions);
|
70 | /**
|
71 | * Parses the request body, once per request, cached across all
|
72 | * GraphQL handlers. This is done to avoid multiple parsing of the
|
73 | * request body, which each requires a clone of the request.
|
74 | */
|
75 | parseGraphQLRequestOrGetFromCache(request: Request): Promise<ParsedGraphQLRequest<GraphQLVariables>>;
|
76 | parse(args: {
|
77 | request: Request;
|
78 | }): Promise<GraphQLRequestParsedResult>;
|
79 | predicate(args: {
|
80 | request: Request;
|
81 | parsedResult: GraphQLRequestParsedResult;
|
82 | }): boolean;
|
83 | protected extendResolverArgs(args: {
|
84 | request: Request;
|
85 | parsedResult: GraphQLRequestParsedResult;
|
86 | }): {
|
87 | query: string;
|
88 | operationName: string;
|
89 | variables: GraphQLVariables;
|
90 | cookies: Record<string, string>;
|
91 | };
|
92 | log(args: {
|
93 | request: Request;
|
94 | response: Response;
|
95 | parsedResult: GraphQLRequestParsedResult;
|
96 | }): Promise<void>;
|
97 | }
|
98 |
|
99 | export { type ExpectedOperationTypeNode as E, GraphQLHandler as G, type ParsedGraphQLRequest as P, type GraphQLQuery as a, type GraphQLVariables as b, type GraphQLRequestBody as c, type GraphQLJsonRequestBody as d, type GraphQLHandlerNameSelector as e, type GraphQLResolverExtras as f, type GraphQLResponseBody as g, type ParsedGraphQLQuery as h, type GraphQLParsedOperationsMap as i, type GraphQLMultipartRequestBody as j, parseGraphQLRequest as k, type GraphQLHandlerInfo as l, type GraphQLRequestParsedResult as m, isDocumentNode as n, parseDocumentNode as p };
|