Skip to content

Commit

Permalink
fix(types): add missing hook types (#932)
Browse files Browse the repository at this point in the history
  • Loading branch information
benjie committed Nov 29, 2018
1 parent 12ed988 commit 102b786
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/postgraphile/pluginHook.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AddFlagFn } from './cli';
import { Server } from 'http';
import { Server, IncomingMessage } from 'http';
import { HttpRequestHandler, PostGraphileOptions } from '../interfaces';
import { WithPostGraphileContextFn } from './withPostGraphileContext';
import { version } from '../../package.json';
Expand All @@ -8,7 +8,10 @@ import * as graphql from 'graphql';
export type HookFn<T> = (arg: T, context: {}) => T;
export type PluginHookFn = <T>(hookName: string, argument: T, context?: {}) => T;
export interface PostGraphilePlugin {
init?: HookFn<null>;

pluginHook?: HookFn<PluginHookFn>;

'cli:flags:add:standard'?: HookFn<AddFlagFn>;
'cli:flags:add:schema'?: HookFn<AddFlagFn>;
'cli:flags:add:errorHandling'?: HookFn<AddFlagFn>;
Expand All @@ -19,11 +22,18 @@ export interface PostGraphilePlugin {
'cli:flags:add'?: HookFn<AddFlagFn>;
'cli:flags:add:deprecated'?: HookFn<AddFlagFn>;
'cli:flags:add:workarounds'?: HookFn<AddFlagFn>;

'cli:library:options'?: HookFn<{}>;
'cli:server:middleware'?: HookFn<HttpRequestHandler>;
'cli:server:created'?: HookFn<Server>;
'cli:greeting'?: HookFn<Array<string | void>>;

'postgraphile:options'?: HookFn<PostGraphileOptions>;
'postgraphile:validationRules:static'?: HookFn<ReadonlyArray<typeof graphql.specifiedRules>>;
'postgraphile:http:handler'?: HookFn<IncomingMessage>;
'postgraphile:httpParamsList'?: HookFn<Array<object>>;
'postgraphile:validationRules'?: HookFn<ReadonlyArray<typeof graphql.specifiedRules>>; // AVOID THIS where possible; use 'postgraphile:validationRules:static' instead.
'postgraphile:middleware'?: HookFn<HttpRequestHandler>;

withPostGraphileContext?: HookFn<WithPostGraphileContextFn>;
}
type HookName = keyof PostGraphilePlugin;
Expand Down

0 comments on commit 102b786

Please sign in to comment.