apollo-logging-plugin
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

Apollo Logging Plugin

Adds colorful logs to your Apollo Server.

Installation

npm i apollo-logging-plugin #npm
yarn add apollo-logging-plugin #yarn
pnpm add apollo-logging-plugin #pnpm

Usage

import { ApolloServer, BaseContext } from '@apollo/server';
import { ApolloLogPlugin } from 'apollo-logging-plugin';

const server = new ApolloServer<BaseContext>({
  typeDefs,
  resolvers,
  plugins: [ApolloLogPlugin()]
});

Custom handlers

import { ApolloServer, BaseContext } from '@apollo/server';
import { ApolloLogPlugin, type Log } from 'apollo-logging-plugin';

const handlers = (log: Log) => ({
  didEncounterErrors: log.error,
  didResolveOperation: log.info,
  didEncounterSubsequentErrors: (context) =>
    log.error(context, 'Custom Message'),
  parsingDidStart: (context) => {
    // handle event
  }
  // ... other handlers
});

const server = new ApolloServer<BaseContext>({
  typeDefs,
  resolvers,
  plugins: [ApolloLogPlugin(handlers)]
});

This is a typescript library built with ts-lib-starter. Build yours now ->

/apollo-logging-plugin/

    Package Sidebar

    Install

    npm i apollo-logging-plugin

    Weekly Downloads

    4

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    11.2 kB

    Total Files

    8

    Last publish

    Collaborators

    • youssef-ahamid