1 |
|
2 | import { AddFlagFn } from './cli';
|
3 | import { Server, IncomingMessage } from 'http';
|
4 | import { CreateRequestHandlerOptions, HttpRequestHandler, PostGraphileOptions } from '../interfaces';
|
5 | import { WithPostGraphileContextFn } from './withPostGraphileContext';
|
6 | import * as graphql from 'graphql';
|
7 | import * as graphqlWs from 'graphql-ws';
|
8 | import { Extra as GraphQLWSContextExtra } from 'graphql-ws/lib/use/ws';
|
9 | import { ExecutionParams } from 'subscriptions-transport-ws';
|
10 | import { PostGraphileResponse } from './http/frameworks';
|
11 | declare type PromiseOrValue<T> = T | Promise<T>;
|
12 | export declare type HookFn<TArg, TContext = any> = (arg: TArg, context: TContext) => TArg;
|
13 | export declare type PluginHookFn = <TArgument, TContext = Record<string, any>>(hookName: string, argument: TArgument, context?: TContext) => TArgument;
|
14 | export interface PostGraphileHTTPResult {
|
15 | statusCode?: number;
|
16 | result?: Record<string, any>;
|
17 | errors?: Array<Record<string, any>>;
|
18 | meta?: Record<string, any>;
|
19 | }
|
20 | export interface PostGraphileHTTPEnd {
|
21 | statusCode?: number;
|
22 | result: Record<string, any> | Array<Record<string, any>>;
|
23 | }
|
24 | export interface PostGraphilePlugin {
|
25 | init?: HookFn<null, {
|
26 | version: string;
|
27 | graphql: typeof import('graphql');
|
28 | }>;
|
29 | pluginHook?: HookFn<PluginHookFn>;
|
30 | 'cli:flags:add:standard'?: HookFn<AddFlagFn>;
|
31 | 'cli:flags:add:schema'?: HookFn<AddFlagFn>;
|
32 | 'cli:flags:add:errorHandling'?: HookFn<AddFlagFn>;
|
33 | 'cli:flags:add:plugins'?: HookFn<AddFlagFn>;
|
34 | 'cli:flags:add:noServer'?: HookFn<AddFlagFn>;
|
35 | 'cli:flags:add:webserver'?: HookFn<AddFlagFn>;
|
36 | 'cli:flags:add:jwt'?: HookFn<AddFlagFn>;
|
37 | 'cli:flags:add'?: HookFn<AddFlagFn>;
|
38 | 'cli:flags:add:deprecated'?: HookFn<AddFlagFn>;
|
39 | 'cli:flags:add:workarounds'?: HookFn<AddFlagFn>;
|
40 | 'cli:library:options'?: HookFn<PostGraphileOptions, {
|
41 | config: any;
|
42 | cliOptions: any;
|
43 | }>;
|
44 | 'cli:server:middleware'?: HookFn<HttpRequestHandler>;
|
45 | 'cli:server:created'?: HookFn<Server>;
|
46 | 'cli:greeting'?: HookFn<Array<string | null | void>>;
|
47 | 'postgraphile:options'?: HookFn<PostGraphileOptions>;
|
48 | 'postgraphile:validationRules:static'?: HookFn<typeof graphql.specifiedRules>;
|
49 | 'postgraphile:graphiql:html'?: HookFn<string>;
|
50 | 'postgraphile:middleware'?: HookFn<HttpRequestHandler>;
|
51 | 'postgraphile:http:handler'?: HookFn<IncomingMessage>;
|
52 | 'postgraphile:http:eventStreamRouteHandler'?: HookFn<IncomingMessage, {
|
53 | options: CreateRequestHandlerOptions;
|
54 | response: PostGraphileResponse;
|
55 | }>;
|
56 | 'postgraphile:http:faviconRouteHandler'?: HookFn<IncomingMessage, {
|
57 | options: CreateRequestHandlerOptions;
|
58 | response: PostGraphileResponse;
|
59 | }>;
|
60 | 'postgraphile:http:graphiqlRouteHandler'?: HookFn<IncomingMessage, {
|
61 | options: CreateRequestHandlerOptions;
|
62 | response: PostGraphileResponse;
|
63 | }>;
|
64 | 'postgraphile:http:graphqlRouteHandler'?: HookFn<IncomingMessage, {
|
65 | options: CreateRequestHandlerOptions;
|
66 | response: PostGraphileResponse;
|
67 | }>;
|
68 | 'postgraphile:http:result'?: HookFn<PostGraphileHTTPResult>;
|
69 | 'postgraphile:http:end'?: HookFn<PostGraphileHTTPEnd>;
|
70 | 'postgraphile:httpParamsList'?: HookFn<Array<Record<string, any>>>;
|
71 | 'postgraphile:validationRules'?: HookFn<typeof graphql.specifiedRules>;
|
72 | 'postgraphile:ws:onOperation'?: HookFn<ExecutionParams>;
|
73 | 'postgraphile:ws:onSubscribe'?: HookFn<graphql.ExecutionArgs & {
|
74 | document: graphql.DocumentNode | null;
|
75 | }, {
|
76 | context: graphqlWs.Context<any, GraphQLWSContextExtra>;
|
77 | message: graphqlWs.SubscribeMessage;
|
78 | options: CreateRequestHandlerOptions;
|
79 | }>;
|
80 | 'postgraphile:liveSubscribe:executionResult'?: HookFn<PromiseOrValue<graphql.ExecutionResult<{
|
81 | [key: string]: any;
|
82 | }, {
|
83 | [key: string]: any;
|
84 | }>>, {
|
85 | schema: graphql.GraphQLSchema;
|
86 | document: graphql.DocumentNode;
|
87 | rootValue: any;
|
88 | contextValue: any;
|
89 | variableValues: {
|
90 | [key: string]: any;
|
91 | } | undefined;
|
92 | operationName: string | undefined;
|
93 | fieldResolver: graphql.GraphQLFieldResolver<any, any, {
|
94 | [argName: string]: any;
|
95 | }> | undefined;
|
96 | subscribeFieldResolver: graphql.GraphQLFieldResolver<any, any, {
|
97 | [argName: string]: any;
|
98 | }> | undefined;
|
99 | }>;
|
100 | withPostGraphileContext?: HookFn<WithPostGraphileContextFn>;
|
101 | }
|
102 | export declare function makePluginHook(plugins: Array<PostGraphilePlugin>): PluginHookFn;
|
103 | export declare function pluginHookFromOptions(options: PostGraphileOptions): PluginHookFn;
|
104 | export {};
|