import { GraphQLSchema, GraphQLError } from 'graphql'; import DataLoader from 'dataloader'; import { PubSub } from 'graphql-subscriptions'; import type { Context } from '../context.js'; import type { WebSocket } from 'ws'; export interface GraphQLOptions { schema: string; resolvers?: Record; endpoint?: string; subscriptionsEndpoint?: string; playground?: boolean; introspection?: boolean; dataLoaders?: Record DataLoader>; context?: (ctx: Context) => Record; formatError?: (error: GraphQLError) => any; validationRules?: any[]; requireAuth?: boolean; allowedOrigins?: string[]; maxQueryDepth?: number; maxQueryComplexity?: number; rateLimit?: { windowMs: number; maxQueries: number; }; disablePlaygroundInProduction?: boolean; sanitizeInputs?: boolean; } export interface GraphQLContext extends Context { dataLoaders: Record>; pubsub: PubSub; } export interface SubscriptionContext { pubsub: PubSub; connection: WebSocket; context: Record; } declare class DataLoaderFactory { private loaders; createLoader(name: string, batchFn: (keys: readonly K[]) => Promise, options?: DataLoader.Options): DataLoader; getLoader(name: string): DataLoader | undefined; clearAll(): void; primeAll(key: any, value: any): void; } declare class GraphQLSchemaBuilder { private typeDefs; private resolvers; private dataLoaderFactory; addTypeDefs(typeDefs: string): GraphQLSchemaBuilder; addResolvers(resolvers: Record): GraphQLSchemaBuilder; addDataLoader(name: string, batchFn: (keys: readonly K[]) => Promise, options?: DataLoader.Options): GraphQLSchemaBuilder; generateResolvers(dataSources: Record): GraphQLSchemaBuilder; build(): { schema: GraphQLSchema; resolvers: Record; dataLoaders: DataLoaderFactory; }; } declare class TypeGenerator { static generateTypes(schema: GraphQLSchema, outputPath?: string): string; private static schemaToTypes; } declare class SubscriptionManager { private pubsub; private subscriptions; subscribe(topic: string, callback: (payload: any) => void): Promise; unsubscribe(subId: number): Promise; publish(topic: string, payload: any): Promise; handleWebSocketSubscription(connection: WebSocket, context: SubscriptionContext): void; } export declare function graphqlPlugin(options: GraphQLOptions): (ctx: Context, next: () => Promise) => Promise; export declare function createDataLoader(batchFn: (keys: readonly K[]) => Promise, options?: DataLoader.Options): () => DataLoader; export { GraphQLSchemaBuilder, TypeGenerator, SubscriptionManager, DataLoaderFactory }; export { graphqlPlugin as graphql }; export declare function createLoaderResolver(loaderName: string, keyFn: (parent: any, args: any, context: GraphQLContext) => K): (parent: any, args: any, context: GraphQLContext) => Promise; export declare function createBatchResolver(loaderName: string, keyFn: (args: any, context: GraphQLContext) => any[]): (parent: any, args: any, context: GraphQLContext) => Promise; //# sourceMappingURL=graphql.d.ts.map