@shovelandsandbox/artemis
TypeScript icon, indicating that this package has built-in type declarations

0.0.2 • Public • Published
Apollo Server

tests cover size

Artemis

A logging plugin for Apollo GraphQL Server

❤️ Please consider Sponsoring our work

This module provides uniform logging for the entire GraphQL request lifecycle, as provided by plugin hooks in apollo-server. The console/terminal result of which will resemble the image below:

Requirements

artemis is an evergreen 🌲 module.

This module requires an Active LTS Node version (v10.23.1+).

Install

Using npm:

npm install @shovelandsandbox/artemis

Usage

Setting up artemis is straight-forward. Import and call the plugin function, passing any desired options, and pass the plugin in an array to apollo-server.

import { ArtemisLoggingPlugin } from '@shovelandsandbox/artemis';
import { ApolloServer } from 'apollo-server';

const options = { ... };
const plugins = [ArtemisLoggingPlugin(options)];
const apollo = new ApolloServer({
  plugins,
  ...
});

Please see the Apollo Plugins documentation for more information.

Options

events

Type: Record<string, boolean>
Default:

{
  didEncounterErrors: true,
  didResolveOperation: false,
  executionDidStart: false,
  parsingDidStart: false,
  responseForOperation: false,
  validationDidStart: false,
  willSendResponse: true
}

Specifies which Apollo lifecycle events will be logged. The requestDidStart event is always logged, and by default didEncounterErrors and willSendResponse are logged.

mutate

Type: Function Default: (data: Record<string, string>) => Record<string, string>

If specified, allows inspecting and mutating the data logged to the console for each message.

prefix

Type: String
Default: apollo

Specifies a prefix, colored by level, prepended to each log message.

timestamp

Type: Boolean

If true, will prepend a timestamp in the HH:mm:ss format to each log message.

Meta

CONTRIBUTING

LICENSE (Mozilla Public License)


Package Sidebar

Install

npm i @shovelandsandbox/artemis

Weekly Downloads

5

Version

0.0.2

License

MPL-2.0

Unpacked Size

30.8 kB

Total Files

6

Last publish

Collaborators

  • shovelandsandbox