import { GraphQLSchema } from "graphql";
import { Middleware, ParameterizedContext } from "koa";

export interface ExecuteOptions {
  schema?: GraphQLSchema | undefined;
  rootValue?: any;
  contextValue?: any;
  fieldResolver?: any;
}

export function errorHandler(): Middleware;

export function execute<StateT = any, CustomT = {}>(
  options: ExecuteOptions & {
    override?: ((ctx: ParameterizedContext<StateT, CustomT>) => ExecuteOptions) | undefined;
  }
): Middleware<StateT, CustomT>;
