3.0.0-rc.9 • Published 2 years ago

@debugr/apollo v3.0.0-rc.9

Weekly downloads
3
License
MIT
Repository
-
Last release
2 years ago

Apollo Server plugin for Debugr

This plugin provides GraphQL query logging for Apollo Server.

Installation

npm install --save @debugr/apollo

Usage

Standalone Apollo Server:

import { ApolloServer } from 'apollo-server';
import { Logger, LogLevel } from '@debugr/core';
import { ApolloCollector } from '@debugr/apollo';
import { ConsoleHandler } from '@debugr/console';

const globalContext = {
  applicationName: 'example',
};

const logger = new Logger(globalContext, [
  new ConsoleHandler({
    threshold: LogLevel.INFO,
  }),
  new ApolloCollector(),
]);

const server = new ApolloServer({
  // typeDefs, resolvers, ...
  plugins: [
    logger.getPlugin('apollo'),
  ],
});

With Express integration and plugin:

import { ApolloServer } from 'apollo-server-express';
import * as express from 'express';
import { Logger, LogLevel } from '@debugr/core';
import { ExpressCollector } from '@debugr/express';
import { ApolloCollector } from '@debugr/apollo';
import { ConsoleHandler } from '@debugr/console';

const globalContext = {
  applicationName: 'example',
};

const logger = new Logger(globalContext, [
  new ConsoleHandler({
    threshold: LogLevel.INFO,
  }),
  new ExpressCollector(),
  new ApolloCollector(),
]);

const app = express();

const server = new ApolloServer({
  // typeDefs, resolvers, ...
  plugins: [
    debug.getPlugin('apollo'),
  ],
});

app.use(logger.getPlugin('express').createRequestHandler());

server.applyMiddleware({ app });

app.use(logger.getPlugin('express').createErrorHandler());

app.listen(8000);

Options

The ApolloCollector constructor accepts an optional options object with the following keys as the first argument:

OptionTypeDefaultDescription
levelLogLevelLogLevel.INFOThe level at which GraphQL queries are logged.
3.0.0-rc.9

2 years ago

3.0.0-rc.6

3 years ago

3.0.0-rc.5

3 years ago

3.0.0-rc.8

2 years ago

3.0.0-rc.7

3 years ago

3.0.0-rc.2

3 years ago

3.0.0-rc.4

3 years ago

3.0.0-rc.3

3 years ago

3.0.0-rc.1

3 years ago

2.0.0

4 years ago

1.0.3

4 years ago

1.0.2

5 years ago

1.0.1

5 years ago

1.0.0

5 years ago