-
Notifications
You must be signed in to change notification settings - Fork 2k
/
types.ts
87 lines (77 loc) · 2.97 KB
/
types.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
import { GraphQLSchema, DocumentNode } from 'graphql';
import { SchemaDirectiveVisitor, IResolvers, IMocks } from 'graphql-tools';
import { ConnectionContext } from 'subscriptions-transport-ws';
import WebSocket from 'ws';
import { GraphQLExtension } from 'graphql-extensions';
export { GraphQLExtension } from 'graphql-extensions';
import { EngineReportingOptions } from 'apollo-engine-reporting';
import { PlaygroundConfig } from './playground';
export { PlaygroundConfig, PlaygroundRenderPageOptions } from './playground';
import {
GraphQLServerOptions as GraphQLOptions,
PersistedQueryOptions,
} from './graphqlOptions';
import { CacheControlExtensionOptions } from 'apollo-cache-control';
import { ApolloServerPlugin } from 'apollo-server-plugin-base';
import { GraphQLSchemaModule } from '@apollographql/apollo-tools';
export { GraphQLSchemaModule };
export { KeyValueCache } from 'apollo-server-caching';
export type Context<T = any> = T;
export type ContextFunction<T = any> = (
context: Context<T>,
) => Promise<Context<T>>;
// A plugin can return an interface that matches `ApolloServerPlugin`, or a
// factory function that returns `ApolloServerPlugin`.
export type PluginDefinition = ApolloServerPlugin | (() => ApolloServerPlugin);
export interface SubscriptionServerOptions {
path: string;
keepAlive?: number;
onConnect?: (
connectionParams: Object,
websocket: WebSocket,
context: ConnectionContext,
) => any;
onDisconnect?: (websocket: WebSocket, context: ConnectionContext) => any;
}
// This configuration is shared between all integrations and should include
// fields that are not specific to a single integration
export interface Config
extends Pick<
GraphQLOptions<Context<any>>,
| 'formatError'
| 'debug'
| 'rootValue'
| 'validationRules'
| 'formatResponse'
| 'fieldResolver'
| 'tracing'
| 'dataSources'
| 'cache'
> {
modules?: GraphQLSchemaModule[];
typeDefs?: DocumentNode | Array<DocumentNode>;
resolvers?: IResolvers;
schema?: GraphQLSchema;
schemaDirectives?: Record<string, typeof SchemaDirectiveVisitor>;
context?: Context<any> | ContextFunction<any>;
introspection?: boolean;
mocks?: boolean | IMocks;
mockEntireSchema?: boolean;
engine?: boolean | EngineReportingOptions<Context<any>>;
extensions?: Array<() => GraphQLExtension>;
cacheControl?: CacheControlExtensionOptions | boolean;
plugins?: PluginDefinition[];
persistedQueries?: PersistedQueryOptions | false;
subscriptions?: Partial<SubscriptionServerOptions> | string | false;
//https://github.com/jaydenseric/graphql-upload#type-uploadoptions
uploads?: boolean | FileUploadOptions;
playground?: PlaygroundConfig;
}
export interface FileUploadOptions {
//Max allowed non-file multipart form field size in bytes; enough for your queries (default: 1 MB).
maxFieldSize?: number;
//Max allowed file size in bytes (default: Infinity).
maxFileSize?: number;
//Max allowed number of files (default: Infinity).
maxFiles?: number;
}