UNPKG

postgraphile

Version:

A GraphQL schema created by reflection over a PostgreSQL schema 🐘 (previously known as PostGraphQL)

105 lines (104 loc) 4.65 kB
/// <reference types="node" /> import { AddFlagFn } from './cli'; import { Server, IncomingMessage } from 'http'; import { CreateRequestHandlerOptions, HttpRequestHandler, PostGraphileOptions } from '../interfaces'; import { WithPostGraphileContextFn } from './withPostGraphileContext'; import * as graphql from 'graphql'; import * as graphqlWs from 'graphql-ws'; import { Extra as GraphQLWSContextExtra } from 'graphql-ws/lib/use/ws'; import { ExecutionParams } from 'subscriptions-transport-ws'; import { PostGraphileResponse } from './http/frameworks'; declare type PromiseOrValue<T> = T | Promise<T>; export declare type HookFn<TArg, TContext = any> = (arg: TArg, context: TContext) => TArg; export declare type PluginHookFn = <TArgument, TContext = Record<string, any>>(hookName: string, argument: TArgument, context?: TContext) => TArgument; export interface PostGraphileHTTPResult { statusCode?: number; result?: Record<string, any>; errors?: Array<Record<string, any>>; meta?: Record<string, any>; } export interface PostGraphileHTTPEnd { statusCode?: number; result: Record<string, any> | Array<Record<string, any>>; } export interface PostGraphilePlugin { init?: HookFn<null, { version: string; graphql: typeof import('graphql'); }>; pluginHook?: HookFn<PluginHookFn>; 'cli:flags:add:standard'?: HookFn<AddFlagFn>; 'cli:flags:add:schema'?: HookFn<AddFlagFn>; 'cli:flags:add:errorHandling'?: HookFn<AddFlagFn>; 'cli:flags:add:plugins'?: HookFn<AddFlagFn>; 'cli:flags:add:noServer'?: HookFn<AddFlagFn>; 'cli:flags:add:webserver'?: HookFn<AddFlagFn>; 'cli:flags:add:jwt'?: HookFn<AddFlagFn>; 'cli:flags:add'?: HookFn<AddFlagFn>; 'cli:flags:add:deprecated'?: HookFn<AddFlagFn>; 'cli:flags:add:workarounds'?: HookFn<AddFlagFn>; 'cli:library:options'?: HookFn<PostGraphileOptions, { config: any; cliOptions: any; }>; 'cli:server:middleware'?: HookFn<HttpRequestHandler>; 'cli:server:created'?: HookFn<Server>; 'cli:greeting'?: HookFn<Array<string | null | void>>; 'postgraphile:options'?: HookFn<PostGraphileOptions>; 'postgraphile:validationRules:static'?: HookFn<typeof graphql.specifiedRules>; 'postgraphile:graphiql:html'?: HookFn<string>; 'postgraphile:middleware'?: HookFn<HttpRequestHandler>; 'postgraphile:http:handler'?: HookFn<IncomingMessage>; 'postgraphile:http:eventStreamRouteHandler'?: HookFn<IncomingMessage, { options: CreateRequestHandlerOptions; response: PostGraphileResponse; }>; 'postgraphile:http:faviconRouteHandler'?: HookFn<IncomingMessage, { options: CreateRequestHandlerOptions; response: PostGraphileResponse; }>; 'postgraphile:http:graphiqlRouteHandler'?: HookFn<IncomingMessage, { options: CreateRequestHandlerOptions; response: PostGraphileResponse; }>; 'postgraphile:http:graphqlRouteHandler'?: HookFn<IncomingMessage, { options: CreateRequestHandlerOptions; response: PostGraphileResponse; }>; 'postgraphile:http:result'?: HookFn<PostGraphileHTTPResult>; 'postgraphile:http:end'?: HookFn<PostGraphileHTTPEnd>; 'postgraphile:httpParamsList'?: HookFn<Array<Record<string, any>>>; 'postgraphile:validationRules'?: HookFn<typeof graphql.specifiedRules>; 'postgraphile:ws:onOperation'?: HookFn<ExecutionParams>; 'postgraphile:ws:onSubscribe'?: HookFn<graphql.ExecutionArgs & { document: graphql.DocumentNode | null; }, { context: graphqlWs.Context<any, GraphQLWSContextExtra>; message: graphqlWs.SubscribeMessage; options: CreateRequestHandlerOptions; }>; 'postgraphile:liveSubscribe:executionResult'?: HookFn<PromiseOrValue<graphql.ExecutionResult<{ [key: string]: any; }, { [key: string]: any; }>>, { schema: graphql.GraphQLSchema; document: graphql.DocumentNode; rootValue: any; contextValue: any; variableValues: { [key: string]: any; } | undefined; operationName: string | undefined; fieldResolver: graphql.GraphQLFieldResolver<any, any, { [argName: string]: any; }> | undefined; subscribeFieldResolver: graphql.GraphQLFieldResolver<any, any, { [argName: string]: any; }> | undefined; }>; withPostGraphileContext?: HookFn<WithPostGraphileContextFn>; } export declare function makePluginHook(plugins: Array<PostGraphilePlugin>): PluginHookFn; export declare function pluginHookFromOptions(options: PostGraphileOptions): PluginHookFn; export {};