@totalsoft/pino-apollo
TypeScript icon, indicating that this package has built-in type declarations

2.1.0 • Public • Published

pino-apollo

An apollo server plugin that logs the main events related to a request. It uses the pino logger.

In addition, it comes with a cool feature called securedMessages which will make sure that sensitive error messages does not leak outside your server. All the errors thrown inside an Apollo Server, are wrapped in a 'user friendly message', helping increase the security of your server.

Installation

npm i @totalsoft/pino-apollo

or

yarn add @totalsoft/pino-apollo

Usage with Apollo Server plugins

import { ApolloLoggerPlugin } from '@totalsoft/pino-apollo'
import { ApolloServer } from '@apollo/server'
import pino from 'pino'

const logger = pino()

const plugins = [ApolloLoggerPlugin({ logger, securedMessages: false})]
const apollo = new ApolloServer({
  plugins,
  ...
})

See Apollo Plugins documentation for more information.

Configuration Options

- ApolloLoggingOptions

The ApolloLoggerPlugin class can be instantiated using the following configuration options:

{
  // Pre-configured pino logger. Default is `console`.
  logger: Logger
  // If 'true', errors thrown inside Apollo Server are wrapped in a 'user friendly message'. Default is 'true'.
  securedMessages?: boolean
}

Package Sidebar

Install

npm i @totalsoft/pino-apollo

Weekly Downloads

284

Version

2.1.0

License

MIT

Unpacked Size

95.7 kB

Total Files

16

Last publish

Collaborators

  • osstotalsoft