postgraphile
- Version 4.13.0
- Published
- 4.93 MB
- 27 dependencies
- MIT license
Install
npm i postgraphile
yarn add postgraphile
pnpm add postgraphile
Overview
A GraphQL schema created by reflection over a PostgreSQL schema đ (previously known as PostGraphQL)
Index
Variables
Functions
Classes
Interfaces
PostGraphileOptions
- additionalGraphQLContextFromRequest
- allowExplain
- appendPlugins
- bodySizeLimit
- classicIds
- disableDefaultMutations
- disableQueryLog
- dynamicJson
- enableCors
- enableQueryBatching
- enhanceGraphiql
- eventStreamRoute
- exportGqlSchemaPath
- exportJsonSchemaPath
- extendedErrors
- externalEventStreamRoute
- externalGraphqlRoute
- externalUrlBase
- graphiql
- graphiqlCredentials
- graphiqlRoute
- graphqlRoute
- handleErrors
- ignoreIndexes
- ignoreRBAC
- includeExtensionResources
- jwtAudiences
- jwtPgTypeIdentifier
- jwtPublicKey
- jwtRole
- jwtSecret
- jwtSignOptions
- jwtVerifyOptions
- legacyJsonUuid
- legacyRelations
- live
- ownerConnectionString
- pgDefaultRole
- pgSettings
- pluginHook
- prependPlugins
- queryCacheMaxSize
- readCache
- replaceAllPlugins
- retryOnInitFail
- setofFunctionsContainNulls
- showErrorStack
- simpleCollections
- skipPlugins
- sortExport
- subscriptions
- watchPg
- websocketMiddlewares
- websocketOperations
- websockets
- writeCache
PostGraphilePlugin
- 'cli:flags:add:deprecated'
- 'cli:flags:add:errorHandling'
- 'cli:flags:add:jwt'
- 'cli:flags:add:noServer'
- 'cli:flags:add:plugins'
- 'cli:flags:add:schema'
- 'cli:flags:add:standard'
- 'cli:flags:add:webserver'
- 'cli:flags:add:workarounds'
- 'cli:flags:add'
- 'cli:greeting'
- 'cli:library:options'
- 'cli:server:created'
- 'cli:server:middleware'
- 'postgraphile:graphiql:html'
- 'postgraphile:http:end'
- 'postgraphile:http:eventStreamRouteHandler'
- 'postgraphile:http:faviconRouteHandler'
- 'postgraphile:http:graphiqlRouteHandler'
- 'postgraphile:http:graphqlRouteHandler'
- 'postgraphile:http:handler'
- 'postgraphile:http:result'
- 'postgraphile:httpParamsList'
- 'postgraphile:liveSubscribe:executionResult'
- 'postgraphile:middleware'
- 'postgraphile:options'
- 'postgraphile:validationRules:static'
- 'postgraphile:validationRules'
- 'postgraphile:ws:onOperation'
- 'postgraphile:ws:onSubscribe'
- init
- pluginHook
- withPostGraphileContext
Type Aliases
Variables
variable withPostGraphileContext
const withPostGraphileContext: WithPostGraphileContextFn<ExecutionResult>;
Creates a PostGraphile context object which should be passed into a GraphQL execution. This function will also connect a client from a Postgres pool and setup a transaction in that client.
This function is intended to wrap a call to GraphQL-js execution like so:
const result = await withPostGraphileContext({pgPool,jwtToken,jwtSecret,pgDefaultRole,}, async context => {return await graphql(schema,query,null,{ ...context },variables,operationName,);});
variable withPostGraphQLContext
const withPostGraphQLContext: WithPostGraphileContextFn<ExecutionResult>;
Creates a PostGraphile context object which should be passed into a GraphQL execution. This function will also connect a client from a Postgres pool and setup a transaction in that client.
This function is intended to wrap a call to GraphQL-js execution like so:
const result = await withPostGraphileContext({pgPool,jwtToken,jwtSecret,pgDefaultRole,}, async context => {return await graphql(schema,query,null,{ ...context },variables,operationName,);});
Functions
function debugPgClient
debugPgClient: (pgClient: PoolClient, allowExplain?: boolean) => PoolClient;
Monkey-patches the
query
method of a pg Client to add debugging functionality. Use with care.
function enhanceHttpServerWithSubscriptions
enhanceHttpServerWithSubscriptions: < Request extends IncomingMessage = IncomingMessage, Response extends ServerResponse = ServerResponse>( websocketServer: Server, postgraphileMiddleware: HttpRequestHandler, subscriptionServerOptions?: { keepAlive?: number; graphqlRoute?: string }) => Promise<void>;
function enhanceHttpServerWithWebSockets
enhanceHttpServerWithWebSockets: < Request extends IncomingMessage = IncomingMessage, Response extends ServerResponse = ServerResponse>( websocketServer: Server, postgraphileMiddleware: HttpRequestHandler, subscriptionServerOptions?: { keepAlive?: number; graphqlRoute?: string }) => Promise<void>;
function makePluginHook
makePluginHook: (plugins: Array<PostGraphilePlugin>) => PluginHookFn;
function postgraphile
postgraphile: { < Request extends IncomingMessage = IncomingMessage, Response extends ServerResponse = ServerResponse >( poolOrConfig?: Pool | PoolConfig | string, schema?: string | Array<string>, options?: PostGraphileOptions<Request, Response> ): HttpRequestHandler; < Request extends IncomingMessage = IncomingMessage, Response extends ServerResponse = ServerResponse >( poolOrConfig?: any, options?: PostGraphileOptions<Request, Response> ): HttpRequestHandler<IncomingMessage, ServerResponse>;};
function postgraphql
postgraphql: { < Request extends IncomingMessage = IncomingMessage, Response extends ServerResponse = ServerResponse >( poolOrConfig?: Pool | PoolConfig | string, schema?: string | Array<string>, options?: PostGraphileOptions<Request, Response> ): HttpRequestHandler; < Request extends IncomingMessage = IncomingMessage, Response extends ServerResponse = ServerResponse >( poolOrConfig?: any, options?: PostGraphileOptions<Request, Response> ): HttpRequestHandler<IncomingMessage, ServerResponse>;};
Classes
class PostGraphileResponse
abstract class PostGraphileResponse {}
The base class for PostGraphile responses; collects headers, status code and body, and then hands to the relevant adaptor at the correct time.
property statusCode
statusCode: number;
method end
end: (moreBody?: Buffer | string | null) => void;
Use
endWithStream
orend
; not both
method endWithStream
endWithStream: () => PassThrough;
Use
endWithStream
orend
; not both.
method getNodeServerRequest
abstract getNodeServerRequest: () => IncomingMessage;
Returns the
res
object that the underlying HTTP server would have.
method getNodeServerResponse
abstract getNodeServerResponse: () => ServerResponse;
method setBody
abstract setBody: (body: Stream | Buffer | string | undefined) => void;
method setHeader
setHeader: (header: string, value: string) => void;
method setHeaders
abstract setHeaders: (statusCode: number, headers: Headers) => void;
class PostGraphileResponseFastify3
class PostGraphileResponseFastify3 extends PostGraphileResponse {}
Suitable for Fastify v3 (use PostGraphileResponseNode and middleware approach for Fastify v2)
constructor
constructor(request: CompatFastifyRequest, reply: CompatFastifyReply);
method endWithStream
endWithStream: () => PassThrough;
method getNodeServerRequest
getNodeServerRequest: () => IncomingMessage;
method getNodeServerResponse
getNodeServerResponse: () => ServerResponse;
method setBody
setBody: (body: Stream | Buffer | string | undefined) => void;
method setHeaders
setHeaders: (statusCode: number, headers: Headers) => void;
class PostGraphileResponseKoa
class PostGraphileResponseKoa extends PostGraphileResponse {}
Suitable for Koa.
constructor
constructor(ctx: CompatKoaContext, next: CompatKoaNext);
method endWithStream
endWithStream: () => PassThrough;
method getNextCallback
getNextCallback: () => CompatKoaNext;
method getNodeServerRequest
getNodeServerRequest: () => IncomingMessage;
method getNodeServerResponse
getNodeServerResponse: () => ServerResponse;
method setBody
setBody: (body: Stream | Buffer | string | undefined) => void;
method setHeaders
setHeaders: (statusCode: number, headers: Headers) => void;
class PostGraphileResponseNode
class PostGraphileResponseNode extends PostGraphileResponse {}
Suitable for Node's HTTP server, but also connect, express, restify and fastify v2.
constructor
constructor( req: IncomingMessage, res: ServerResponse, next: (e?: 'route' | Error) => void);
method getNextCallback
getNextCallback: () => (e?: Error | 'route' | undefined) => void;
method getNodeServerRequest
getNodeServerRequest: () => IncomingMessage;
method getNodeServerResponse
getNodeServerResponse: () => ServerResponse;
method setBody
setBody: (body: Stream | Buffer | string | undefined) => void;
method setHeaders
setHeaders: (statusCode: number, headers: Headers) => void;
Interfaces
interface CreateRequestHandlerOptions
interface CreateRequestHandlerOptions extends PostGraphileOptions {}
property getGqlSchema
getGqlSchema: () => Promise<GraphQLSchema>;
property pgPool
pgPool: Pool;
property shutdownActions
shutdownActions: ShutdownActions;
interface GraphQLFormattedErrorExtended
interface GraphQLFormattedErrorExtended {}
property extensions
extensions?: { [s: string]: any;};
property locations
locations: ReadonlyArray<SourceLocation> | void;
property message
message: string;
property path
path: ReadonlyArray<string | number> | void;
interface HttpRequestHandler
interface HttpRequestHandler< Request extends IncomingMessage = IncomingMessage, Response extends ServerResponse = ServerResponse> {}
A request handler for one of many different
http
frameworks.
property eventStreamRoute
eventStreamRoute: string;
property eventStreamRouteHandler
eventStreamRouteHandler: ((res: PostGraphileResponse) => Promise<void>) | null;
property faviconRouteHandler
faviconRouteHandler: ((res: PostGraphileResponse) => Promise<void>) | null;
property formatError
formatError: (e: GraphQLError) => GraphQLFormattedErrorExtended;
property getGraphQLSchema
getGraphQLSchema: () => Promise<GraphQLSchema>;
property graphiqlRoute
graphiqlRoute: string;
property graphiqlRouteHandler
graphiqlRouteHandler: ((res: PostGraphileResponse) => Promise<void>) | null;
property graphqlRoute
graphqlRoute: string;
property graphqlRouteHandler
graphqlRouteHandler: (res: PostGraphileResponse) => Promise<void>;
property handleErrors
handleErrors: ( errors: ReadonlyArray<GraphQLError>, req: Request, res: Response) => ReadonlyArray<GraphQLError | GraphQLErrorExtended>;
property options
options: CreateRequestHandlerOptions;
property pgPool
pgPool: Pool;
property release
release: () => Promise<void>;
Experimental!
property withPostGraphileContextFromReqRes
withPostGraphileContextFromReqRes: ( req: Request, res: Response, moreOptions: any, fn: (ctx: mixed) => any) => Promise<any>;
call signature
(req: Request, res: Response, next?: (error?: mixed) => void): Promise<void>;
call signature
( ctx: { req: Request; res: Response; }, next: () => void): Promise<void>;
interface PostGraphileOptions
interface PostGraphileOptions< Request extends IncomingMessage = IncomingMessage, Response extends ServerResponse = ServerResponse> extends PostGraphileCoreOptions {}
property additionalGraphQLContextFromRequest
additionalGraphQLContextFromRequest?: ( req: Request, res: Response) => Promise<Record<string, any>>;
property allowExplain
allowExplain?: DirectOrCallback<Request, boolean>;
property appendPlugins
appendPlugins?: Array<Plugin>;
property bodySizeLimit
bodySizeLimit?: string;
property classicIds
classicIds?: boolean;
property disableDefaultMutations
disableDefaultMutations?: boolean;
property disableQueryLog
disableQueryLog?: boolean;
property dynamicJson
dynamicJson?: boolean;
property enableCors
enableCors?: boolean;
property enableQueryBatching
enableQueryBatching?: boolean;
property enhanceGraphiql
enhanceGraphiql?: boolean;
property eventStreamRoute
eventStreamRoute?: string;
property exportGqlSchemaPath
exportGqlSchemaPath?: string;
property exportJsonSchemaPath
exportJsonSchemaPath?: string;
property extendedErrors
extendedErrors?: Array<string>;
property externalEventStreamRoute
externalEventStreamRoute?: string;
property externalGraphqlRoute
externalGraphqlRoute?: string;
property externalUrlBase
externalUrlBase?: string;
property graphiql
graphiql?: boolean;
property graphiqlCredentials
graphiqlCredentials?: 'include' | 'omit' | 'same-origin';
property graphiqlRoute
graphiqlRoute?: string;
property graphqlRoute
graphqlRoute?: string;
property handleErrors
handleErrors?: ( errors: ReadonlyArray<GraphQLError>, req: Request, res: Response) => ReadonlyArray<GraphQLError | GraphQLErrorExtended>;
property ignoreIndexes
ignoreIndexes?: boolean;
property ignoreRBAC
ignoreRBAC?: boolean;
property includeExtensionResources
includeExtensionResources?: boolean;
property jwtAudiences
jwtAudiences?: Array<string>;
property jwtPgTypeIdentifier
jwtPgTypeIdentifier?: string;
property jwtPublicKey
jwtPublicKey?: jwt.Secret | jwt.GetPublicKeyOrSecret;
property jwtRole
jwtRole?: Array<string>;
property jwtSecret
jwtSecret?: Exclude<jwt.Secret, KeyObject>;
property jwtSignOptions
jwtSignOptions?: jwt.SignOptions;
property jwtVerifyOptions
jwtVerifyOptions?: jwt.VerifyOptions;
property legacyJsonUuid
legacyJsonUuid?: boolean;
property legacyRelations
legacyRelations?: 'only' | 'deprecated' | 'omit';
property live
live?: boolean;
property ownerConnectionString
ownerConnectionString?: string;
property pgDefaultRole
pgDefaultRole?: string;
property pgSettings
pgSettings?: DirectOrCallback< Request, { [key: string]: mixed; }>;
property pluginHook
pluginHook?: PluginHookFn;
property prependPlugins
prependPlugins?: Array<Plugin>;
property queryCacheMaxSize
queryCacheMaxSize?: number;
property readCache
readCache?: string | Record<string, any>;
property replaceAllPlugins
replaceAllPlugins?: Array<Plugin>;
property retryOnInitFail
retryOnInitFail?: | boolean | ((error: Error, attempts: number) => boolean | Promise<boolean>);
property setofFunctionsContainNulls
setofFunctionsContainNulls?: boolean;
property showErrorStack
showErrorStack?: boolean | 'json';
property simpleCollections
simpleCollections?: 'omit' | 'both' | 'only';
property skipPlugins
skipPlugins?: Array<Plugin>;
property sortExport
sortExport?: boolean;
property subscriptions
subscriptions?: boolean;
property watchPg
watchPg?: boolean;
property websocketMiddlewares
websocketMiddlewares?: Array<Middleware<Request, Response>>;
property websocketOperations
websocketOperations?: 'all' | 'subscriptions';
property websockets
websockets?: ('v0' | 'v1')[];
property writeCache
writeCache?: string;
interface PostGraphilePlugin
interface PostGraphilePlugin {}
property 'cli:flags:add:deprecated'
'cli:flags:add:deprecated'?: HookFn<AddFlagFn>;
property 'cli:flags:add:errorHandling'
'cli:flags:add:errorHandling'?: HookFn<AddFlagFn>;
property 'cli:flags:add:jwt'
'cli:flags:add:jwt'?: HookFn<AddFlagFn>;
property 'cli:flags:add:noServer'
'cli:flags:add:noServer'?: HookFn<AddFlagFn>;
property 'cli:flags:add:plugins'
'cli:flags:add:plugins'?: HookFn<AddFlagFn>;
property 'cli:flags:add:schema'
'cli:flags:add:schema'?: HookFn<AddFlagFn>;
property 'cli:flags:add:standard'
'cli:flags:add:standard'?: HookFn<AddFlagFn>;
property 'cli:flags:add:webserver'
'cli:flags:add:webserver'?: HookFn<AddFlagFn>;
property 'cli:flags:add:workarounds'
'cli:flags:add:workarounds'?: HookFn<AddFlagFn>;
property 'cli:flags:add'
'cli:flags:add'?: HookFn<AddFlagFn>;
property 'cli:greeting'
'cli:greeting'?: HookFn<Array<string | null | void>>;
property 'cli:library:options'
'cli:library:options'?: HookFn< PostGraphileOptions, { config: any; cliOptions: any; }>;
property 'cli:server:created'
'cli:server:created'?: HookFn<Server>;
property 'cli:server:middleware'
'cli:server:middleware'?: HookFn<HttpRequestHandler>;
property 'postgraphile:graphiql:html'
'postgraphile:graphiql:html'?: HookFn<string>;
property 'postgraphile:http:end'
'postgraphile:http:end'?: HookFn<PostGraphileHTTPEnd>;
property 'postgraphile:http:eventStreamRouteHandler'
'postgraphile:http:eventStreamRouteHandler'?: HookFn< IncomingMessage, { options: CreateRequestHandlerOptions; response: PostGraphileResponse; }>;
property 'postgraphile:http:faviconRouteHandler'
'postgraphile:http:faviconRouteHandler'?: HookFn< IncomingMessage, { options: CreateRequestHandlerOptions; response: PostGraphileResponse; }>;
property 'postgraphile:http:graphiqlRouteHandler'
'postgraphile:http:graphiqlRouteHandler'?: HookFn< IncomingMessage, { options: CreateRequestHandlerOptions; response: PostGraphileResponse; }>;
property 'postgraphile:http:graphqlRouteHandler'
'postgraphile:http:graphqlRouteHandler'?: HookFn< IncomingMessage, { options: CreateRequestHandlerOptions; response: PostGraphileResponse; }>;
property 'postgraphile:http:handler'
'postgraphile:http:handler'?: HookFn<IncomingMessage>;
property 'postgraphile:http:result'
'postgraphile:http:result'?: HookFn<PostGraphileHTTPResult>;
property 'postgraphile:httpParamsList'
'postgraphile:httpParamsList'?: HookFn<Array<Record<string, any>>>;
property 'postgraphile:liveSubscribe:executionResult'
'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; }>;
property 'postgraphile:middleware'
'postgraphile:middleware'?: HookFn<HttpRequestHandler>;
property 'postgraphile:options'
'postgraphile:options'?: HookFn<PostGraphileOptions>;
property 'postgraphile:validationRules:static'
'postgraphile:validationRules:static'?: HookFn<typeof graphql.specifiedRules>;
property 'postgraphile:validationRules'
'postgraphile:validationRules'?: HookFn<typeof graphql.specifiedRules>;
property 'postgraphile:ws:onOperation'
'postgraphile:ws:onOperation'?: HookFn<ExecutionParams>;
property 'postgraphile:ws:onSubscribe'
'postgraphile:ws:onSubscribe'?: HookFn< graphql.ExecutionArgs & { document: graphql.DocumentNode | null; }, { context: graphqlWs.Context<any, GraphQLWSContextExtra>; message: graphqlWs.SubscribeMessage; options: CreateRequestHandlerOptions; }>;
property init
init?: HookFn< null, { version: string; graphql: typeof import('graphql'); }>;
property pluginHook
pluginHook?: HookFn<PluginHookFn>;
property withPostGraphileContext
withPostGraphileContext?: HookFn<WithPostGraphileContextFn>;
interface WithPostGraphileContextOptions
interface WithPostGraphileContextOptions {}
Options passed to the
withPostGraphileContext
function
property explain
explain?: boolean;
property jwtAudiences
jwtAudiences?: Array<string>;
property jwtPublicKey
jwtPublicKey?: jwt.Secret | jwt.GetPublicKeyOrSecret;
property jwtRole
jwtRole?: Array<string>;
property jwtSecret
jwtSecret?: Exclude<jwt.Secret, KeyObject>;
property jwtToken
jwtToken?: string;
property jwtVerifyOptions
jwtVerifyOptions?: jwt.VerifyOptions;
property operationName
operationName?: string;
property pgDefaultRole
pgDefaultRole?: string;
property pgForceTransaction
pgForceTransaction?: boolean;
property pgPool
pgPool: Pool;
property pgSettings
pgSettings?: { [key: string]: mixed;};
property queryDocumentAst
queryDocumentAst?: DocumentNode;
property singleStatement
singleStatement?: boolean;
property variables
variables?: any;
Type Aliases
type GraphQLErrorExtended
type GraphQLErrorExtended = GraphQLError & { extensions: { exception: { hint?: string; detail?: string; code: string; }; };};
type Middleware
type Middleware< Request extends IncomingMessage = IncomingMessage, Response extends ServerResponse = ServerResponse> = (req: Request, res: Response, next: (errOrEscape?: any) => void) => void;
type mixed
type mixed = Record<string, any> | string | number | boolean | undefined | null;
A narrower type than
any
that wonât swallow errors from assumptions about code.For example
(x as any).anything()
is ok. That function then returnsany
as well so the problem compounds into(x as any).anything().else()
and the problem just goes from there.any
is a type black hole that swallows any useful type information and shouldnât be used unless you know what youâre doing.With
mixed
you must *prove* the type is what you want to use.The
mixed
type is identical to themixed
type in Flow.See Also
https://github.com/Microsoft/TypeScript/issues/9999
https://flowtype.org/docs/builtins.html#mixed
Package Files (7)
Dependencies (27)
Dev Dependencies (57)
- @babel/core
- @babel/plugin-proposal-class-properties
- @babel/plugin-transform-runtime
- @babel/preset-env
- @babel/preset-react
- @babel/runtime
- @types/chalk
- @types/commander
- @types/compression
- @types/debug
- @types/finalhandler
- @types/http-errors
- @types/jest
- @types/koa-bodyparser
- @types/koa-compress
- @types/lru-cache
- @types/morgan
- @types/node
- @types/parseurl
- @types/restify
- @typescript-eslint/eslint-plugin
- @typescript-eslint/parser
- babel-loader
- compression
- connect
- conventional-changelog-cli
- css-loader
- eslint
- eslint-config-prettier
- eslint-plugin-jest
- eslint-plugin-prettier
- express
- fastify
- fastify-compress
- fastify-cookie
- fastify-formbody
- fastify-v2
- helmet
- html-webpack-inline-source-plugin
- html-webpack-plugin
- http-proxy
- jest
- koa
- koa-bodyparser
- koa-compress
- koa-mount
- morgan
- nodemon
- pg-minify
- prettier
- restify
- source-map-support
- style-loader
- superagent
- ts-node
- typescript
- webpack
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/postgraphile
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/postgraphile)
- HTML<a href="https://www.jsdocs.io/package/postgraphile"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 5899 ms. - Missing or incorrect documentation? Open an issue for this package.