From d64ec06744bc629ab8ec397675670afaa6f20139 Mon Sep 17 00:00:00 2001 From: Benjie Gillam Date: Thu, 23 Aug 2018 19:17:07 +0100 Subject: [PATCH] fix(types): export interfaces (#841) --- src/index.ts | 2 ++ src/interfaces.ts | 10 ---------- .../http/createPostGraphileHttpRequestHandler.ts | 13 ++++++++++++- src/postgraphile/http/setupServerSentEvents.ts | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/src/index.ts b/src/index.ts index 44944c6ab8..c213536404 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,6 +6,8 @@ import { } from './postgraphile'; import { makePluginHook, PostGraphilePlugin } from './postgraphile/pluginHook'; +export * from './interfaces'; + export default postgraphile; export { diff --git a/src/interfaces.ts b/src/interfaces.ts index f0313c1e17..102b8f8195 100644 --- a/src/interfaces.ts +++ b/src/interfaces.ts @@ -1,5 +1,4 @@ /* tslint:disable:no-any */ -import { EventEmitter } from 'events'; import { GraphQLError, GraphQLSchema, SourceLocation } from 'graphql'; import { IncomingMessage, ServerResponse } from 'http'; import { PluginHookFn } from './postgraphile/pluginHook'; @@ -227,15 +226,6 @@ export type GraphQLErrorExtended = GraphQLError & { code: string; }; -// Used by `createPostGraphileHttpRequestHandler` -export interface CreateRequestHandlerOptions extends PostGraphileOptions { - // The actual GraphQL schema we will use. - getGqlSchema: () => Promise; - // A Postgres client pool we use to connect Postgres clients. - pgPool: Pool; - _emitter: EventEmitter; -} - /** * A request handler for one of many different `http` frameworks. */ diff --git a/src/postgraphile/http/createPostGraphileHttpRequestHandler.ts b/src/postgraphile/http/createPostGraphileHttpRequestHandler.ts index 951e40427e..cb417c4b1c 100644 --- a/src/postgraphile/http/createPostGraphileHttpRequestHandler.ts +++ b/src/postgraphile/http/createPostGraphileHttpRequestHandler.ts @@ -17,7 +17,7 @@ import { extendedFormatError } from '../extendedFormatError'; import { IncomingMessage, ServerResponse } from 'http'; import { isKoaApp, middleware as koaMiddleware } from './koaMiddleware'; import { pluginHookFromOptions } from '../pluginHook'; -import { HttpRequestHandler, CreateRequestHandlerOptions, mixed } from '../../interfaces'; +import { HttpRequestHandler, PostGraphileOptions, mixed } from '../../interfaces'; import setupServerSentEvents from './setupServerSentEvents'; import withPostGraphileContext from '../withPostGraphileContext'; import { Context as KoaContext } from 'koa'; @@ -31,6 +31,17 @@ import bodyParser = require('body-parser'); import sendFile = require('send'); import LRU = require('lru-cache'); import crypto = require('crypto'); +import { Pool } from 'pg'; +import { EventEmitter } from 'events'; + +// Used by `createPostGraphileHttpRequestHandler` +export interface CreateRequestHandlerOptions extends PostGraphileOptions { + // The actual GraphQL schema we will use. + getGqlSchema: () => Promise; + // A Postgres client pool we use to connect Postgres clients. + pgPool: Pool; + _emitter: EventEmitter; +} const calculateQueryHash = (queryString: string): string => crypto diff --git a/src/postgraphile/http/setupServerSentEvents.ts b/src/postgraphile/http/setupServerSentEvents.ts index cbd3abe7a7..ca7704937c 100644 --- a/src/postgraphile/http/setupServerSentEvents.ts +++ b/src/postgraphile/http/setupServerSentEvents.ts @@ -1,7 +1,7 @@ /* tslint:disable:no-any */ import { PassThrough } from 'stream'; import { IncomingMessage, ServerResponse } from 'http'; -import { CreateRequestHandlerOptions } from '../../interfaces'; +import { CreateRequestHandlerOptions } from './createPostGraphileHttpRequestHandler'; export default function setupServerSentEvents( req: IncomingMessage,