Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/youssef-ahamid/apollo-logging-plugin
Colorful Logs for your Apollo GraphQL server
https://github.com/youssef-ahamid/apollo-logging-plugin
apollo apollo-server apollo-server-express log logger logging typescript typescript-library
Last synced: 19 days ago
JSON representation
Colorful Logs for your Apollo GraphQL server
- Host: GitHub
- URL: https://github.com/youssef-ahamid/apollo-logging-plugin
- Owner: youssef-ahamid
- Created: 2023-03-16T18:00:00.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-03-16T22:43:19.000Z (almost 2 years ago)
- Last Synced: 2024-11-30T09:20:19.023Z (about 1 month ago)
- Topics: apollo, apollo-server, apollo-server-express, log, logger, logging, typescript, typescript-library
- Language: TypeScript
- Homepage:
- Size: 57.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# Apollo Logging Plugin
Adds colorful logs to your Apollo Server.
## Installation
```bash
npm i apollo-logging-plugin #npm
yarn add apollo-logging-plugin #yarn
pnpm add apollo-logging-plugin #pnpm
```## Usage
```typescript
import { ApolloServer, BaseContext } from '@apollo/server';
import { ApolloLogPlugin } from 'apollo-logging-plugin';const server = new ApolloServer({
typeDefs,
resolvers,
plugins: [ApolloLogPlugin()]
});
```### Custom [handlers](https://www.apollographql.com/docs/apollo-server/integrations/plugins/#responding-to-events)
```typescript
import { ApolloServer, BaseContext } from '@apollo/server';
import { ApolloLogPlugin } 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({
typeDefs,
resolvers,
plugins: [ApolloLogPlugin(handlers)]
});
```> This is a typescript library built with `ts-lib-starter`. [Build yours now ->]('https://github.com/youssef-ahamid/ts-lib-starter/')