UNPKG

3.81 kBTypeScriptView Raw
1import { GraphQLSchema, DocumentNode } from 'graphql';
2import { SchemaDirectiveVisitor, IResolvers, IMocks, GraphQLParseOptions } from 'graphql-tools';
3import { ApolloConfig, ValueOrPromise, GraphQLExecutor, GraphQLExecutionResult, GraphQLRequestContextExecutionDidStart, ApolloConfigInput } from 'apollo-server-types';
4import { ConnectionContext } from 'subscriptions-transport-ws';
5import type WebSocket from 'ws';
6import { GraphQLExtension } from 'graphql-extensions';
7export { GraphQLExtension } from 'graphql-extensions';
8import { PlaygroundConfig } from './playground';
9export { PlaygroundConfig, PlaygroundRenderPageOptions } from './playground';
10import { GraphQLServerOptions as GraphQLOptions, PersistedQueryOptions } from './graphqlOptions';
11import { CacheControlExtensionOptions } from 'apollo-cache-control';
12import { ApolloServerPlugin } from 'apollo-server-plugin-base';
13import { GraphQLSchemaModule } from '@apollographql/apollo-tools';
14import type { EngineReportingOptions } from './plugin';
15export { GraphQLSchemaModule };
16export { KeyValueCache } from 'apollo-server-caching';
17export declare type Context<T = object> = T;
18export declare type ContextFunction<FunctionParams = any, ProducedContext = object> = (context: FunctionParams) => ValueOrPromise<Context<ProducedContext>>;
19export declare type PluginDefinition = ApolloServerPlugin | (() => ApolloServerPlugin);
20export interface SubscriptionServerOptions {
21 path: string;
22 keepAlive?: number;
23 onConnect?: (connectionParams: Object, websocket: WebSocket, context: ConnectionContext) => any;
24 onDisconnect?: (websocket: WebSocket, context: ConnectionContext) => any;
25}
26declare type BaseConfig = Pick<GraphQLOptions<Context>, 'formatError' | 'debug' | 'rootValue' | 'validationRules' | 'executor' | 'formatResponse' | 'fieldResolver' | 'tracing' | 'dataSources' | 'cache' | 'logger'>;
27export declare type Unsubscriber = () => void;
28export declare type SchemaChangeCallback = (schema: GraphQLSchema) => void;
29export declare type GraphQLServiceConfig = {
30 schema: GraphQLSchema;
31 executor: GraphQLExecutor;
32};
33export declare type GraphQLServiceEngineConfig = {
34 apiKeyHash: string;
35 graphId: string;
36 graphVariant?: string;
37};
38export interface GraphQLService {
39 load(options: {
40 apollo?: ApolloConfig;
41 engine?: GraphQLServiceEngineConfig;
42 }): Promise<GraphQLServiceConfig>;
43 onSchemaChange(callback: SchemaChangeCallback): Unsubscriber;
44 executor<TContext>(requestContext: GraphQLRequestContextExecutionDidStart<TContext>): ValueOrPromise<GraphQLExecutionResult>;
45 stop?(): Promise<void>;
46}
47export interface Config extends BaseConfig {
48 modules?: GraphQLSchemaModule[];
49 typeDefs?: DocumentNode | Array<DocumentNode> | string | Array<string>;
50 parseOptions?: GraphQLParseOptions;
51 resolvers?: IResolvers | Array<IResolvers>;
52 schema?: GraphQLSchema;
53 schemaDirectives?: Record<string, typeof SchemaDirectiveVisitor>;
54 context?: Context | ContextFunction;
55 introspection?: boolean;
56 mocks?: boolean | IMocks;
57 mockEntireSchema?: boolean;
58 extensions?: Array<() => GraphQLExtension>;
59 cacheControl?: CacheControlExtensionOptions | boolean;
60 plugins?: PluginDefinition[];
61 persistedQueries?: PersistedQueryOptions | false;
62 subscriptions?: Partial<SubscriptionServerOptions> | string | false;
63 uploads?: boolean | FileUploadOptions;
64 playground?: PlaygroundConfig;
65 gateway?: GraphQLService;
66 experimental_approximateDocumentStoreMiB?: number;
67 stopOnTerminationSignals?: boolean;
68 apollo?: ApolloConfigInput;
69 engine?: boolean | EngineReportingOptions<Context>;
70}
71export interface FileUploadOptions {
72 maxFieldSize?: number;
73 maxFileSize?: number;
74 maxFiles?: number;
75}
76//# sourceMappingURL=types.d.ts.map
\No newline at end of file