-
Notifications
You must be signed in to change notification settings - Fork 56
/
index.d.ts
108 lines (95 loc) · 2.7 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
declare module "moleculer-apollo-server" {
import { ServiceSchema, Context } from "moleculer";
import { Config } from "apollo-server-core";
import { OptionsUrlencoded } from "body-parser";
import { SchemaDirectiveVisitor, IResolvers } from "graphql-tools";
export {
GraphQLExtension,
gql,
ApolloError,
toApolloError,
SyntaxError,
ValidationError,
AuthenticationError,
ForbiddenError,
UserInputError,
defaultPlaygroundOptions,
} from "apollo-server-core";
export { GraphQLUpload } from "graphql-upload";
export * from "graphql-tools";
export interface ApolloServerOptions {
path: string;
disableHealthCheck: boolean;
onHealthCheck: () => {};
}
export class ApolloServer {
createGraphQLServerOptions(req: any, res: any): Promise<any>;
createHandler(options: ApolloServerOptions): void;
supportsUploads(): boolean;
supportsSubscriptions(): boolean;
}
export interface ActionResolverSchema {
action: string;
rootParams?: {
[key: string]: string;
};
dataLoader?: boolean;
nullIfError?: boolean;
skipNullKeys?: boolean;
params?: { [key: string]: any };
}
export interface ServiceResolverSchema {
[key: string]: {
[key: string]: ActionResolverSchema;
};
}
type CorsMethods = "GET" | "POST" | "PUT" | "DELETE" | "OPTIONS";
export interface ServiceRouteCorsOptions {
origin?: string | string[];
methods?: CorsMethods | CorsMethods[];
allowedHeaders?: string[];
exposedHeaders?: string[];
credentials?: boolean;
maxAge?: number;
}
export interface ServiceRouteOptions {
path?: string;
use?: any[];
etag?: boolean;
whitelist?: string[];
authorization?: boolean;
camelCaseNames?: boolean;
aliases?: {
[key: string]: any; // Should discuss more on this. string | AliasSchema, ...
};
bodyParsers?: {
json: boolean;
urlencoded: OptionsUrlencoded;
};
cors?: boolean | ServiceRouteCorsOptions;
mappingPolicy?: "all" | "restrict";
authentication?: boolean;
callOptions?: {
timeout: number;
fallbackResponse?: any;
};
onBeforeCall?: (ctx: Context, route: any, req: any, res: any) => Promise<any>;
onAfterCall?: (ctx: Context, route: any, req: any, res: any, data: any) => Promise<any>;
}
export interface ApolloServiceOptions {
typeDefs?: string | string[];
resolvers?: ServiceResolverSchema | IResolvers | Array<IResolvers>;
schemaDirectives?: {
[name: string]: typeof SchemaDirectiveVisitor;
};
routeOptions?: ServiceRouteOptions;
serverOptions?: Config;
checkActionVisibility?: boolean;
autoUpdateSchema?: boolean;
}
export function ApolloService(options: ApolloServiceOptions): ServiceSchema;
export function moleculerGql<T>(
typeString: TemplateStringsArray | string,
...placeholders: T[]
): string;
}