apollo-logging-plugin
v1.0.2
Published
Colorful Logs for your Apollo GraphQL server
Downloads
153
Maintainers
Readme
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 ->