3.0.0-rc.9 • Published 9 months ago

@debugr/apollo v3.0.0-rc.9

Weekly downloads
3
License
MIT
Repository
-
Last release
9 months 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

9 months ago

3.0.0-rc.6

1 year ago

3.0.0-rc.5

1 year ago

3.0.0-rc.8

1 year ago

3.0.0-rc.7

1 year ago

3.0.0-rc.2

2 years ago

3.0.0-rc.4

2 years ago

3.0.0-rc.3

2 years ago

3.0.0-rc.1

2 years ago

2.0.0

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

4 years ago

1.0.0

4 years ago